Ejemplo n.º 1
0
  def post(self):
    item = Item.get(Key.from_path('Item', long(self.request.get('item_id'))))
    if not helpers.checkPermissionAndRespond(self, item=item): return

    item.deleted = True
    item.put()
    for copy in item.item_set:
      helpers.pushNotification(item, "deleted the task", item.checklist.user, copy.checklist.user , False)

    helpers.createResponse(self, 'message_deleted.html')
Ejemplo n.º 2
0
 def post(self):
   checklist = Checklist.get(Key(self.request.get("key")))
   if helpers.checkPermissionAndRespond(self, cl=checklist):
     checklist.title = self.request.get('title')
     checklist.public = bool(self.request.get('public'))
     checklist.description = self.request.get('description')
     checklist.put()
   
     for copy in checklist.checklist_set:
       helpers.pushNotification(checklist, "edited the checklist", checklist.user, copy.user , True)
         
     self.redirect('/cl/' + str(checklist.key().id()))
Ejemplo n.º 3
0
 def post(self):
   cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
   if not helpers.checkPermissionAndRespond(self, cl=cl): return
     
   for item in cl.item_set:
     item.deleted = True
     item.put()
   cl.deleted = True
   cl.put()
     
   for copy in cl.checklist_set:
     helpers.pushNotification(cl, "deleted the checklist", cl.user, copy.user , True)
       
   helpers.createResponse(self, 'message_deleted.html')
Ejemplo n.º 4
0
  def post(self):
    cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id'))))
    if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False):
      return
    
    user = users.get_current_user()
    for checklist in Checklist.all().filter("user ==", user):
      if checklist.source.key() == cl.key():
        helpers.createResponse(self, 'message_already_subscribed.html', 
          {'old_checklist': cl, 'my_checklist': checklist})
        return
        
    new_cl = Checklist(
        title = cl.title,
        description = cl.description,
        user = user,
        progress = cl.progress,
        public = cl.public,
        source = cl,
        deleted = cl.deleted,
                         )
    new_cl.put()

    for item in cl.item_set:
      new_item = Item(
          title = item.title,
          description = item.description,
          progress = item.progress,
          progress_description = item.progress_description,
          difficulty = item.difficulty,
          original = item,
          checklist = new_cl,
          deleted = item.deleted,
                      )
      new_item.put()
    
    helpers.pushNotification(cl, "subscribed to your Checklist", user, cl.user, True)
    
    helpers.createResponse(self, 'message_subscribed.html')
Ejemplo n.º 5
0
  def post(self):
    item = Item.get(Key.from_path("Item", long(self.request.get("item_id"))))
    if helpers.checkPermissionAndRespond(self, item=item):
      item.title = self.request.get("title")
      item.description = self.request.get("description")
      item.difficulty = int(self.request.get("difficulty"))
    
      if item.original:
        if self.request.get('progress') != '' and \
          item.progress != int(self.request.get('progress')):
          item.progress = int(self.request.get('progress'))
          helpers.updateProgress(item.checklist, item.checklist.user)
          helpers.pushNotification(
              item, 
              "updated progress to " + str(item.progress) + " for item", 
              item.checklist.user, item.original.checklist.user, False)
        item.progress_description = self.request.get('progress_description')
      
      item.put()
    
      for copy in item.item_set:
        helpers.pushNotification(item, "edited the task", item.checklist.user, copy.checklist.user , False)

      self.redirect("/cl/" + str(item.checklist.key().id()) + "/" + str(item.key().id()))