changed request model, added create_request utility.
--- a/taskapp/admin.py Tue Feb 23 14:31:54 2010 +0530
+++ b/taskapp/admin.py Tue Feb 23 15:27:00 2010 +0530
@@ -1,6 +1,6 @@
from django.contrib import admin
-from pytask.taskapp.models import Profile, Task, Credit, Comment, Claim, Notification
+from pytask.taskapp.models import Profile, Task, Credit, Comment, Claim, Notification, Request
admin.site.register(Profile)
admin.site.register(Task)
@@ -8,3 +8,4 @@
admin.site.register(Credit)
admin.site.register(Claim)
admin.site.register(Notification)
+admin.site.register(Request)
--- a/taskapp/models.py Tue Feb 23 14:31:54 2010 +0530
+++ b/taskapp/models.py Tue Feb 23 15:27:00 2010 +0530
@@ -110,14 +110,15 @@
class Request(models.Model):
- to = models.ForeignKey(User, related_name = "%(class)s_to", blank = False)
+ to = models.ManyToManyField(User, related_name = "%(class)s_to", blank = False)
by = models.ForeignKey(User, related_name = "%(class)s_by", blank = False)
role = models.CharField(max_length = 2, blank = False)
is_active = models.BooleanField(default = True)
reply = models.BooleanField(default = False)
- read = models.BooleanField()
+ read = models.BooleanField(default = False)
creation_date = models.DateTimeField()
reply_date = models.DateTimeField()
+ replied = models.BooleanField(default = False)
class Notification(models.Model):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskapp/utilities/request.py Tue Feb 23 15:27:00 2010 +0530
@@ -0,0 +1,17 @@
+from pytask.taskapp.models import Request
+from datetime import datetime
+
+def create_request(to,by,role):
+ """
+ creates an unreplied request, based on the passed arguments
+ to - a list of users to which the notification is to be sent
+ by - sender of request
+ role - a two character field which represents the role requested
+ """
+ req = Request(creation_date=datetime.now())
+ req.by = by
+ req.reply_date = datetime(1970,01,01)
+ req.save()
+ req.to = to
+ req.role = role
+ req.save()