--- 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']
--- 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)
--- 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.
"""
--- /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 %}
--- 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 %}
+ <a href="/task/report/tid={{task.id}}">Submit Work</a>
Claim the task
{% endif %}</a>
{% endif %}
--- 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),
)