ditchaxed the claims model.
--- 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)
--- 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:
--- 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 """
--- 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)
--- 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)
--- 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 @@
<a href="/task/assign/tid={{task.id}}">Select a user to assign the work.</a><sup><a href="/about/assigntask/" target="_blank">learn more</a></sup>
{% endif %}
{% if user_can_claim %}
+ <!--
{% if errors %}
{% for error in errors %}
{{error}}<br />
@@ -37,7 +38,15 @@
<form action="" method="post">
<textarea name="message"></textarea><br />
<input type="submit" value="Submit Claim"><br />
- Please note that you can claim only once and so write your proposal carefully.<br />
+
</form>
+ -->
+ <hr />
+ <form action="" method="post">
+ {{form.as_p}}
+ <input type="submit" value="Submit Claim"><br />
+ Please note that you can claim only once and so write your proposal carefully.<br />
+ </form>
{% endif %}
+
{% endblock %}