Exemplo n.º 1
0
 def handle_user_task_id_get(self, id):
     try:
         if "logged_in" not in session or session[
                 'logged_in'] != True or "username" not in session:
             return jsonify({"error": "you must be logged in"})
         models = Models()
         if not models.task_exist(id):
             return jsonify({"error": "task id does not exist"})
         if not self.user_has_task(id, session['username']):
             return jsonify({"error": "not your task lmao"})
         task = models.get_task_info(id)
         return jsonify({
             "result": {
                 "title": str(task[1]),
                 "begin": str(task[2]),
                 "end": str(task[3]),
                 "status": self.id_to_status(int(task[4]))
             }
         })
     except:
         return jsonify({"error": "internal error"})
Exemplo n.º 2
0
 def handle_user_task(self):
     try:
         if "logged_in" not in session or session[
                 'logged_in'] != True or "username" not in session:
             return jsonify({"error": "you must be logged in"})
         models = Models()
         tasks_id = []
         tasks = []
         for i in models.get_user_tasks(
                 models.get_usr_id(session["username"])[0][0]):
             tasks_id.append(i[1])
         for i in tasks_id:
             tmp = models.get_task_info(i)
             tasks.append({
                 str(i): {
                     "title": str(tmp[1]),
                     "begin": str(tmp[2]),
                     "end": str(tmp[3]),
                     "status": self.id_to_status(int(tmp[4]))
                 }
             })
         return jsonify({"result": {"tasks": tasks}})
     except:
         return jsonify({"error": "internal error"})