Esempio n. 1
0
    def post(self):
        #defining the payload
        data = api.payload

        title = data['title']
        description = data['description']
        agenda = AgendaModel(title = title, agenda = description)
        agenda.createRecord()

        return {"message" : "Record added successfully"}, 201
Esempio n. 2
0
    def get(cls, agenda_id: str = None):
        if not agenda_id:
            list = AgendaModel.fetch_all()
            return agendaListSchema.dump(list), 200
        agenda = AgendaModel.find_by_id(agenda_id)
        if not agenda:
            return {
                "message": "Agenda <id={}> not found.".format(agenda_id)
            }, 404

        return agendaSchema.dump(agenda), 200
Esempio n. 3
0
    def post(cls):
        task_json = request.get_json()

        task = task_schema.load(task_json)

        if not AgendaModel.find_by_id(task.agenda_id):
            return {"message": "The specified agenda <id={task.agenda_id}}> was not found."}, 400

        task.save()

        return task_schema.dump(task), 201
Esempio n. 4
0
    def post(self):
        try:

            data = api.payload

            title = data['title']
            agenda = data['agenda']

            agenda = AgendaModel(title=title, agenda=agenda)
            agenda.create_record()

            return {"status": "Agenda Added Successfully"}, 201
        except KeyError as e:
            api.abort(500,
                      e.__doc__,
                      status="Could not perform this action",
                      statusCode="500")
        except KeyError as e:
            api.abort(400,
                      e.__doc__,
                      status="Could not perform this action",
                      statusCode="400")
Esempio n. 5
0
 def delete(self, id):
     try:
         agenda = AgendaModel.delete_by_id(id)
         return {"status": "Agenda successfully deleted"}, 200
     except KeyError as e:
         api.abort(500,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="500")
     except KeyError as e:
         api.abort(400,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="400")
Esempio n. 6
0
 def get(self, id):
     try:
         agenda = AgendaModel.fetch_by_id(id)
         return agenda_schema.dump(agenda)
     except KeyError as e:
         api.abort(500,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="500")
     except KeyError as e:
         api.abort(400,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="400")
Esempio n. 7
0
 def get(self):
     try:
         agendas = AgendaModel.fetch_records()
         return agendas_schema.dump(agendas)
     except KeyError as e:
         api.abort(500,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="500")
     except KeyError as e:
         api.abort(400,
                   e.__doc__,
                   status="Could not perform this action",
                   statusCode="400")
Esempio n. 8
0
    def post(cls):
        agenda_json = request.get_json()
        agenda = agendaSchema.load(agenda_json)

        if not UserModel.find_by_id(agenda.user_id):
            return {
                "message":
                "The specified user <id={agenda.user_id}> was not found."
            }, 400

        if AgendaModel.find_by_title(agenda.title):
            return {"message": "This title is already been used."}, 400

        agenda.save()

        return agendaSchema.dump(agenda), 201
Esempio n. 9
0
    def put(self, id):
        try:
            data = api.payload

            title = agenda = None

            title = data['title']
            agenda = data['agenda']

            update_record = AgendaModel.update_by_id(id=id,
                                                     title=title,
                                                     agenda=agenda)
            return {'status': 'Agenda updated successfully'}, 200
        except KeyError as e:
            api.abort(500,
                      e.__doc__,
                      status="Could not perform this action",
                      statusCode="500")
        except KeyError as e:
            api.abort(400,
                      e.__doc__,
                      status="Could not perform this action",
                      statusCode="400")
Esempio n. 10
0
    def get(self, id):

        agenda = AgendaModel.fetch_agendas_by_id(id)
        return agenda_schema.dump(agenda)
Esempio n. 11
0
 def get(self):
     
     agenda = AgendaModel.fetchAgendas()
     return agendas_schema.dump(agenda), 200