urls.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from __future__ import unicode_literals
  2. from django.conf.urls import url
  3. from mezzanine.accounts import views
  4. from mezzanine.conf import settings
  5. ACCOUNT_URL = getattr(settings, "ACCOUNT_URL", "/accounts/")
  6. SIGNUP_URL = getattr(settings, "SIGNUP_URL",
  7. "/%s/signup/" % ACCOUNT_URL.strip("/"))
  8. SIGNUP_VERIFY_URL = getattr(settings, "SIGNUP_VERIFY_URL",
  9. "/%s/verify/" % ACCOUNT_URL.strip("/"))
  10. LOGIN_URL = settings.LOGIN_URL
  11. LOGOUT_URL = getattr(settings, "LOGOUT_URL", "/accounts/logout/")
  12. PROFILE_URL = getattr(settings, "PROFILE_URL", "/users/")
  13. PROFILE_UPDATE_URL = getattr(settings, "PROFILE_UPDATE_URL",
  14. "/%s/update/" % ACCOUNT_URL.strip("/"))
  15. PASSWORD_RESET_URL = getattr(settings, "PASSWORD_RESET_URL",
  16. "/%s/password/reset/" % ACCOUNT_URL.strip("/"))
  17. PASSWORD_RESET_VERIFY_URL = getattr(settings, "PASSWORD_RESET_VERIFY_URL",
  18. "/%s/password/verify/" %
  19. ACCOUNT_URL.strip("/"))
  20. _verify_pattern = "/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)"
  21. _slash = "/" if settings.APPEND_SLASH else ""
  22. urlpatterns = [
  23. url("^%s%s$" % (LOGIN_URL.strip("/"), _slash),
  24. views.login, name="login"),
  25. url("^%s%s$" % (LOGOUT_URL.strip("/"), _slash),
  26. views.logout, name="logout"),
  27. url("^%s%s$" % (SIGNUP_URL.strip("/"), _slash),
  28. views.signup, name="signup"),
  29. url("^%s%s%s$" % (SIGNUP_VERIFY_URL.strip("/"), _verify_pattern, _slash),
  30. views.signup_verify, name="signup_verify"),
  31. url("^%s%s$" % (PROFILE_UPDATE_URL.strip("/"), _slash),
  32. views.profile_update, name="profile_update"),
  33. url("^%s%s$" % (PASSWORD_RESET_URL.strip("/"), _slash),
  34. views.password_reset, name="mezzanine_password_reset"),
  35. url("^%s%s%s$" %
  36. (PASSWORD_RESET_VERIFY_URL.strip("/"), _verify_pattern, _slash),
  37. views.password_reset_verify, name="password_reset_verify"),
  38. url("^%s%s$" % (ACCOUNT_URL.strip("/"), _slash),
  39. views.account_redirect, name="account_redirect"),
  40. ]
  41. if settings.ACCOUNTS_PROFILE_VIEWS_ENABLED:
  42. urlpatterns += [
  43. url("^%s%s$" % (PROFILE_URL.strip("/"), _slash),
  44. views.profile_redirect, name="profile_redirect"),
  45. url("^%s/(?P<username>.*)%s$" % (PROFILE_URL.strip("/"), _slash),
  46. views.profile, name="profile"),
  47. ]