# HG changeset patch # User nishanth # Date 1267306313 -19800 # Node ID 8632a44b743def8097c2d800f07af4caab6037f9 # Parent 0ede6b2c5cd11600879f088559fb4c429bd04b8e deducing previous credits for a task using the request model. with a few changes, we can ditchax the credits model. diff -r 0ede6b2c5cd1 -r 8632a44b743d taskapp/forms/task.py --- 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): diff -r 0ede6b2c5cd1 -r 8632a44b743d taskapp/views/task.py --- 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) diff -r 0ede6b2c5cd1 -r 8632a44b743d templates/task/assigncredits.html --- 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 %} Mark task as complete.