# HG changeset patch # User nishanth # Date 1267709927 -19800 # Node ID 0c317f68df49620d8d0cd6f189149c2d16890360 # Parent fa1da06d25c9d5dc8618c6cc06a3cdf1c2efb14d ditchaxed the claims model. diff -r fa1da06d25c9 -r 0c317f68df49 taskapp/admin.py --- a/taskapp/admin.py Thu Mar 04 18:30:55 2010 +0530 +++ b/taskapp/admin.py Thu Mar 04 19:08:47 2010 +0530 @@ -1,10 +1,9 @@ from django.contrib import admin -from pytask.taskapp.models import Profile, Task, Comment, Claim, Notification, Request +from pytask.taskapp.models import Profile, Task, Comment, Notification, Request admin.site.register(Profile) admin.site.register(Task) admin.site.register(Comment) -admin.site.register(Claim) admin.site.register(Notification) admin.site.register(Request) diff -r fa1da06d25c9 -r 0c317f68df49 taskapp/events/task.py --- a/taskapp/events/task.py Thu Mar 04 18:30:55 2010 +0530 +++ b/taskapp/events/task.py Thu Mar 04 19:08:47 2010 +0530 @@ -1,5 +1,5 @@ from datetime import datetime -from pytask.taskapp.models import Profile, Task, Comment, Claim, Map +from pytask.taskapp.models import Profile, Task, Comment, Map from pytask.taskapp.utilities.task import getTask from pytask.taskapp.utilities.request import create_request from pytask.taskapp.utilities.helper import get_key @@ -141,12 +141,6 @@ task.claimed_users.add(user) task.save() - claim = Claim() - claim.message = message - claim.task = task - claim.user = user - claim.creation_datetime = datetime.now() - claim.save() pending_reqs = user.request_sent_to.filter(is_replied=False, is_valid=True, role="MT", task=task).all() for req in pending_reqs: diff -r fa1da06d25c9 -r 0c317f68df49 taskapp/forms/task.py --- a/taskapp/forms/task.py Thu Mar 04 18:30:55 2010 +0530 +++ b/taskapp/forms/task.py Thu Mar 04 19:08:47 2010 +0530 @@ -1,5 +1,5 @@ from django import forms -from pytask.taskapp.models import Task, Claim +from pytask.taskapp.models import Task class TaskCreateForm(forms.ModelForm): class Meta: @@ -53,10 +53,15 @@ form = myform(instance) if instance else myform() return form -class ClaimTaskForm(forms.ModelForm): - class Meta: - model = Claim - fields = ['message'] +class ClaimTaskForm(forms.Form): + message = forms.CharField(label="Proposal") + + def clean_message(self): + data = self.cleaned_data['message'].strip() + if not data: + raise forms.ValidationError('Enter something as a proposal') + return data + def ChoiceForm(choices, instance=None): """ return a form object with appropriate choices """ diff -r fa1da06d25c9 -r 0c317f68df49 taskapp/models.py --- a/taskapp/models.py Thu Mar 04 18:30:55 2010 +0530 +++ b/taskapp/models.py Thu Mar 04 19:08:47 2010 +0530 @@ -127,13 +127,6 @@ def __unicode__(self): return unicode(self.task.title) -class Claim(models.Model): - - task = models.ForeignKey('Task') - user = models.ForeignKey(User) - message = models.TextField() - creation_datetime = models.DateTimeField() - class Request(models.Model): sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False) diff -r fa1da06d25c9 -r 0c317f68df49 taskapp/views/task.py --- a/taskapp/views/task.py Thu Mar 04 18:30:55 2010 +0530 +++ b/taskapp/views/task.py Thu Mar 04 19:08:47 2010 +0530 @@ -3,9 +3,9 @@ from django.http import HttpResponse, Http404 from django.shortcuts import render_to_response, redirect -from pytask.taskapp.models import User, Task, Comment, Claim, Request, Notification +from pytask.taskapp.models import User, Task, Comment, Request, Notification from pytask.taskapp.utilities.task import getTask -from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm, EditTaskForm +from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm, EditTaskForm, ClaimTaskForm from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignCredits, completeTask, closeTask, addMentor, deleteTask from pytask.taskapp.views.user import show_msg from pytask.taskapp.utilities.user import get_user @@ -342,7 +342,7 @@ user = get_user(request.user) if request.user.is_authenticated() else request.user task = getTask(tid) - #claims = Claim.objects.filter(task=task) + #claims = task.notifications_task.filter(role="CL",sent_to=task.created_by) # this is what the next line should be when i re sync the db claims = Notification.objects.filter(task=task, sent_to=task.created_by, role="CL") @@ -368,13 +368,16 @@ 'errors':errors} if not is_guest: + form = ClaimTaskForm() + context['form'] = form if request.method == "POST": - claim_proposal = request.POST['message'] - if claim_proposal: + form = ClaimTaskForm(request.POST) + context['form'] = form + if form.is_valid(): + claim_proposal = form.cleaned_data['message'] addClaim(task, claim_proposal, user) return redirect(claim_url) else: - errors.append('Please fill up proposal in the field below') return render_to_response('task/claim.html', context) else: return render_to_response('task/claim.html', context) diff -r fa1da06d25c9 -r 0c317f68df49 templates/task/claim.html --- a/templates/task/claim.html Thu Mar 04 18:30:55 2010 +0530 +++ b/templates/task/claim.html Thu Mar 04 19:08:47 2010 +0530 @@ -26,6 +26,7 @@ Select a user to assign the work.learn more {% endif %} {% if user_can_claim %} + +
+
+ {{form.as_p}} +
+ Please note that you can claim only once and so write your proposal carefully.
+
{% endif %} + {% endblock %}