Skip to content

Commit

Permalink
Get complete admin URL
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Jul 30, 2024
1 parent 57e20f9 commit b4d1ed6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dds_registration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ class Meta:
]

def get_admin_url(self):
return reverse("admin:%s_%s_change" % (self._meta.app_label, self._meta.model_name), args=(self.id,))
return "https://{}{}".format(
Site.objects.get_current().domain,
reverse(
"admin:%s_%s_change" % (self._meta.app_label, self._meta.model_name),
args=(self.id,)
)
)

@property
def can_register(self):
Expand Down
10 changes: 10 additions & 0 deletions dds_registration/views/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ def event_registration(request: HttpRequest, event_code: str):
)
registration.save()

if settings.SLACK_REGISTRATIONS_WEBHOOK:
requests.post(
url=settings.SLACK_REGISTRATIONS_WEBHOOK,
json={
"text": "Registration by {} for {} ({})".format(
request.user.get_full_name(), event.title, event.get_admin_url()
)
}
)

if not registration.option.price:
messages.success(request, f"You have successfully registered for {event.title}.")
registration.complete_registration()
Expand Down

0 comments on commit b4d1ed6

Please sign in to comment.