mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
Upgrade django-registration to version 3.0.
This involves changing how registration templates are referenced and how the activation email is sent on user's email address change. Signed-off-by: Amber Elliot <amber.n.elliot@intel.com>
This commit is contained in:
parent
d333657e9d
commit
0f3b3e42a6
|
@ -148,7 +148,7 @@ INSTALLED_APPS = (
|
|||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'layerindex',
|
||||
'registration',
|
||||
'django_registration',
|
||||
'reversion',
|
||||
'reversion_compare',
|
||||
'captcha',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
from django import forms
|
||||
from captcha.fields import CaptchaField
|
||||
from registration.forms import RegistrationForm
|
||||
from django_registration.forms import RegistrationForm
|
||||
from django.contrib.auth.forms import PasswordResetForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.hashers import check_password
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.core.exceptions import PermissionDenied
|
|||
from django.shortcuts import render
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import logout
|
||||
from registration.backends.model_activation.views import RegistrationView
|
||||
from django_registration.backends.activation.views import RegistrationView
|
||||
from django.contrib.auth.views import PasswordResetView
|
||||
from layerindex.auth_forms import CaptchaRegistrationForm, CaptchaPasswordResetForm, DeleteAccountForm
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from collections import OrderedDict
|
|||
from layerindex.models import LayerItem, LayerBranch, LayerMaintainer, LayerNote, RecipeChangeset, RecipeChange, ClassicRecipe
|
||||
from django import forms
|
||||
from django.core.validators import URLValidator, RegexValidator, EmailValidator
|
||||
from registration.validators import ReservedNameValidator, DEFAULT_RESERVED_NAMES, validate_confusables
|
||||
from django_registration.validators import ReservedNameValidator, DEFAULT_RESERVED_NAMES, validate_confusables
|
||||
from django.forms.models import inlineformset_factory, modelformset_factory
|
||||
from captcha.fields import CaptchaField
|
||||
from django.contrib.auth.models import User
|
||||
|
|
|
@ -4,45 +4,56 @@
|
|||
#
|
||||
# Licensed under the MIT license, see COPYING.MIT for details
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pkg_resources import parse_version
|
||||
from itertools import islice
|
||||
from django.shortcuts import get_object_or_404, get_list_or_404, render
|
||||
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404
|
||||
from django.core.urlresolvers import reverse, reverse_lazy, resolve
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.template import RequestContext
|
||||
from layerindex.models import Branch, LayerItem, LayerMaintainer, LayerBranch, LayerDependency, LayerNote, Update, LayerUpdate, Recipe, Machine, Distro, BBClass, IncFile, BBAppend, RecipeChange, RecipeChangeset, ClassicRecipe, StaticBuildDep, DynamicBuildDep
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from django.views.generic import TemplateView, DetailView, ListView
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
from django.views.generic.base import RedirectView
|
||||
from itertools import islice
|
||||
from pkg_resources import parse_version
|
||||
|
||||
import reversion
|
||||
from django import forms
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import logout
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.contrib.auth.models import Permission, User
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from layerindex.forms import EditLayerForm, LayerMaintainerFormSet, EditNoteForm, EditProfileForm, RecipeChangesetForm, AdvancedRecipeSearchForm, BulkChangeEditFormSet, ClassicRecipeForm, ClassicRecipeSearchForm, ComparisonRecipeSelectForm
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.urlresolvers import resolve, reverse, reverse_lazy
|
||||
from django.db import transaction
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.db.models import Q, Count, Sum
|
||||
from django.db.models import Count, Q
|
||||
from django.db.models.functions import Lower
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models.signals import pre_save
|
||||
from django.dispatch import receiver
|
||||
from django.http import Http404, HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import get_list_or_404, get_object_or_404, render
|
||||
from django.template.loader import get_template
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth import logout
|
||||
from django.contrib import messages
|
||||
from django import forms
|
||||
from django.utils.html import escape
|
||||
from django.contrib.sites.models import Site
|
||||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.views.generic.edit import (CreateView, DeleteView, FormView,
|
||||
UpdateView)
|
||||
|
||||
from django_registration.backends.activation.views import RegistrationView
|
||||
from reversion.models import Revision
|
||||
from . import utils
|
||||
from . import simplesearch
|
||||
from . import tasks
|
||||
|
||||
import settings
|
||||
from django.dispatch import receiver
|
||||
import reversion
|
||||
from django.db.models.signals import pre_save
|
||||
from registration.models import RegistrationProfile
|
||||
from layerindex.forms import (AdvancedRecipeSearchForm, BulkChangeEditFormSet,
|
||||
ClassicRecipeForm, ClassicRecipeSearchForm,
|
||||
ComparisonRecipeSelectForm, EditLayerForm,
|
||||
EditNoteForm, EditProfileForm,
|
||||
LayerMaintainerFormSet, RecipeChangesetForm)
|
||||
from layerindex.models import (BBAppend, BBClass, Branch, ClassicRecipe,
|
||||
Distro, DynamicBuildDep, IncFile, LayerBranch,
|
||||
LayerDependency, LayerItem, LayerMaintainer,
|
||||
LayerNote, LayerUpdate, Machine, Patch, Recipe,
|
||||
RecipeChange, RecipeChangeset, Source, StaticBuildDep,
|
||||
Update)
|
||||
|
||||
from . import simplesearch, tasks, utils
|
||||
|
||||
def edit_layernote_view(request, template_name, slug, pk=None):
|
||||
layeritem = get_object_or_404(LayerItem, name=slug)
|
||||
|
@ -887,10 +898,9 @@ class EditProfileFormView(SuccessMessageMixin, UpdateView):
|
|||
# Deactivate user and put through registration again
|
||||
user.is_active = False
|
||||
user.save()
|
||||
site = Site.objects.get_current()
|
||||
RegistrationProfile.objects.filter(user=user).delete()
|
||||
registration_profile = RegistrationProfile.objects.create_profile(user)
|
||||
registration_profile.send_activation_email(site)
|
||||
view = RegistrationView()
|
||||
view.request = self.request
|
||||
view.send_activation_email(user)
|
||||
return HttpResponseRedirect(reverse('reregister'))
|
||||
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
@ -1611,4 +1621,3 @@ class ComparisonRecipeSelectDetailView(DetailView):
|
|||
messages.error(request, 'Failed to save changes: %s' % form.errors)
|
||||
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ django-axes==4.4.2
|
|||
django-cors-headers==2.4.0
|
||||
django-ipware==2.1.0
|
||||
django-ranged-response==0.2.0
|
||||
django-registration==2.5.2
|
||||
django-registration==3
|
||||
django-reversion==2.0.13
|
||||
django-reversion-compare==0.8.5
|
||||
django-simple-captcha==0.5.9
|
||||
|
|
|
@ -148,7 +148,7 @@ INSTALLED_APPS = (
|
|||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'layerindex',
|
||||
'registration',
|
||||
'django_registration',
|
||||
'reversion',
|
||||
'reversion_compare',
|
||||
'captcha',
|
||||
|
|
|
@ -53,14 +53,14 @@
|
|||
<b class="caret"></b>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a></li>
|
||||
<li><a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a></li>
|
||||
<li><a href="{% url 'logout' %}">{% trans "Log out" %}</a></li>
|
||||
<li><a href="{% url 'password_change' %}">{% trans "Change password" %}</a></li>
|
||||
<li><a href="{% url 'profile' %}?return_to={{ request.path }}">{% trans "Edit profile" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="pull-right nav-spacer">
|
||||
<a class="btn btn-default navbar-btn" href="{% url 'auth_login' %}{% if login_return_url %}?next={{ login_return_url }}{% endif %}">{% trans "Log in" %}</a>
|
||||
<a class="btn btn-default navbar-btn" href="{% url 'login' %}{% if login_return_url %}?next={{ login_return_url }}{% endif %}">{% trans "Log in" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<p>{% trans "Account successfully activated" %}</p>
|
||||
|
||||
<p><a href="{% url "auth_login" %}">{% trans "Log in" %}</a></p>
|
||||
<p><a href="{% url "login" %}">{% trans "Log in" %}</a></p>
|
||||
|
||||
{% else %}
|
||||
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
{% trans "Your account has been successfully activated." %}
|
||||
<br/>
|
||||
{% trans "You can now " %} <a href="{% url 'auth_login' %}">{% trans "log in" %}</a>.
|
||||
{% trans "You can now " %} <a href="{% url 'login' %}">{% trans "log in" %}</a>.
|
||||
|
||||
{% endblock %}
|
|
@ -7,7 +7,7 @@ link is valid for {{ expiration_days }} days.
|
|||
|
||||
{% endblocktrans %}
|
||||
|
||||
http://{{ site.domain }}{% url "registration_activate" activation_key %}
|
||||
http://{{ site.domain }}{% url "django_registration_activate" activation_key %}
|
||||
|
||||
{% blocktrans %}
|
||||
If you did not make this request, please ignore this message.
|
13
templates/django_registration/activation_failed.html
Normal file
13
templates/django_registration/activation_failed.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% blocktrans %}
|
||||
|
||||
Activation has failed.
|
||||
<br/>
|
||||
|
||||
{% endblocktrans %}
|
||||
|
||||
{% endblock %}
|
|
@ -13,8 +13,8 @@
|
|||
{% csrf_token %}
|
||||
</form>
|
||||
|
||||
<p>{% trans "Forgot password" %}? <a href="{% url "auth_password_reset" %}">{% trans "Reset it" %}</a>!</p>
|
||||
<p>{% trans "Don't have an account" %}? <a href="{% url "registration_register" %}">{% trans "Create one now" %}</a>!</p>
|
||||
<p>{% trans "Forgot password" %}? <a href="{% url "password_reset" %}">{% trans "Reset it" %}</a>!</p>
|
||||
<p>{% trans "Don't have an account" %}? <a href="{% url "django_registration_register" %}">{% trans "Create one now" %}</a>!</p>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
<p>{% trans "Password reset successfully" %}</p>
|
||||
|
||||
<p><a href="{% url "auth_login" %}">{% trans "Log in" %}</a></p>
|
||||
<p><a href="{% url "login" %}">{% trans "Log in" %}</a></p>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
If you did request to reset your password, please click on the following link to do so:{% endblocktrans %}
|
||||
|
||||
{% block reset_link %}
|
||||
{{ protocol }}://{{ domain }}{% url "auth_password_reset_confirm" uidb64=uid token=token %}
|
||||
{{ protocol }}://{{ domain }}{% url "password_reset_confirm" uidb64=uid token=token %}
|
||||
{% endblock %}
|
||||
|
||||
{% blocktrans %}If you did not make this request then please ignore this message.{% endblocktrans %}
|
||||
|
|
9
urls.py
9
urls.py
|
@ -21,17 +21,18 @@ urlpatterns = [
|
|||
url(r'^accounts/password/reset/$',
|
||||
CaptchaPasswordResetView.as_view(
|
||||
email_template_name='registration/password_reset_email.txt',
|
||||
success_url=reverse_lazy('auth_password_reset_done')),
|
||||
name='auth_password_reset'),
|
||||
success_url=reverse_lazy('password_reset_done')),
|
||||
name='password_reset'),
|
||||
url(r'^accounts/register/$', CaptchaRegistrationView.as_view(),
|
||||
name='registration_register'),
|
||||
name='django_registration_register'),
|
||||
url(r'^accounts/delete/$', delete_account_view,
|
||||
{'template_name': 'layerindex/deleteaccount.html'},
|
||||
name='delete_account'),
|
||||
url(r'^accounts/reregister/$', TemplateView.as_view(
|
||||
template_name='registration/reregister.html'),
|
||||
name='reregister'),
|
||||
url(r'^accounts/', include('registration.backends.default.urls')),
|
||||
url(r'^accounts/', include('django_registration.backends.activation.urls')),
|
||||
url(r'^accounts/', include('django.contrib.auth.urls')),
|
||||
url(r'^captcha/', include('captcha.urls')),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user