Skip to content

Commit

Permalink
Merge pull request #281 from LleidaHack/integration
Browse files Browse the repository at this point in the history
Integration
  • Loading branch information
elver5041 authored Nov 4, 2024
2 parents 4882c6e + 0956342 commit bc93dc8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/impl/Event/router_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,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 bc93dc8

Please sign in to comment.