Skip to content

Commit a6ea2a7

Browse files
author
Guillim
committed
coding style fixes
1 parent b68f115 commit a6ea2a7

File tree

11 files changed

+61
-49
lines changed

11 files changed

+61
-49
lines changed

app/authentification/forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.contrib.auth.forms import UserCreationForm
33
from django.contrib.auth.models import User
44

5+
56
class SignupForm(UserCreationForm):
67
email = forms.EmailField(max_length=200, help_text='Required')
78

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'base.html' %}
22

33
{% block content %}
4-
<div class="hero-body">
5-
<div class="container">
6-
<div class="card is-shady column is-4 is-offset-4">
7-
{% block content_auth %}{% endblock %}
8-
</div>
4+
<div class="hero-body">
5+
<div class="container">
6+
<div class="card is-shady column is-4 is-offset-4">
7+
{% block content_auth %}{% endblock %}
98
</div>
109
</div>
10+
</div>
1111
{% endblock %}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{% extends "base_auth.html" %}
22

33
{% block content_auth %}
4-
{% if validlink %}
5-
<div class="card-content">
6-
<div style="text-align:center;font-size:1.5em">
7-
<h2>Change password</h2>
8-
</div>
9-
10-
<form method="post">
11-
{% csrf_token %}
12-
{{ form.as_p }}
13-
<div style="text-align:center">
14-
<button type="submit" class="button is-link">Change password</button>
15-
</div>
16-
</form>
17-
4+
{% if validlink %}
5+
<div class="card-content">
6+
<div style="text-align:center;font-size:1.5em">
7+
<h2>Change password</h2>
188
</div>
19-
{% else %}
20-
<div class="card-content">
21-
The password reset link was invalid, possibly because it has already been used.
22-
Please request a new password reset.
9+
10+
<form method="post">
11+
{% csrf_token %}
12+
{{ form.as_p }}
13+
<div style="text-align:center">
14+
<button type="submit" class="button is-link">Change password</button>
2315
</div>
24-
{% endif %}
16+
</form>
17+
18+
</div>
19+
{% else %}
20+
<div class="card-content">
21+
The password reset link was invalid, possibly because it has already been used.
22+
Please request a new password reset.
23+
</div>
24+
{% endif %}
2525
{% endblock %}

app/authentification/templates/password_reset_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2>Forgot password</h2>
1111
{% csrf_token %}
1212
{{ form.as_p }}
1313
<div style="text-align:center">
14-
<button type="submit" class="button is-link">Submit</button>
14+
<button type="submit" class="button is-link">Submit</button>
1515
</div>
1616
</form>
1717

app/authentification/templates/signup.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ <h2>Sign up</h2>
99
</div> -->
1010
<form method="post">
1111
{% csrf_token %}
12-
{% for field in form %}
13-
<div class="field">
14-
<label class="label">{{ field.label_tag }}</label>
15-
<div class="control">
16-
{{ field|addcss:'input' }}
17-
{% if field.help_text %}
18-
<small style="display: none">{{ field.help_text }}</small>
19-
{% endif %}
20-
{% for error in field.errors %}
21-
<p style="color: red">{{ error }}</p>
22-
{% endfor %}
23-
</div>
12+
{% for field in form %}
13+
<div class="field">
14+
<label class="label">{{ field.label_tag }}</label>
15+
<div class="control">
16+
{{ field|addcss:'input' }}
17+
{% if field.help_text %}
18+
<small style="display: none">{{ field.help_text }}</small>
19+
{% endif %}
20+
{% for error in field.errors %}
21+
<p style="color: red">{{ error }}</p>
22+
{% endfor %}
2423
</div>
24+
</div>
2525

26-
{% endfor %}
26+
{% endfor %}
2727
<div style="text-align:center">
28-
<button type="submit" class="button is-block is-primary is-fullwidth is-middle">Sign up</button>
28+
<button type="submit" class="button is-block is-primary is-fullwidth is-middle">Sign up</button>
2929
</div>
3030
<div class="field">
3131
<span class="checkbox" style="margin-top:30px">

app/authentification/templatetags/utils_templating.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
register = template.Library()
44

5+
56
@register.filter(name='addcss')
67
def addcss(value, arg):
78
css_classes = value.field.widget.attrs.get('class', '').split(' ')

app/authentification/tokens.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from django.contrib.auth.tokens import PasswordResetTokenGenerator
22
from django.utils import six
3+
4+
35
class TokenGenerator(PasswordResetTokenGenerator):
46
def _make_hash_value(self, user, timestamp):
57
return (
68
six.text_type(user.pk) + six.text_type(timestamp) +
79
six.text_type(user.is_active)
810
)
11+
12+
913
account_activation_token = TokenGenerator()

app/authentification/urls.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from django.urls import path
22
from django.contrib.auth.views import PasswordResetDoneView, PasswordResetConfirmView, PasswordResetCompleteView
33

4-
from .views import SignupView
5-
from .utils import activate
4+
from .views import SignupView
5+
from .utils import activate
66

77

88
urlpatterns = [
9-
path('password_reset/done/', PasswordResetDoneView.as_view(),name='password_reset_done'),
10-
path('reset/done/', PasswordResetCompleteView.as_view(),name='password_reset_complete'),
11-
path('reset/<uidb64>/<token>/', PasswordResetConfirmView.as_view(),name='password_reset_confirm'),
9+
path('password_reset/done/', PasswordResetDoneView.as_view(),
10+
name='password_reset_done'),
11+
path('reset/done/', PasswordResetCompleteView.as_view(),
12+
name='password_reset_complete'),
13+
path('reset/<uidb64>/<token>/', PasswordResetConfirmView.as_view(),
14+
name='password_reset_confirm'),
1215
path('signup/', SignupView.as_view(), name='signup'),
1316
path('activate/<str:uidb64>/<str:token>', activate, name='activate'),
1417
]

app/authentification/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .tokens import account_activation_token
77
from django.contrib.auth.models import User
88

9+
910
def activate(request, uidb64, token):
1011
try:
1112
uid = force_text(urlsafe_base64_decode(uidb64))
@@ -15,7 +16,8 @@ def activate(request, uidb64, token):
1516
if user is not None and account_activation_token.check_token(user, token):
1617
user.is_active = True
1718
user.save()
18-
login(request=request, user=user, backend='django.contrib.auth.backends.ModelBackend')
19+
login(request=request, user=user,
20+
backend='django.contrib.auth.backends.ModelBackend')
1921
return redirect('projects')
2022
else:
2123
return render(request, 'validate_mail_address_invalid.html')

app/authentification/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from app import settings
1212

13+
1314
class SignupView(TemplateView):
1415
template_name = 'signup.html'
1516
form_class = SignupForm
@@ -35,12 +36,12 @@ def post(self, request, *args, **kwargs):
3536
message = render_to_string('acc_active_email.html', {
3637
'user': user,
3738
'domain': current_site.domain,
38-
'uid':urlsafe_base64_encode(force_bytes(user.pk)).decode(),
39-
'token':account_activation_token.make_token(user),
39+
'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(),
40+
'token': account_activation_token.make_token(user),
4041
})
4142
to_email = form.cleaned_data.get('email')
4243
email = EmailMessage(
43-
mail_subject, message, to=[to_email]
44+
mail_subject, message, to=[to_email]
4445
)
4546
email.send()
4647
return render(request, 'validate_mail_address_complete.html')

0 commit comments

Comments
 (0)