160 lines
5.3 KiB
Python
160 lines
5.3 KiB
Python
from django.conf import settings
|
|
from django.urls import reverse_lazy, path, re_path
|
|
from django.contrib.auth import views as auth_views
|
|
|
|
from . import forms
|
|
from .views import normal_pages, registration_email, json_api, developer_applications
|
|
|
|
app_name = "bid_main"
|
|
urlpatterns = [
|
|
re_path(r"^$", normal_pages.IndexView.as_view(), name="index"),
|
|
re_path(r"^settings/profile$", normal_pages.ProfileView.as_view(), name="profile"),
|
|
re_path(r"^login$", normal_pages.LoginView.as_view(), name="login"),
|
|
re_path(
|
|
r"^logout$",
|
|
normal_pages.LogoutView.as_view(next_page="bid_main:index"),
|
|
name="logout",
|
|
),
|
|
re_path(r"^switch/?$", normal_pages.SwitchUserView.as_view(), name="switch_user"),
|
|
re_path(
|
|
r"^switch/(?P<switch_to>.+)$",
|
|
normal_pages.SwitchUserView.as_view(),
|
|
name="switch_user",
|
|
),
|
|
re_path(r"^delete-my-account$", normal_pages.DeleteUserView.as_view(), name="delete_user"),
|
|
re_path(
|
|
r"^applications",
|
|
normal_pages.ApplicationTokenView.as_view(),
|
|
name="auth_tokens",
|
|
),
|
|
path(
|
|
"developer/applications",
|
|
developer_applications.ListApplicationsView.as_view(),
|
|
name="developer_applications",
|
|
),
|
|
path(
|
|
"developer/applications/<int:pk>/edit",
|
|
developer_applications.EditApplicationView.as_view(),
|
|
name="developer_application_edit",
|
|
),
|
|
re_path(
|
|
r"^privacy-policy/agree$",
|
|
normal_pages.PrivacyPolicyAgreeView.as_view(),
|
|
name="privacy_policy_agree",
|
|
),
|
|
re_path(
|
|
r"^badge-toggle-private",
|
|
json_api.BadgeTogglePrivateView.as_view(),
|
|
name="badge_toggle_private",
|
|
),
|
|
re_path(
|
|
"^change$",
|
|
auth_views.PasswordChangeView.as_view(
|
|
form_class=forms.PasswordChangeForm,
|
|
success_url=reverse_lazy("bid_main:password_change_done"),
|
|
),
|
|
name="password_change",
|
|
),
|
|
re_path(
|
|
"^change-password/done$",
|
|
auth_views.PasswordChangeDoneView.as_view(),
|
|
name="password_change_done",
|
|
),
|
|
re_path(
|
|
r"^password_reset/$",
|
|
auth_views.PasswordResetView.as_view(
|
|
form_class=forms.PasswordResetForm,
|
|
success_url=reverse_lazy("bid_main:password_reset_done"),
|
|
),
|
|
name="password_reset",
|
|
),
|
|
re_path(
|
|
r"^password_reset/done/$",
|
|
auth_views.PasswordResetDoneView.as_view(),
|
|
name="password_reset_done",
|
|
),
|
|
re_path(
|
|
r"^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,33})/$",
|
|
auth_views.PasswordResetConfirmView.as_view(
|
|
form_class=forms.SetPasswordForm,
|
|
success_url=reverse_lazy("bid_main:password_reset_complete"),
|
|
),
|
|
name="password_reset_confirm",
|
|
),
|
|
re_path(
|
|
r"^password_reset/complete/$",
|
|
auth_views.PasswordResetCompleteView.as_view(),
|
|
name="password_reset_complete",
|
|
),
|
|
# Source of registration machinery:
|
|
# http://musings.tinbrain.net/blog/2014/sep/21/registration-django-easy-way/
|
|
re_path(r"^register/$", normal_pages.RegistrationView.as_view(), name="register"),
|
|
re_path(
|
|
r"^register/signed-up/$",
|
|
auth_views.PasswordResetDoneView.as_view(
|
|
template_name="registration/initial_signed_up.html"
|
|
),
|
|
name="register-done",
|
|
),
|
|
re_path(
|
|
r"^register/password/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,33})/$", # noqa: E501
|
|
registration_email.InitialSetPasswordView.as_view(),
|
|
name="register-confirm",
|
|
),
|
|
re_path(
|
|
r"^register/complete/$",
|
|
auth_views.PasswordResetCompleteView.as_view(
|
|
template_name="registration/registration_complete.html"
|
|
),
|
|
name="register-complete",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/start$",
|
|
registration_email.ConfirmEmailView.as_view(),
|
|
name="confirm-email",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/start-change$",
|
|
registration_email.ConfirmEmailView.as_view(
|
|
template_name="bid_main/confirm_email/change.html"
|
|
),
|
|
name="confirm-email-change",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/cancel-change$",
|
|
registration_email.CancelEmailChangeView.as_view(),
|
|
name="cancel-email-change",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/sent$",
|
|
registration_email.ConfirmEmailSentView.as_view(),
|
|
name="confirm-email-sent",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/verified/(?P<info>[^/]+)/(?P<hmac>[^/]+)$",
|
|
registration_email.ConfirmEmailVerifiedView.as_view(),
|
|
name="confirm-email-verified",
|
|
),
|
|
re_path(
|
|
r"^confirm-email/poll$",
|
|
registration_email.ConfirmEmailPollView.as_view(),
|
|
name="confirm-email-poll",
|
|
),
|
|
path('active-sessions/', normal_pages.ActiveSessionsView.as_view(), name='active_sessions'),
|
|
path(
|
|
'terminate-session/<int:pk>/',
|
|
normal_pages.TerminateSessionView.as_view(),
|
|
name='terminate_session',
|
|
),
|
|
]
|
|
|
|
# Only enable this on a dev server:
|
|
if settings.DEBUG:
|
|
from .views import testviews
|
|
|
|
urlpatterns += [
|
|
re_path(r"^debug/email-changed$", testviews.test_mail_email_changed),
|
|
re_path(r"^debug/email-verify$", testviews.test_mail_verify_address),
|
|
re_path(r"^error/(?P<code>\d+)$", testviews.test_error),
|
|
]
|