Skip to content

Commit

Permalink
make admin non-GET requests work
Browse files Browse the repository at this point in the history
  • Loading branch information
ludvigalden committed Feb 27, 2024
1 parent a2d25f6 commit 2033a33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/admin/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from django.conf import settings
from django_hosts.resolvers import reverse_host
from django.http import HttpResponseRedirect
from django.http import HttpResponseRedirect, HttpResponseNotAllowed


def redirect_admin(request, path):
if request.method != 'GET':
return HttpResponseNotAllowed(['GET'])
elif request.headers.get('Accept') == 'application/json':
return HttpResponseNotAllowed(['GET'])

protocol = 'https' if request.is_secure() else 'http'
host = reverse_host(host='admin')
if getattr(settings, 'HOST_PORT', None):
Expand Down
8 changes: 4 additions & 4 deletions src/events/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
name="my-ticket"
),
re_path(
r'^admin/events/event/assign/(\d+)/$',
r'^events/event/assign/(\d+)/$',
views.admin_assign,
name='events_event_modeladmin_assign_tickets'
),
re_path(
r'^admin/events/event/unassign_unpaid/(\d+)/$',
r'^events/event/unassign_unpaid/(\d+)/$',
views.admin_unassign_unpaid,
name='events_event_modeladmin_unassign_unpaid_tickets'
),
re_path(
r'^admin/events/event/remove_applications/(\d+)/$',
r'^events/event/remove_applications/(\d+)/$',
views.admin_remove_applications,
name='events_event_modeladmin_remove_applications'
),
re_path(
r'^admin/events/event/export_participants/(\d+)/$',
r'^events/event/export_participants/(\d+)/$',
views.admin_export_participants,
name='events_event_modeladmin_export_participants'
),
Expand Down
6 changes: 3 additions & 3 deletions src/involvement/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

urlpatterns = [
re_path(
r'^admin/involvement/position/elect/(\d+)/$',
r'^involvement/position/elect/(\d+)/$',
views.admin_approve_applicants,
name='involvement_position_modeladmin_approve'
),
re_path(
r'^admin/involvement/position/appoint/(\d+)/$',
r'^involvement/position/appoint/(\d+)/$',
views.admin_appoint,
name='involvement_position_modeladmin_appoint'
),
re_path(
r'^admin/involvement/position/extend/(\d+)/$',
r'^involvement/position/extend/(\d+)/$',
views.admin_extend_deadline,
name='involvement_position_extend'
),
Expand Down

0 comments on commit 2033a33

Please sign in to comment.