merged.
authoranoop
Wed, 24 Feb 2010 20:33:45 +0530
changeset 88 0b6d251d3c30
parent 87 f0a3d6612462 (current diff)
parent 86 fcbdf372857c (diff)
child 89 1cc03941ed5d
merged.
--- a/taskapp/models.py	Wed Feb 24 20:32:57 2010 +0530
+++ b/taskapp/models.py	Wed Feb 24 20:33:45 2010 +0530
@@ -133,20 +133,19 @@
     sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False)
     sent_by = models.ForeignKey(User, related_name = "%(class)s_sent_by", blank = False)
     role = models.CharField(max_length = 2, blank = False)
-    is_active = models.BooleanField(default = True)
     reply = models.BooleanField(default = False)
     is_read = models.BooleanField(default = False)
     creation_date = models.DateTimeField()
     reply_date = models.DateTimeField()
     is_replied = models.BooleanField(default = False)
-    replied_by = models.ForeignKey(User, related_name = "%(class)s_replied_by", blank = False)
+    replied_by = models.ForeignKey(User, related_name = "%(class)s_replied_by", blank = True, null = True)
     task = models.ForeignKey(Task,related_name = "%(class)s_task", blank = True, null = True)
     receiving_user = models.ForeignKey(User, related_name = "%(class)s_receiving_user", blank = True, null = True)
     pynts = models.PositiveIntegerField(default=0)
 
     def __unicode__(self):
 
-        return u"Request %s %s"%(self.by.username, self.role)
+        return u"Request %s %s"%(self.sent_by.username, self.role)
 
 class Notification(models.Model):
 
--- a/taskapp/views/user.py	Wed Feb 24 20:32:57 2010 +0530
+++ b/taskapp/views/user.py	Wed Feb 24 20:33:45 2010 +0530
@@ -99,7 +99,7 @@
 def browse_requests(request):
     
     user = request.user
-    active_reqs = user.request_to.filter(replied=False)
+    active_reqs = user.request_sent_to.filter(is_replied=False)
     reqs = active_reqs.order_by('creation_date').reverse()
     for pos, req in enumerate(reversed(reqs)):
         req.pos = pos
@@ -117,13 +117,13 @@
     """
 
     user = request.user
-    reqs = user.request_to.filter(replied=False).order_by('creation_date')
+    reqs = user.request_sent_to.filter(is_replied=False).order_by('creation_date')
     user_request = reqs[int(rid)]
 
     context = {
         'user':user,
         'req':user_request,
-        'sent_users':user_request.to.all()
+        'sent_users':user_request.sent_to.all()
     }
 
     return render_to_response('user/view_request.html', context)
@@ -137,9 +137,9 @@
     if request.method=="POST":
         user = request.user
         browse_request_url= '/user/requests'
-        reqs = user.request_to.filter(replied=False).order_by('creation_date')
+        reqs = user.request_sent_to.filter(is_replied=False).order_by('creation_date')
         user_request = reqs[int(rid)]
-
+        
         return show_msg("Your reply has been processed", browse_request_url, "view other requests")
     else:
         return show_msg("You are not authorised to do this", browse_request_url, "view other requests")
--- a/templates/user/browse_requests.html	Wed Feb 24 20:32:57 2010 +0530
+++ b/templates/user/browse_requests.html	Wed Feb 24 20:33:45 2010 +0530
@@ -1,7 +1,7 @@
 {% extends 'base.html' %}
 {% block content %}
     {% for req in reqs %}
-        <form><a href="/user/requests/rid={{req.pos}}">{{req.by.username}}|{{req.role}}|
+        <form><a href="/user/requests/rid={{req.pos}}">{{req.sent_by.username}}|{{req.role}}|
         {% ifequal req.role "PY" %}            
             {{req.task.title}}
         {% endifequal %}</a><br /></form>
--- a/templates/user/view_request.html	Wed Feb 24 20:32:57 2010 +0530
+++ b/templates/user/view_request.html	Wed Feb 24 20:33:45 2010 +0530
@@ -1,6 +1,6 @@
 {% extends 'base.html' %}
 {% block content %}
-    From:&nbsp; <a href=""/user/view/uid={{req.by.id}}"">{{req.by.username}}</a><br />
+    From:&nbsp; <a href="/user/view/uid={{req.sent_by.id}}">{{req.sent_by.username}}</a><br />
     To: 
     {% for to_user in sent_users %}
         <a href="/user/view/uid={{to_user.id}}">{{to_user.username}}</a>,&nbsp;
@@ -8,17 +8,19 @@
     <br />
     Message: <br />
     {% ifequal "PY" req.role %}
-        <a href="/user/view/uid={{req.by.id}}">{{req.by.username}}</a> assigned {{req.pynts}} pynts to 
-        <a href="/user/view/uid={{req.assigned_to.id}}">{{req.assigned_to.username}}</a> for the task
+        <a href="/user/view/uid={{req.sent_by.id}}">{{req.sent_by.username}}</a> assigned {{req.pynts}} pynts to 
+        <a href="/user/view/uid={{req.receiving_user.id}}">{{req.receiving_user.username}}</a> for the task
         <a href="/task/view/tid={{req.task.id}}">{{req.task.title}}</a><br />
         Please click yes/no<br />
-        <form action="yes/" method="post">
-            <input value="Yes" type="submit">
-        </form>
-        <form action="no/" method="post">
-            <input value="No" type="submit">
-        </form>
     {% else %}
     {% endifequal %}
     
+    <form action="yes/" method="post">
+        <input value="Yes" type="submit">
+    </form>
+    <form action="no/" method="post">
+        <input value="No" type="submit">
+    </form>
+    <a href="/user/requests/">Click here</a> to return to the requests page.
+    
 {% endblock %}