# HG changeset patch # User Nishanth Amuluru # Date 1294251670 -19800 # Node ID 807e4b701a20547d9819d4b723c015301d1d2c3b # Parent f04a1ec7a07f8a920498e8485ed3db276109125f added a submit_report link for each task diff -r f04a1ec7a07f -r 807e4b701a20 taskapp/forms/task.py --- a/taskapp/forms/task.py Wed Jan 05 22:30:45 2011 +0530 +++ b/taskapp/forms/task.py Wed Jan 05 23:51:10 2011 +0530 @@ -1,5 +1,5 @@ from django import forms -from pytask.taskapp.models import Task +from pytask.taskapp.models import Task, WorkReport class TaskCreateForm(forms.ModelForm): class Meta: @@ -99,3 +99,8 @@ reason = forms.CharField(min_length=1, required=True) return myForm(instance) if instance else myForm() +class WorkReportForm(forms.ModelForm): + + class Meta: + model = WorkReport + fields = ['remarks', 'attachment'] diff -r f04a1ec7a07f -r 807e4b701a20 taskapp/models.py --- a/taskapp/models.py Wed Jan 05 22:30:45 2011 +0530 +++ b/taskapp/models.py Wed Jan 05 23:51:10 2011 +0530 @@ -169,5 +169,15 @@ def __unicode__(self): return u"%s %s %s"%(self.sent_to, self.message, self.sent_date.ctime()) +class WorkReport(models.Model): + + attachment = models.FileField(upload_to = UPLOADS_DIR, blank = False) + remarks = models.TextField() + revision = models.PositiveIntegerField(default=0) + task = models.ForeignKey(Task, related_name = "%(class)s_report") + submitted_by = models.ForeignKey(Task, related_name = "%(class)s_submitted_by") + + created_at = models.DateTimeField() + #tagging.register(Profile) #tagging.register(Task) diff -r f04a1ec7a07f -r 807e4b701a20 taskapp/views/task.py --- a/taskapp/views/task.py Wed Jan 05 22:30:45 2011 +0530 +++ b/taskapp/views/task.py Wed Jan 05 23:51:10 2011 +0530 @@ -5,7 +5,7 @@ from pytask.taskapp.models import User, Task, Comment, Request, Notification from pytask.taskapp.utilities.task import getTask -from pytask.taskapp.forms.task import TaskCreateForm, AddReviewerForm, AddTaskForm, ChoiceForm, AssignPyntForm, RemoveUserForm, EditTaskForm, ClaimTaskForm +from pytask.taskapp.forms.task import TaskCreateForm, AddReviewerForm, AddTaskForm, ChoiceForm, AssignPyntForm, RemoveUserForm, EditTaskForm, ClaimTaskForm, WorkReportForm from pytask.taskapp.events.task import createTask, reqReviewer, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignPynts, completeTask, closeTask, addReviewer, deleteTask from pytask.taskapp.views.user import show_msg from pytask.taskapp.utilities.user import get_user @@ -39,6 +39,34 @@ } return render_to_response('task/browse.html', context) +def upload_work(request, tid): + """ Check if the work is in WR state and the user is in assigned_users. + """ + + task_url = "/task/view/tid=%s"%tid + + user = get_user(request.user) if request.user.is_authenticated() else request.user + task = getTask(tid) + + if not task.status == "WR": + return show_msg(user, "The task is not in a stage to upload content", task_url, "view the task") + + if not user in task.assigned_users.all(): + return show_msg(user, "You are not authorised to upload data to this task", task_url, "view the task") + + + context = { + 'user':user, + 'task':task, + } + + if request.method == "POST": + pass + else: + form = WorkReportForm() + return render_to_response('task/report.html', context) + + def publish_task(request, tid): """ check if user is the reviewer and also if the task status is UP. """ diff -r f04a1ec7a07f -r 807e4b701a20 templates/task/report.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/task/report.html Wed Jan 05 23:51:10 2011 +0530 @@ -0,0 +1,7 @@ +{% extends 'base.html' %} +{% block title %} + {{task.title}} +{% endblock %} +{% block content %} + +{% endblock %} diff -r f04a1ec7a07f -r 807e4b701a20 templates/task/view.html --- a/templates/task/view.html Wed Jan 05 22:30:45 2011 +0530 +++ b/templates/task/view.html Wed Jan 05 23:51:10 2011 +0530 @@ -132,6 +132,7 @@ {% if is_reviewer %} View claims {% else %} + Submit Work Claim the task {% endif %} {% endif %} diff -r f04a1ec7a07f -r 807e4b701a20 urls.py --- a/urls.py Wed Jan 05 22:30:45 2011 +0530 +++ b/urls.py Wed Jan 05 23:51:10 2011 +0530 @@ -124,5 +124,6 @@ (r'^about/(\w+)/$', userViews.learn_more), (r'^textbook/$', taskViews.show_textbooks), + (r'^task/report/tid=(\w+)/$', taskViews.upload_work), )