def delete(self, category_id): category = EvalCategory.find_by_id(int(category_id)) card = category.card if card.is_authorized(): category = EvalCategory.find_by_id(int(category_id)) card_id = category.card.key().id() category.delete()
def add(self, card_id): card = ReportCard.find_by_id(int(card_id)) if card.is_authorized(): category_id = EvalCategory.create(self.request.get('name'), int(card_id)).id() category = EvalCategory.find_by_id(category_id) template = JinjaEnv.get().get_template('templates/category/edit_table.html') self.response.out.write(template.render({'category': category}))
def add(self, category_id): category = EvalCategory.find_by_id(int(category_id)) if category.card.is_authorized(): item_id = EvalItem.create(self.request.get('name'), int(category_id)).id() item = EvalItem.find_by_id(item_id) template = JinjaEnv.get().get_template('templates/item/edit_row.html') self.response.out.write(template.render({'item': item}))
def edit(self, category_id): category = EvalCategory.find_by_id(int(category_id)) card = category.card if card.is_authorized(): category.name = self.request.get('name') category.save() template = JinjaEnv.get().get_template('templates/category/edit_table.html') self.response.out.write(template.render({'category': category}))
def create(self, name, category_id): item = EvalItem(parent=self.report_key()) item.name = name category = EvalCategory.find_by_id(category_id) item.category = category if len(category.items()) > 0: item.position = category.items()[-1].position+1 return item.put()
def move_up(self, category_id): category = EvalCategory.find_by_id(int(category_id)) card = category.card if card.is_authorized(): all_categories = category.card.categories() id_list = map(lambda x: x.key().id(), all_categories) index = id_list.index(category.key().id()) if index >= 1: temp = category.position category.position = all_categories[index-1].position all_categories[index-1].position = temp category.save() all_categories[index-1].save() else: return webapp2.abort(403)
def delete_form(self, category_id): category = EvalCategory.find_by_id(int(category_id)) card = category.card if card.is_authorized(): template = JinjaEnv.get().get_template('templates/category/delete_form.html') self.response.out.write(template.render({'category_id': category_id, 'category': category}))
def add_form(self, category_id): category = EvalCategory.find_by_id(int(category_id)) if category.card.is_authorized(): template = JinjaEnv.get().get_template('templates/item/add_form.html') self.response.out.write(template.render({'category_id': category_id}))