Ejemplo n.º 1
0
    def put(self, task_id):
        task_id = int(task_id)
        json_data = json.loads(self.request.body)
        was_positive = json_data.get("goodJob")
        task_event = models.update_task_event_feedback(task_id, was_positive)

        if task_event:
            task = models.get_task(task_id)

            obj = jsons.get_task_json(task)

            update_json = {}
            update_json['eventType'] = 'taskFeedback'
            update_json['taskId'] = task_id
            update_json['positive'] = task_event.positive_feedback
            update_json['negative'] = task_event.negative_feedback
            member = models.get_member_key().get()
            update_json['doneBy'] = member.first_name + " " + member.last_name
            #if member.avatar:
                #update_json['avatar'] = member.avatar

            json_data = json.dumps(obj)
            update_data = json.dumps(update_json)
            publisher.update_clients(models.get_members_list(), update_data)
            self.response.out.write(json_data)
Ejemplo n.º 2
0
 def get(self, task_id=None):
     if task_id is None:
         tasks_list = models.get_household_tasks()
         task_list_json = jsons.get_all_tasks_json(tasks_list)
         json_data = json.dumps(task_list_json)
         self.response.out.write(json_data)
     else:
         task = models.get_task(int(task_id))
         task_json = jsons.get_task_json(task)
         json_data = json.dumps(task_json)
         self.response.out.write(json_data)
Ejemplo n.º 3
0
    def put(self):
        json_data = json.loads(self.request.body)
        task_id = json_data.get("taskID")
        task = models.edit_task(task_id, json_data)

        task_json = jsons.get_task_json(task)
        update_json = {}
        update_json['eventType'] = 'editTask'
        update_json['task'] = task_json
        json_data = json.dumps(task_json)
        update_data = json.dumps(update_json)
        publisher.update_clients(models.get_members_list(), update_data)
        self.response.out.write(json_data)
Ejemplo n.º 4
0
    def post(self):
        json_data = json.loads(self.request.body)
        task_name = json_data.get("name")
        frequency = int(json_data.get("frequency"))
        description = json_data.get("description")
        difficulty = int(json_data.get("difficulty"))
        style = json_data.get("iconClass")

        task = models.add_task(task_name, difficulty, description, frequency, style)
        task = task.get()

        delegator.delegate_task_loop(task)
        task_json = jsons.get_task_json(task)
        update_json = {}
        update_json['eventType'] = 'addTask'
        update_json['task'] = task_json
        json_data = json.dumps(task_json)
        update_data = json.dumps(update_json)
        publisher.update_clients(models.get_members_list(), update_data)
        self.response.out.write(json_data)
Ejemplo n.º 5
0
    def post(self, task_id):
        task_id = int(task_id)
        new_task_event = models.add_task_event(task_id).get()
        task = models.get_task(task_id)

        obj = jsons.get_task_json(task)

        update_json = {}
        update_json['eventType'] = 'taskEvent'
        update_json['taskId'] = task_id
        update_json[strings.assignedInitials] = task.get_delagated_initials()
        update_json[strings.completedByInitials] = new_task_event.completed_by.get().get_initials()

        member = models.get_member_key().get()
        update_json['doneBy'] = member.first_name + " " + member.last_name
        #if member.avatar:
            #update_json['avatar'] = member.avatar
        json_data = json.dumps(obj)
        update_data = json.dumps(update_json)
        publisher.update_clients(models.get_members_list(), update_data)
        self.response.out.write(json_data)