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 sub in Subscription.all().filter("user ==", user).filter("deleted ==", False): if sub.source.key() == cl.key(): helpers.createResponse(self, 'message_already_subscribed.html', {'old_checklist': cl}) sub = Subscription( user=user, source=cl, deleted=False, ) sub.put() for item in cl.item_set: subItem = SubscribedItem( subscription=sub, original=item, finished=False, deleted=False, ) subItem.put() helpers.createResponse(self, 'message_subscribed.html')
def get(self, **args): cl = Checklist.get(Key.from_path("Checklist", long(args['id']))) if not cl or cl.deleted: helpers.createResponse(self, 'message_not_exist.html') return if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False): return item_q = cl.item_set.filter("deleted ==", False).order("creation_time") cursor = self.request.get('cursor') if cursor: item_q = item_q.with_cursor(cursor) items = item_q.fetch(20) user = users.get_current_user() subscribed = False for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False): if sub.source.key() == cl.key(): subscribed = True break helpers.createResponse(self, 'dashboard_subscribe.html', {'items': items, 'cl': cl, 'cursor_item': item_q.cursor(), 'subscribed': subscribed, }, )
def get(self): checklist = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id')))) if not helpers.checkPermissionAndRespond(self, cl=checklist): return if not self.addable(checklist): helpers.createResponse(self, 'message_can_not_create_item.html') return helpers.createResponse(self, 'create_item.html', {'checklist': checklist})
def get(self, **args): cl = Checklist.get(Key.from_path("Checklist", long(args['id']))) if not cl or cl.deleted: helpers.createResponse(self, 'message_not_exist.html') return if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False): return item_q = cl.item_set.filter("deleted ==", False).order("creation_time") cursor = self.request.get('cursor_item') if cursor: item_q = item_q.with_cursor(cursor) items = item_q.fetch(20) subs = [] for sub in cl.subscription_set: subs.append(sub) cursor_item = item_q.cursor() item_q = item_q.with_cursor(cursor_item) helpers.createResponse(self, 'dashboard_items.html', {'items': items, 'cl': cl, 'cursor_item': cursor_item, 'more_items': item_q.count(1) == 1, 'subs': subs, })
def post(self): cl = Checklist.get(Key(self.request.get('cl'))) if helpers.checkPermission(users.User(self.request.get('email')), cl=cl): difficulty_sum, weighted_progress = 0, 0 for item in cl.item_set: difficulty_sum += item.difficulty weighted_progress += item.difficulty*item.progress cl.progress = weighted_progress/difficulty_sum cl.put()
def post(self): cl = Checklist.get(Key((self.request.get('key')))) if not helpers.checkPermissionAndRespond(self, cl=cl): return for item in cl.item_set: item.deleted = True item.put() cl.deleted = True cl.put() self.response.write('ok')
def post(self): cl = Checklist.get(Key(self.request.get("cl_key"))) for sub in cl.subscription_set: total, finished = 0, 0 for subItem in sub.subscribeditem_set: total += 1 if subItem.finished: finished += 1 if sub.progress != finished * 100 / total: sub.progress = finished * 100 / total sub.put()
def post(self): checklist = Checklist.get(Key(self.request.get('cl_key'))) if not helpers.checkPermissionAndRespond(self, cl=checklist): return item = Item( title=self.request.get('title'), checklist=checklist, deleted=False) item.put() helpers.createResponse(self, 'new_item.html', {'item': item})
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()))
def post(self): checklist = Checklist.get(Key(self.request.get("cl_key"))) if not helpers.checkPermissionAndRespond(self, cl=checklist): return item = Item(title=self.request.get("title"), checklist=checklist, deleted=False) item.put() taskqueue.add(url="/taskqueue/updatesubscription", params={"key": item.key()}) taskqueue.add(url="/taskqueue/updateprogress", params={"cl_key": item.checklist.key()}) helpers.createResponse(self, "new_item.html", {"item": item})
def post(self): value = self.request.get("value") key, tmp, field = self.request.get("id").rpartition("_") checklist = Checklist.get(Key(key)) if helpers.checkPermissionAndRespond(self, cl=checklist): if field == 'title': checklist.title = value elif field == 'public': checklist.public = value.lower() not in ['no', 'false'] elif field == 'description': checklist.description = value checklist.put() self.response.write(value)
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')
def get(self): user = users.get_current_user() if user: query = self.request.query.split('&') cl_key, cursor = query[0], query[1] cl = Checklist.get(db.Key(cl_key)) query = cl.listitem_set.with_cursor(cursor) items = query.fetch(10) # self.response.out.write("<tr></tr>") template = jinja_environment.get_template('templates/more_items.html') template_values = { 'items': items, } self.response.out.write(template.render(template_values))
def post(self): checklist = Checklist.get(self.request.get('checklist')) if not helpers.checkPermissionAndRespond(self, cl=checklist): return if not self.addable(checklist): helpers.createResponse(self, 'message_can_not_create_item.html') return item = Item( title=self.request.get('title'), difficulty=int(self.request.get('difficulty')), progress=0, checklist=checklist, deleted=False) if self.request.get('description') != '': item.description=self.request.get('description') item.put() self.redirect("/cl/" + str(checklist.key().id()))
def get(self, **args): cl = Checklist.get(Key.from_path("Checklist", long(args['id']))) if not cl or cl.deleted: helpers.createResponse(self, 'message_not_exist.html') return if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False): return item_q = cl.item_set.filter("deleted ==", False).order("title") cursor = self.request.get('cursor') if cursor: item_q = item_q.with_cursor(cursor) items = item_q.fetch(7) helpers.createResponse(self, 'list_items.html', {'items': items, 'checklist': cl, 'item_cursor': item_q.cursor()})
def post(self): user = users.get_current_user() if user: checklist = Checklist.get(self.request.get('checklist_key')) listitem = ListItem( title=self.request.get('title'), assigner=user, assignees=[user], priority=int(self.request.get('priority')), finished=bool(self.request.get('finished')), checklist=checklist) if self.request.get('link') != '': listitem.link = self.request.get('link') if self.request.get('deadline') != '': # TODO: replace this with deadline listitem.deadline=datetime.now() if self.request.get('details') != '': listitem.details=self.request.get('detail') listitem.put() self.redirect('/')
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')
def post(self): cl = Checklist.get(Key.from_path('Checklist', long(self.request.get('cl_id')))) subscribe = self.request.get('subscribe') if not helpers.checkPermissionAndRespond(self, cl=cl, edit=False): return user = users.get_current_user() if subscribe == 'false': for sub in Subscription.all().filter("user ==", user).filter("deleted ==", False): if sub.source.key() == cl.key(): for subItem in sub.subscribeditem_set: subItem.delete() sub.delete() cl.subscribers = cl.subscribers - 1 self.response.write("unsubscribed") else: sub = Subscription( user=user, source=cl, deleted=False, ) sub.put() for item in cl.item_set.filter("deleted ==", False): subItem = SubscribedItem( subscription=sub, original=item, finished=False, deleted=False, ) subItem.put() cl.subscribers = cl.subscribers + 1 self.response.write("subscribed") cl.put()
def get(self): checklist = Checklist.get(Key.from_path("Checklist", long(self.request.get('cl_id')))); if helpers.checkPermissionAndRespond(self, cl=checklist): helpers.createResponse(self, 'edit_cl.html', {'checklist_to_change': checklist})