/usr/lib/python2.7/dist-packages/registration/backends/model_activation/views.py is in python-django-registration 2.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | """
A two-step (registration followed by activation) workflow, implemented
by storing an activation key in a model and emailing the key to the
user.
This workflow is provided primarily for backwards-compatibility with
existing installations; new installs of django-registration should
look into the HMAC activation workflow in registration.backends.hmac.
"""
from django.contrib.sites.shortcuts import get_current_site
from registration import signals
from registration.models import RegistrationProfile
from registration.views import ActivationView as BaseActivationView
from registration.views import RegistrationView as BaseRegistrationView
class RegistrationView(BaseRegistrationView):
"""
Register a new (inactive) user account, generate and store an
activation key, and email it to the user.
"""
def register(self, form):
new_user = RegistrationProfile.objects.create_inactive_user(
form,
site=get_current_site(self.request)
)
signals.user_registered.send(sender=self.__class__,
user=new_user,
request=self.request)
return new_user
def get_success_url(self, user):
return ('registration_complete', (), {})
class ActivationView(BaseActivationView):
"""
Given a valid activation key, activate the user's
account. Otherwise, show an error message stating the account
couldn't be activated.
"""
def activate(self, *args, **kwargs):
activation_key = kwargs.get('activation_key')
activated_user = RegistrationProfile.objects.activate_user(
activation_key
)
return activated_user
def get_success_url(self, user):
return ('registration_activation_complete', (), {})
|