Example #1
0
    def put(self, uuid: str, user_uuid: str):
        AuthorizationService.as_access_to_this_evenement_resource(
            g.user_info["id"],
            evenement_id=uuid,
            role_type=EvenementRoleType.ADMIN,
            uow=current_app.context)
        parser = reqparse.RequestParser()
        parser.add_argument('role_type',
                            type=str,
                            required=False,
                            choices=([e.value for e in EvenementRoleType]))

        args = parser.parse_args()
        role_type: EvenementRoleType = args.get("role_type")
        if role_type:
            result = EvenementService.change_user_role(uuid=uuid,
                                                       user_id=user_uuid,
                                                       role_type=role_type,
                                                       uow=current_app.context)
        else:
            result = EvenementService.invite_user(
                uuid=uuid,
                user_id=user_uuid,
                role_type=EvenementRoleType.VIEW,
                uow=current_app.context)
        return {
            "message": "success",
            "data": result,
        }, 201
Example #2
0
    def get(self, uuid: str):
        AuthorizationService.as_access_to_this_evenement_resource(
            g.user_info["id"],
            evenement_id=uuid,
            role_type=EvenementRoleType.VIEW,
            uow=current_app.context)
        parser = reqparse.RequestParser()
        parser.add_argument('format', type=str, required=True)

        args = parser.parse_args()
        format_: str = args.get("format")

        df = EvenementService.create_dataframe(uuid, current_app.context)
        with NamedTemporaryFile(suffix=f".{format_}") as f:
            if format_ == "csv":
                df.to_csv(f.name, index=False)
            if format_ == "xlsx":
                df.to_excel(f.name, sheet_name='export')

            if format_ == "json":
                df.to_json(f.name)
            if format_ == "html":
                df.to_html(f.name)

            return send_file(
                f.name,
                f"export_evenement_{uuid}_{datetime.now()}.{format_}",
                as_attachment=True)
Example #3
0
 def delete(self, uuid: str, user_uuid: str):
     AuthorizationService.as_access_to_this_evenement_resource(
         g.user_info["id"],
         evenement_id=uuid,
         role_type=EvenementRoleType.ADMIN,
         uow=current_app.context)
     result = EvenementService.revoke_access(uuid=uuid,
                                             user_id=user_uuid,
                                             uow=current_app.context)
     return {
         "message": "success",
         "data": result,
     }, 202
Example #4
0
 def get(self, uuid: str, message_uuid: str):
     AuthorizationService.as_access_to_this_evenement_resource(
         g.user_info["id"],
         evenement_id=uuid,
         role_type=EvenementRoleType.VIEW,
         uow=current_app.context)
     return {
         "data":
         EvenementService.get_message_by_uuid(uuid=uuid,
                                              message_uuid=message_uuid,
                                              uow=current_app.context),
         "message":
         "success"
     }, 200
Example #5
0
    def get(self, uuid: str):
        parser = reqparse.RequestParser()
        parser.add_argument('tags', type=str, help='Tags ids', action='append')
        args = parser.parse_args()
        tags: Union[str, List[str], None] = args.get("tags")
        creator_id = g.user_info["id"]
        AuthorizationService.as_access_to_this_evenement_resource(
            creator_id,
            evenement_id=uuid,
            role_type=EvenementRoleType.VIEW,
            uow=current_app.context)

        messages = EvenementService.list_messages_by_query(
            uuid=uuid,
            tag_ids=tags,
            creator_id=creator_id,
            uow=current_app.context)

        return {"data": messages, "message": "success"}, 200
Example #6
0
from domain.evenements.services.evenement_service import EvenementService
from flask import current_app

uow = current_app.context
event_uuid = "29ef5913-258c-4fb9-94d7-4ef94aa081f2"
EvenementService.create_list_of_dict_entries(uuid=event_uuid, uow=uow)
Example #7
0
def create_evenement(command: CreateEvenement, uow: AbstractUnitOfWork):
    return EvenementService.add_evenement(data=command.data, uow=uow)