from __future__ import unicode_literals

from django.conf.urls import patterns, url

from mezzanine.conf import settings


urlpatterns = []

if "django.contrib.admin" in settings.INSTALLED_APPS:
    urlpatterns += patterns("django.contrib.auth.views",
        url("^password_reset/$", "password_reset", name="password_reset"),
        url("^password_reset/done/$", "password_reset_done",
            name="password_reset_done"),
        url("^reset/done/$", "password_reset_complete",
            name="password_reset_complete"),
    )
    try:
        from django.contrib.auth.views import password_reset_confirm_uidb36
    except ImportError:
        # Django < 1.6
        urlpatterns += patterns("django.contrib.auth.views",
            url("^reset/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$",
                "password_reset_confirm", name="password_reset_confirm"),
        )
    else:
        # Django >= 1.6: http://bit.ly/1dvcV4Z
        urlpatterns += patterns("django.contrib.auth.views",
            url("^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$",
                "password_reset_confirm", name="password_reset_confirm"),
            url("^reset/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$",
                password_reset_confirm_uidb36),
        )

urlpatterns += patterns("mezzanine.core.views",
    url("^edit/$", "edit", name="edit"),
    url("^search/$", "search", name="search"),
    url("^set_site/$", "set_site", name="set_site"),
    url("^set_device/(?P<device>.*)/$", "set_device", name="set_device"),
    url("^asset_proxy/$", "static_proxy", name="static_proxy"),
    url("^displayable_links.js$", "displayable_links_js",
        name="displayable_links_js"),
)

@@ -188,16 +188,231 @@
 D_APPS:%0A
+    from django import VERSION%0A    if VERSION %3C (1, 6):%0A        reset_pattern = %22%5Ereset/(?P%3Cuidb36%3E%5B-%5Cw%5D+)/(?P%3Ctoken%3E%5B-%5Cw%5D+)/$%22%0A    else:%0A        reset_pattern = %22%5Ereset/(?P%3Cuidb64%3E%5B0-9A-Za-z_%5C-%5D+)/(?P%3Ctoken%3E.+)/$%22%0A
     urlp
@@ -452,32 +452,32 @@
 ib.auth.views%22,%0A
-
         url(%22%5Epa
@@ -746,340 +746,55 @@
     
-)%0A
     
-try:%0A        from django.contrib.auth.views import password_reset_confirm_uidb36%0A    except ImportError:%0A        # Django %3C 1.6%0A        urlpatterns += patterns(%22django.contrib.auth.views%22,%0A            url(%22%5Ereset/(?P%3Cuidb36%3E%5B-%5Cw%5D+)/(?P%3Ctoken%3E%5B-%5Cw%5D+)/$%22,%0A                %22password_reset_confirm%22, name=%22password_reset_confirm%22)
+url(reset_pattern, %22password_reset_confirm%22
 ,%0A  
@@ -803,389 +803,44 @@
     
-)%0A
     
-else:%0A        # Django %3E= 1.6: http://bit.ly/1dvcV4Z%0A        urlpatterns += patterns(%22django.contrib.auth.views%22,%0A            url(%22%5Ereset/(?P%3Cuidb64%3E%5B0-9A-Za-z_%5C-%5D+)/(?P%3Ctoken%3E.+)/$%22,%0A                %22password_reset_confirm%22, name=%22password_reset_confirm%22),%0A            url(%22%5Ereset/(?P%3Cuidb36%3E%5B-%5Cw%5D+)/(?P%3Ctoken%3E%5B-%5Cw%5D+)/$%22,%0A                password_reset_confirm_uidb36),%0A    
+name=%22password_reset_confirm%22),%0A
     

Change handling of multiple versions of password reset urlpattern format to work with Django 1.7