Ejemplo n.º 1
0
    def delete(self, id):
        '''Deletar uma notícia'''
        session = Session()

        # look up given determined news
        determined_news = session.query(News).filter_by(id=id)

        # check if determined news exists
        if determined_news.scalar() is None:
            namespace.abort(404)

        # delete news from database
        news = determined_news.one()
        records = dictionarize(news)
        session.delete(news)
        session.commit()

        #respond request
        response = {
            "status": 200,
            "message": "Sucess",
            "error": False,
            "response": records
        }
        return jsonify(response)
Ejemplo n.º 2
0
    def delete(self, id):
        '''Deleta uma notificação'''
        session = Session()

        # look up given flag
        given_notification = session.query(Notification).filter_by(id=id)

        # check if given notification exists
        if given_notification.scalar() is None:
            namespace.abort(404)

        # delete notification entry from database
        notification = given_notification.one()
        records = dictionarize(notification)

        session.delete(notification)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": records
        }
        return jsonify(response)
Ejemplo n.º 3
0
    def delete(self, id):
        '''Deleta uma denúncia existente'''
        session = Session()

        # look up given report
        given_report = session.query(Report).filter_by(id=id)

        # check if given report exists
        if given_report.scalar() is None:
            namespace.abort(404)

        # delete report from database
        report = given_report.one()
        # delete the attachments of the report
        attachs = []
        for attach in report.attachments:
            attachs.append(dictionarize(attach))
            session.delete(attach)
        records = dictionarize(report)
        session.delete(report)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": {
                "report": records,
                "attachments": attachs
            }
        }
        return jsonify(response)
Ejemplo n.º 4
0
    def delete(self, id):
        '''Deleta uma flag'''
        session = Session()

        # look up given flag
        given_flag = session.query(Flag).filter_by(identifier=id)

        # check if given flag exists
        if given_flag.scalar() is None:
            namespace.abort(404)

        # delete flag entry from database
        flag = given_flag.one()
        records = dictionarize(flag)

        # generate a list of granted privileges
        privileges = []
        for privilege in flag.privileges:
            privileges.append(privilege.identifier)

        session.delete(flag)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": {
                "flag": records,
                "privileges": privileges
            }
        }
        return jsonify(response)
Ejemplo n.º 5
0
    def delete(self, id):
        '''Deleta um usuário existente'''
        session = Session()

        # look up given user
        given_user = session.query(User).filter_by(id=id)

        # check if given user exists
        if given_user.scalar() is None:
            namespace.abort(404)

        # delete user from database
        user = given_user.one()
        records = dictionarize(user)
        session.delete(user)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": records
        }
        return jsonify(response)
Ejemplo n.º 6
0
    def delete(self, id):
        '''Deleta um privilégio'''
        session = Session()

        # look up given privilege
        given_privilege = session.query(Privilege).filter_by(identifier=id)

        # check if given privilege exists
        if given_privilege.scalar() is None:
            namespace.abort(404)

        # delete privilege entry from database
        privilege = given_privilege.one()
        records = dictionarize(privilege)
        session.delete(privilege)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": records
        }
        return jsonify(response)
Ejemplo n.º 7
0
    def delete(self, id):
        '''Deleta uma resposta específica'''
        session = Session()

        given_reply = session.query(Reply).filter_by(id=id)

        if given_reply.scalar() is None:
            namespace.abort(404)

        # delete reply from database
        report = given_reply.one()
        records = dictionarize(report)
        session.delete(report)
        session.commit()

        # respond request
        response = {
            "status": 200,
            "message": "Success",
            "error": False,
            "response": records
        }
        return jsonify(response)