Преглед на файлове

Added password reset functionality

* Using the Django views directly.
* Replacement templates are in templates/registration but they are
* largely copies of the content in Django's but with our layout.html
master
David Winterbottom преди 13 години
родител
ревизия
d1dfd98adf

+ 10
- 0
oscar/app.py Целия файл

@@ -1,4 +1,5 @@
1 1
 from django.conf.urls.defaults import patterns, url, include
2
+from django.contrib.auth import views as auth_views
2 3
 
3 4
 from oscar.core.application import Application
4 5
 from oscar.apps.catalogue.app import application as catalogue_app
@@ -29,6 +30,15 @@ class Shop(Application):
29 30
             (r'^accounts/', include(self.customer_app.urls)),
30 31
             (r'^search/', include(self.search_app.urls)),
31 32
             (r'^dashboard/', include(self.dashboard_app.urls)),
33
+
34
+            # Password reset - as we're using Django's default view funtions, we
35
+            # can't namespace these urls as that prevents the reverse function
36
+            # from working.
37
+            url(r'^password-reset/$', auth_views.password_reset, name='password-reset'),
38
+            url(r'^password-reset/done/$', auth_views.password_reset_done, name='password-reset-done'),
39
+            url(r'^password-reset/confirm/$', auth_views.password_reset_confirm, name='password-reset-confirm'),
40
+            url(r'^password-reset/complete/$', auth_views.password_reset_complete, name='password-reset-complete'),
41
+
32 42
             (r'', include(self.promotions_app.urls)),             
33 43
         )
34 44
         return urlpatterns

+ 4
- 0
oscar/apps/customer/app.py Целия файл

@@ -7,6 +7,7 @@ from oscar.apps.customer.views import AccountSummaryView, OrderHistoryView, \
7 7
     AccountAuthView, AnonymousOrderDetailView
8 8
 from oscar.core.application import Application
9 9
 
10
+
10 11
 class CustomerApplication(Application):
11 12
     name = 'customer'
12 13
     summary_view = AccountSummaryView
@@ -30,6 +31,9 @@ class CustomerApplication(Application):
30 31
         urlpatterns += patterns('',
31 32
             url(r'^$', login_required(self.summary_view.as_view()), name='summary'),
32 33
             url(r'^login/$', self.login_view.as_view(), name='login'),
34
+
35
+
36
+            # Profile
33 37
             url(r'^orders/$', login_required(self.order_history_view.as_view()), name='order-list'),
34 38
             url(r'^order-status/(?P<order_number>[\w-]*)/(?P<hash>\w+)/$', 
35 39
                 self.anon_order_detail_view.as_view(), name='anon-order'),

+ 2
- 2
oscar/templates/checkout/gateway.html Целия файл

@@ -27,12 +27,12 @@ Checkout gateway | {{ block.super }}
27 27
 			I have an account and my password is:</label>
28 28
 		{{ form.password }}
29 29
 		{{ form.password.errors }}
30
-		<a href="">Get a password reminder</a>
30
+		<a href="{% url password-reset %}">Get a password reminder</a>
31 31
 		<label><input type="radio" id="id_options_0" name="options" value="new" {% if not form.password.errors %}checked="checked"{% endif %} /> I don't want to create an account</label><br/>
32 32
 	</div>
33 33
 	<div>
34 34
 		<button type="submit" class="btn btn-large btn-primary">Continue</button>
35
-		Alternatively <a href="">create an account</a> before you checkout.
35
+		Alternatively <a href="{% url customer:login %}">create an account</a> before you checkout.
36 36
 	</div>
37 37
 </form>
38 38
 

+ 14
- 0
oscar/templates/registration/password_reset_complete.html Целия файл

@@ -0,0 +1,14 @@
1
+{% extends 'layout.html' %}
2
+{% load i18n %}
3
+
4
+{% block title %}{% trans 'Password reset complete' %} | {{ block.super }}{% endblock %}
5
+
6
+{% block content %}
7
+
8
+<h1>{% trans 'Password reset complete' %}</h1>
9
+
10
+<p>{% trans "Your password has been set.  You may go ahead and log in now." %}</p>
11
+
12
+<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>
13
+
14
+{% endblock %}

+ 30
- 0
oscar/templates/registration/password_reset_confirm.html Целия файл

@@ -0,0 +1,30 @@
1
+{% extends 'layout.html' %}
2
+{% load i18n %}
3
+
4
+{% block title %}{% trans 'Password reset confirm' %} | {{ block.super }}{% endblock %}
5
+
6
+{% block content %}
7
+
8
+{% if validlink %}
9
+
10
+<h1>{% trans 'Enter new password' %}</h1>
11
+
12
+<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
13
+
14
+<form action="" method="post">{% csrf_token %}
15
+{{ form.new_password1.errors }}
16
+<p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{ form.new_password1 }}</p>
17
+{{ form.new_password2.errors }}
18
+<p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{ form.new_password2 }}</p>
19
+<p><input type="submit" value="{% trans 'Change my password' %}" /></p>
20
+</form>
21
+
22
+{% else %}
23
+
24
+<h1>{% trans 'Password reset unsuccessful' %}</h1>
25
+
26
+<p>{% trans "The password reset link was invalid, possibly because it has already been used.  Please request a new password reset." %}</p>
27
+
28
+{% endif %}
29
+
30
+{% endblock %}

+ 11
- 0
oscar/templates/registration/password_reset_done.html Целия файл

@@ -0,0 +1,11 @@
1
+{% extends 'layout.html' %}
2
+{% load i18n %}
3
+
4
+{% block title %}{% trans 'Password reset successful' %} | {{ block.super }}{% endblock %}
5
+
6
+{% block content %}
7
+
8
+	<h1>{% trans 'Password reset successful' %}</h1>
9
+	<p>{% trans "We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly." %}</p>
10
+
11
+{% endblock %}

+ 14
- 0
oscar/templates/registration/password_reset_email.html Целия файл

@@ -0,0 +1,14 @@
1
+{% load i18n %}{% load url from future %}{% autoescape off %}
2
+{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
3
+
4
+{% trans "Please go to the following page and choose a new password:" %}
5
+{% block reset_link %}
6
+{{ protocol }}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %}
7
+{% endblock %}
8
+{% trans "Your username, in case you've forgotten:" %} {{ user.username }}
9
+
10
+{% trans "Thanks for using our site!" %}
11
+
12
+{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
13
+
14
+{% endautoescape %}

+ 17
- 0
oscar/templates/registration/password_reset_form.html Целия файл

@@ -0,0 +1,17 @@
1
+{% extends 'layout.html' %}
2
+{% load i18n %}
3
+
4
+{% block title %}{% trans 'Password reset' %} | {{ block.super }}{% endblock %}
5
+
6
+{% block content %}
7
+
8
+	<h1>{% trans "Password reset" %}</h1>
9
+
10
+	<p>{% trans "Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one." %}</p>
11
+
12
+	<form action="" method="post">{% csrf_token %}
13
+	{{ form.email.errors }}
14
+	<p><label for="id_email">{% trans 'E-mail address:' %}</label> {{ form.email }} <input type="submit" value="{% trans 'Reset my password' %}" /></p>
15
+	</form>
16
+
17
+{% endblock %}

+ 3
- 0
oscar/templates/registration/password_reset_subject.txt Целия файл

@@ -0,0 +1,3 @@
1
+{% load i18n %}{% autoescape off %}
2
+{% blocktrans %}Password reset on {{ site_name }}{% endblocktrans %}
3
+{% endautoescape %}

+ 1
- 1
sandbox/settings.py Целия файл

@@ -110,7 +110,7 @@ ROOT_URLCONF = 'urls'
110 110
 
111 111
 from oscar import OSCAR_PARENT_TEMPLATE_DIR
112 112
 TEMPLATE_DIRS = (
113
-    location('templates'),
113
+    os.path.join(OSCAR_PARENT_TEMPLATE_DIR, 'templates'),
114 114
     OSCAR_PARENT_TEMPLATE_DIR,
115 115
 )
116 116
 

Loading…
Отказ
Запис