Commits

Anonymous committed 755c816

delete section updated - doesn't work yet

  • Participants
  • Parent commits 32a97cd

Comments (0)

Files changed (5)

File taskhood/tasks/urls.py

 
     (r'^create_task/(?P<tasklist_key>[\w\-]+)/$', 'taskhood.tasks.views.create_task'),
     (r'^create_column/$', 'taskhood.tasks.views.create_column'),
-    (r'^delete_task/(?P<task_key>[\w\-]+)/$', 'taskhood.tasks.views.delete_task'),
+    (r'^delete_task/(?P<task_key>[\w\-]+)/(?P<tasklist_key>[\w\-]+)/$', 'taskhood.tasks.views.delete_task'),
     (r'^xd_receiver\.htm$', 'taskhood.tasks.views.xd_receiver'),
 
     (r'^create_task_list/', 'taskhood.tasks.views.create_task_list'),

File taskhood/tasks/urls.pyc

Binary file modified.

File taskhood/tasks/views.py

     return
 
 
-def delete_task(request, task_key):
+def delete_task(request, task_key, tasklist_key):
+    logging.info("Delete Task")
     task = db.get(task_key)
-    for t in TaskList.all().filter('created_by =', users.get_current_user()):
-        logging.debug("checking")
-        if task.key in t.tasks:
-            logging.debug("inside")
-            tasklist = t
-            db.delete(db.Key(task_key))#remove the task from DB
+    tasklist = db.get(tasklist_key)
+    user = users.get_current_user()
+    if (tasklist.created_by == user) or (user.email() in tasklist.shared_users_emails):
+        logging.info("tasklist_key is " + tasklist_key)
+        #for t in TaskList.all().filter('created_by =', users.get_current_user()):
+        #logging.debug("checking")
+        if task_key in tasklist.tasks:
+            logging.info("inside")
+            #tasklist = t
             t.tasks.remove(task_key)#remove the task key list
+            db.delete(task)#remove the task from DB
             return HttpResponseRedirect("/main/%s" % tasklist.key())
-    logging.debug("tasklist not found")
-    return HttpResponseRedirect("/main/%s" % "None")
+    logging.info("tasklist not valid")
+    logging.info("task key is ")
+    logging.info(task_key)
+    return HttpResponseRedirect("/main/%s" % tasklist_key)
 
 def logout(request):
     return HttpResponseRedirect(users.create_logout_url("/login"))

File taskhood/tasks/views.pyc

Binary file modified.

File taskhood/templates/tasks_tab.html

                             <input id="edit_submit_{{obj.key}}" type="hidden" src="/site_media/css/images/check/up.gif" onclick="document.getElementById('tasks_form').submit();" title="Accept Changes"/>
                             <input id="edit_image_{{obj.key}}" type="image" onclick="edit_items('{{obj.key}}', '{{obj.status}}');" src="/site_media/css/images/edit/up.gif" title="Edit Task"/>
                         </td><td>
-                        <form method="POST" action="/delete_task/{{obj.key}}/" id="delete_task">
+                        <form method="POST" action="/delete_task/{{obj.key}}/{{tasklist_key}}/" id="delete_task">
                             <input class="delete" type="image" onclick="document.getElementById('delete_task').submit();" src="/site_media/css/images/delete/up.gif" onmouseover="this.src='/site_media/css/images/delete/over.gif';" onmouseout="this.src='/site_media/css/images/delete/up.gif';" title="Delete Task"/>
                         </form>
                         </td></tr></table>