def edit(self, signature_id):
     sig = Signature.find_by_id(int(signature_id))
     if sig.card.is_authorized():
         sig.name = self.request.get('name')
         sig.save()
         template = JinjaEnv.get().get_template('templates/signature/edit_row.html')
         self.response.out.write(template.render({'signature': sig}))
 def add(self, card_id):
     card = ReportCard.find_by_id(int(card_id))
     if card.is_authorized():
         signature_id = Signature.create(self.request.get('name'), int(card_id)).id()
         signature = Signature.find_by_id(signature_id)
         template = JinjaEnv.get().get_template('templates/signature/edit_row.html')
         self.response.out.write(template.render({'signature': signature}))
 def move_up(self, signature_id):
     sig = Signature.find_by_id(int(signature_id))
     if sig.card.is_authorized():
         all_sigs = sig.card.signatures()
         id_list = map(lambda x: x.key().id(), all_sigs)
         index = id_list.index(sig.key().id())
         if index >= 1:
             temp = sig.position
             sig.position = all_sigs[index-1].position
             all_sigs[index-1].position = temp
             sig.save()
             all_sigs[index-1].save()
         else:
             return webapp2.abort(403)
 def delete(self, signature_id):
     sig = Signature.find_by_id(int(signature_id))
     if sig.card.is_authorized():
         card_id = sig.card.key().id()
         sig.delete()
 def delete_form(self, signature_id):
     sig = Signature.find_by_id(int(signature_id))
     if sig.card.is_authorized():
         template = JinjaEnv.get().get_template('templates/signature/delete_form.html')
         self.response.out.write(template.render({'signature_id': signature_id, 'signature': sig}))