diff --git a/logs/views.py b/logs/views.py index 9cda43f..afc1696 100644 --- a/logs/views.py +++ b/logs/views.py @@ -102,7 +102,8 @@ class EntriesView(generic.ListView): if source is None: return [] - nb_max = settings.KHAGANAT_LOGS_MAX_DAYS - settings.KHAGANAT_LOGS_MIN_DAYS + nb_max = settings.KHAGANAT_LOGS_MAX_DAYS + nb_max -= settings.KHAGANAT_LOGS_MIN_DAYS lst = Entry.objects.filter( source=source, ) diff --git a/neluser/forms.py b/neluser/forms.py index 28cf166..d2143d4 100644 --- a/neluser/forms.py +++ b/neluser/forms.py @@ -12,10 +12,20 @@ class RegistrationForm(UserCreationForm): model = NelUser fields = (NelUser.EMAIL_FIELD,) + class ChangePasswordForm(forms.Form): - current_password = forms.CharField(label=_('current_password'), widget=forms.PasswordInput) - new_password = forms.CharField(label=_('new_password'), widget=forms.PasswordInput) - new_password_confirm = forms.CharField(label=_('new_password_confirm'), widget=forms.PasswordInput) + current_password = forms.CharField( + label=_('current_password'), + widget=forms.PasswordInput + ) + new_password = forms.CharField( + label=_('new_password'), + widget=forms.PasswordInput + ) + new_password_confirm = forms.CharField( + label=_('new_password_confirm'), + widget=forms.PasswordInput + ) def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') @@ -28,17 +38,22 @@ class ChangePasswordForm(forms.Form): new_pass_confirm = cleaned_data.get('new_password_confirm') user = self.request.user if new_pass != new_pass_confirm: - raise forms.ValidationError(_('The new password does not match its confirmation.')) + msg = _('The new password does not match its confirmation.') + raise forms.ValidationError(msg) try: validate_password(new_pass, user=user) except ValidationError as error: raise forms.ValidationError(error) if not user.check_password(old_pass): - raise forms.ValidationError(_('The current password is incorrect.')) + msg = _('The current password is incorrect.') + raise forms.ValidationError(msg) class DeleteAccountForm(forms.Form): - current_password = forms.CharField(label=_('current_password'), widget=forms.PasswordInput) + current_password = forms.CharField( + label=_('current_password'), + widget=forms.PasswordInput + ) def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') @@ -49,4 +64,5 @@ class DeleteAccountForm(forms.Form): password = cleaned_data.get('current_password') user = self.request.user if not user.check_password(password): - raise forms.ValidationError(_('The current password is incorrect.')) + msg = _('The current password is incorrect.') + raise forms.ValidationError(msg) diff --git a/neluser/urls.py b/neluser/urls.py index c215c17..3e1899c 100644 --- a/neluser/urls.py +++ b/neluser/urls.py @@ -59,6 +59,14 @@ urlpatterns = [ path('settings/', views.settings_default, name='settings'), # Security - path('settings/security/password/', views.ChangePasswordView.as_view(), name='password_change'), - path('settings/security/delete_account/', views.DeleteAccountView.as_view(), name='delete_account'), + path( + 'settings/security/password/', + views.ChangePasswordView.as_view(), + name='password_change' + ), + path( + 'settings/security/delete_account/', + views.DeleteAccountView.as_view(), + name='delete_account' + ), ] diff --git a/nsfw/views.py b/nsfw/views.py index d9fc3a9..6415dcc 100644 --- a/nsfw/views.py +++ b/nsfw/views.py @@ -73,7 +73,12 @@ def warn_msg(request, next_url=None): 'next_url': next_url, 'is_authenticated': request.user.is_authenticated, } - return render_to_string(request, 'nsfw/redirect_page.html', context=context) + ret = render_to_string( + request, + 'nsfw/redirect_page.html', + context=context + ) + return ret def redirect(request): @@ -83,6 +88,7 @@ def redirect(request): ) return HttpResponseRedirect(dest) + def alert(request, next_url=None): context = { 'next_url': next_url, diff --git a/pages/templatetags/get_page.py b/pages/templatetags/get_page.py index f922490..c7e5e76 100644 --- a/pages/templatetags/get_page.py +++ b/pages/templatetags/get_page.py @@ -4,6 +4,7 @@ from django import template register = template.Library() + @register.simple_tag(takes_context=True) def get_page(context, slug): request = context['request']