deducing previous credits for a task using the request model. with a few changes, we can ditchax the credits model.
authornishanth
Sun, 28 Feb 2010 03:01:53 +0530
changeset 136 8632a44b743d
parent 135 0ede6b2c5cd1
child 137 e56b95298254
deducing previous credits for a task using the request model. with a few changes, we can ditchax the credits model.
taskapp/forms/task.py
taskapp/views/task.py
templates/task/assigncredits.html
--- a/taskapp/forms/task.py	Sun Feb 28 02:45:21 2010 +0530
+++ b/taskapp/forms/task.py	Sun Feb 28 03:01:53 2010 +0530
@@ -46,7 +46,7 @@
     
     class myForm(forms.Form):
         user = forms.ChoiceField(choices=choices, required=True)
-        points = forms.IntegerField(min_value=0,required=True)
+        pynts = forms.IntegerField(min_value=0, required=True, help_text="Choose wisely since it cannot be undone.")
     return myForm(instance) if instance else myForm()
 
 def RemoveUserForm(choices, instance=None):
--- a/taskapp/views/task.py	Sun Feb 28 02:45:21 2010 +0530
+++ b/taskapp/views/task.py	Sun Feb 28 03:01:53 2010 +0530
@@ -433,8 +433,7 @@
             choices = [(_.id,_.username) for _ in task.mentors.all()]
             if task.status == "WR":
                 choices.extend([(_.id, _.username) for _  in task.assigned_users.all() ])
-            prev_credits = task.credit_set.all()
-            ## here we can ditchax credits model and use the request model
+            prev_credits = task.request_task.filter(role="PY",is_valid=True,is_replied=True,reply=True).count()
             credit_requests = task.request_task.filter(role="PY",is_valid=True).order_by('creation_date').reverse()
             form = AssignCreditForm(choices)
 
@@ -452,7 +451,7 @@
                 if form.is_valid():
                     data = form.cleaned_data
                     uid = data['user']
-                    points = data['points']
+                    points = data['pynts']
                     given_to = User.objects.get(id=uid)
                     assignCredits(task=task, given_by=user, given_to=given_to, points=points)
                     return redirect('/task/assigncredits/tid=%s'%task.id)
--- a/templates/task/assigncredits.html	Sun Feb 28 02:45:21 2010 +0530
+++ b/templates/task/assigncredits.html	Sun Feb 28 03:01:53 2010 +0530
@@ -12,6 +12,8 @@
         {% if prev_credits %}
             <a href="/task/complete/tid={{task.id}}">Mark task as complete.</a>
             <hr />
+        {% endif %}
+        {% if credit_requests %}
             <br/>Previous credits:<br />
             {% for req in credit_requests %}
             <hr />
@@ -34,5 +36,7 @@
                     status: Request pending
                 {% endif %}
             {% endfor %}
+        {% else %}
+            No assigning of pynts has been made for this task.
         {% endif %}
 {% endblock %}