Skip to content

Commit

Permalink
Merge branch 'integration' into hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tonlls authored Nov 4, 2024
2 parents b346eba + ca51204 commit 4eea45b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/impl/Event/router_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ def confirm_assistance(token: AssistenceToken = Depends(JWTBearer())):
"""
event_service.confirm_assistance(token)
#redirect to Configuration.get('OTHERS', 'FRONT_URL')
return Response(status_code=303,
headers={"Location": Configuration.front_url})
return {"success": True}


@router.get("/force-confirm-assistance/{event_id}/{user_id}")
Expand Down Expand Up @@ -355,6 +354,12 @@ def get_pending_hackers_gruped(event_id: int,
return event_service.get_pending_hackers_gruped(event_id, token)


@router.get("/{event_id}/resend-accepted-mails")
def resend_accept_mails(event_id: int,
token: BaseToken = Depends(JWTBearer())):
return event_service.resend_mails(event_id, token)


# @router.post("/{event_id}/send_remember")
# def send_remember(
# event_id: int,
Expand Down
26 changes: 26 additions & 0 deletions src/impl/Event/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,3 +685,29 @@ def accept_group(self, event_id: int, group_id: int, data: BaseToken):
raise InvalidDataException("Hacker not registered")
hacker_user = self.hacker_service.get_by_id(hacker.id)
self.accept_hacker(event.id, hacker_user.id, data)

@BaseService.needs_service(MailClient)
def resend_mails(self, event_id: int, data: BaseToken):
if not data.check([UserType.LLEIDAHACKER]):
raise AuthenticationException("Not authorized")
event = self.get_by_id(event_id)
if event.archived:
raise InvalidDataException(
"Unable to operate with an archived event, unarchive it first")
for hacker in event.accepted_hackers:
hacker_registration = db.session.query(HackerRegistration).filter(
HackerRegistration.user_id == hacker.id,
HackerRegistration.event_id == event.id).first()
token = AssistenceToken(hacker, event.id).to_token()
hacker_registration.confirm_assistance_token = token

mail = self.mail_client.create_mail(
MailCreate(
template_id=self.mail_client.get_internall_template_id(
InternalTemplate.EVENT_HACKER_ACCEPTED),
subject='You have been accepted',
receiver_id=str(hacker.id),
receiver_mail=str(hacker.email),
fields=f'{hacker.name},{event.name},5,{token}'))

db.session.commit()

0 comments on commit 4eea45b

Please sign in to comment.