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)
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) MessageService.get_reactions(message_id=message_uuid, uow=current_app.context)
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
def post(self, uuid: str): AuthorizationService.as_access_to_this_evenement_resource( g.user_info["id"], evenement_id=uuid, role_type=EvenementRoleType.EDIT, uow=current_app.context) body = {"creator_id": g.user_info["id"], "evenement_id": uuid} command = CreateMeeting(data=body) result = event_bus.publish(command, current_app.context) return {"message": "success", "data": result[0]}, 201
def get(self, uuid: str, meeting_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": MeetingService.get_by_uuid(meeting_uuid, current_app.context), "message": "success" }, 200
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
def get(self, uuid: str, meeting_uuid: str): AuthorizationService.as_access_to_this_evenement_resource( g.user_info["id"], evenement_id=uuid, role_type=EvenementRoleType.VIEW, uow=current_app.context) redirect_url = MeetingService.join_meeting(meeting_uuid, user_uuid=g.user_info["id"], uow=current_app.context) return { "data": { "direct_uri": redirect_url }, "message": "success" }, 200
def post(self, uuid: str, message_uuid: str): AuthorizationService.as_access_to_this_evenement_resource(g.user_info["id"], evenement_id=uuid, role_type=EvenementRoleType.EDIT, uow=current_app.context) body = request.get_json() reaction_type = ReactionType[body.get("reaction")] creator_id = g.user_info["id"] MessageService.add_reaction(creator_id=creator_id, message_id=message_uuid, reaction_type=reaction_type, uow=current_app.context) return { "message": "success", "data": "ok" }, 201
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