Пример #1
0
    def post(self):
        if request.headers['Content-Type'] in ["application/xml", 'text/xml']:
            current_app.logger.info("post message")
            xml = request.data.decode("utf-8")

            echange = EchangeSchema().load({
                'payload': xml
            })
            _ = EchangeService.add_echange(echange, uow=current_app.context)
            try:
                affair = AffairService.add_affair_from_xml(xml, uow=current_app.context)
                event_bus.publish(AffairCreatedEvent(data=affair))
                current_app.logger.info("Successfully create affairs")
                return {
                           "message": "success affair"
                       }, 200
            except Exception as e:
                current_app.logger.info(f"Failed to create affairs {e}")
                return {
                           "message": "success"
                       }, 200

        return {
                   "message": "error",
                   "contentType": request.headers['Content-Type']
               }, 200
Пример #2
0
 def post(self):
     if request.headers['Content-Type'] in ["application/xml", 'text/xml']:
         current_app.logger.info("post message")
         xml = request.data.decode("utf-8")
         affair = AffairService.add_affair_from_xml(xml, uow=current_app.context)
         event_bus.publish(AffairCreatedEvent(data=affair))
         return {
                "message": "success"
            }, 200
     return {
         "message": "error",
         "contentType": request.headers['Content-Type']
     }, 200
Пример #3
0
 def post(self):
     body = request.get_json()
     body["creator_id"] = g.user_info["id"]
     create_command = CreateResource(data=body)
     result = event_bus.publish(create_command, current_app.context)
     return {"message": "success",
             "data": result[0]}, 201
Пример #4
0
 def invite_user(uuid: str, user_id: str, role_type: EvenementRoleType, uow: AbstractUnitOfWork) -> Dict[str, Any]:
     with uow:
         evenement: EvenementEntity = uow.evenement.get_by_uuid(uuid=uuid)
         user: UserEntity = uow.user.get_by_uuid(uuid=user_id)
         user_event_role: UserEvenementRole = UserEvenementRole(
             uuid=str(uuid4()),
             user_id=user.uuid,
             evenement_id=evenement.uuid,
             type=role_type
         )
         user_event_role.user = user
         evenement.add_user_role(user_role=user_event_role)
         event_bus.publish(UserEventInvitationCreated(data={
             "email": user.email,
             "evenement_id": evenement.uuid,
             "evenement_title": evenement.title
         }))
         return UserSchema().dump(uow.user.get_by_uuid(uuid=user_id))
Пример #5
0
 def add_meeting(data: Dict[str, Any],
                 uow: AbstractUnitOfWork) -> Dict[str, Any]:
     meeting: MeetingEntity = MeetingService.schema().load(data)
     with uow:
         try:
             evenement: EvenementEntity = uow.evenement.get_by_uuid(
                 meeting.evenement_id)
             meeting.evenement_id = evenement.uuid
             meeting.creator_id = data["creator_id"]
             uow.meeting.add(meeting)
             user: UserEntity = uow.user.get_by_uuid(
                 uuid=data["creator_id"])
             meeting.set_creator(creator=user)
             uow.commit()
             return MeetingService.schema().dump(
                 uow.meeting.get_by_uuid(meeting.uuid))
         finally:
             event_bus.publish(MeetingCreatedEvent(data=meeting), uow=uow)
 def post(self):
     current_app.logger.info(f"Start after post")
     body = request.get_json()
     current_app.logger.info(f"body {body}")
     body["creator_id"] = g.user_info["id"]
     command = CreateMessage(data=body)
     result = event_bus.publish(command, current_app.context)
     current_app.logger.info("test")
     return {"message": "success", "data": result[0]}, 201
Пример #7
0
 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
Пример #8
0
 def post(self):
     body = request.get_json()
     body["uuid"] = g.user_info["id"]
     current_app.logger.info("start creating user")
     command = CreateUser(data=body)
     result = event_bus.publish(command, current_app.context)
     return {
                "message": "success",
                "data": result[0]
            }, 201
Пример #9
0
    def post(self):
        body = request.get_json()

        parser = reqparse.RequestParser()
        parser.add_argument('token', type=str, required=False)
        args = parser.parse_args()
        body["uuid"] = g.user_info["id"]
        body["email"] = g.user_info["email"]
        body["token"] = args.get("token")
        command = CreateUser(data=body)
        result = event_bus.publish(command, current_app.context)
        return {"message": "success", "data": result[0]}, 201