Ejemplo n.º 1
0
 def handle_user_task_add(self, request):
     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 "title" not in request.args or "begin" not in request.args or "end" not in request.args or "status" not in request.args:
             return jsonify({"error": "internal error"})
         title = request.args["title"]
         begin = request.args["begin"]
         end = request.args["end"]
         status = request.args["status"]
         id = models.add_task(title, begin, end, status)
         models.link_task_usr(id,
                              models.get_usr_id(session["username"])[0][0])
         return jsonify({"result": "new task added"})
     except:
         return jsonify({"error": "internal error"})
Ejemplo 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"})
Ejemplo n.º 3
0
 def user_has_task(self, id, username):
     models = Models()
     usr_id = models.get_usr_id(username)[0][0]
     return models.usr_has_task(usr_id, id)