Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical fix: make admin non-GET requests work #803

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading