Accounts App

The accounts application extends the default Django authentication and Django registration redux in order to support IMAGE-InjectTool two-steps authentication with Biosample registration and tracking uid.models.Organization objects.

accounts.forms

accounts.forms module contents

Created on Thu Jun 21 16:04:02 2018

@author: Paolo Cozzi <cozzi@ibba.cnr.it>

inspired from A Complete Beginner’s Guide to Django - Part 4

https://simpleisbetterthancomplex.com/series/2017/09/25/a-complete-beginners-guide-to-django-part-4.html

class accounts.forms.MyAccountForm(*args, **kwargs)[source]

Bases: common.forms.RequestFormMixin, betterforms.multiform.MultiModelForm

form_classes = {'person': <class 'accounts.forms.PersonForm'>, 'user': <class 'accounts.forms.UserForm'>}
class accounts.forms.PersonForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ('initials', 'affiliation', 'role')
model

alias of uid.models.Person

base_fields = {'affiliation': <django.forms.models.ModelChoiceField object>, 'initials': <django.forms.fields.CharField object>, 'role': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class accounts.forms.SignUpForm(*args, **kwargs)[source]

Bases: common.forms.RequestFormMixin, betterforms.multiform.MultiModelForm

form_classes = {'person': <class 'accounts.forms.SignUpPersonForm'>, 'user': <class 'accounts.forms.SignUpUserForm'>}
class accounts.forms.SignUpPersonForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ('initials', 'affiliation', 'role')
model

alias of uid.models.Person

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

base_fields = {'affiliation': <django.forms.models.ModelChoiceField object>, 'agree_gdpr': <django.forms.fields.BooleanField object>, 'botcatcher': <django.forms.fields.CharField object>, 'initials': <django.forms.fields.CharField object>, 'role': <django.forms.models.ModelChoiceField object>}
declared_fields = {'agree_gdpr': <django.forms.fields.BooleanField object>, 'botcatcher': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class accounts.forms.SignUpUserForm(*args, **kwargs)[source]

Bases: django.contrib.auth.forms.UserCreationForm

class Meta[source]

Bases: object

fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2')
model

alias of django.contrib.auth.models.User

base_fields = {'email': <django.forms.fields.CharField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'username': <django.forms.fields.CharField object>}
declared_fields = {'email': <django.forms.fields.CharField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class accounts.forms.UserForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.models.ModelForm

class Meta[source]

Bases: object

fields = ('first_name', 'last_name', 'email')
model

alias of django.contrib.auth.models.User

base_fields = {'email': <django.forms.fields.CharField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>}
declared_fields = {'email': <django.forms.fields.CharField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

accounts.models

accounts.models module contents

Created on Fri Jul 20 13:35:27 2018

@author: Paolo Cozzi <cozzi@ibba.cnr.it>

class accounts.models.MyRegistrationManager(*args, **kwargs)[source]

Bases: registration.models.RegistrationManager

resend_activation_mail(email, site, request=None)[source]

Resets activation key for the user and resends activation email. If activation_key is expired, generate a new key

class accounts.models.MyRegistrationProfile(id, user, activation_key, activated)[source]

Bases: registration.models.RegistrationProfile

exception DoesNotExist

Bases: registration.models.RegistrationProfile.DoesNotExist

exception MultipleObjectsReturned

Bases: registration.models.RegistrationProfile.MultipleObjectsReturned

create_new_activation_key(save=True)[source]

Create a new activation key for the user. If the old one is still valid return it

objects = <accounts.models.MyRegistrationManager object>
accounts.models.create_key()[source]

Create a random key for activatings accounts

accounts.views

accounts.views module contents

Created on Thu Jun 21 16:04:02 2018

@author: Paolo Cozzi <cozzi@ibba.cnr.it>

inspired from A Complete Beginner’s Guide to Django - Part 4

https://simpleisbetterthancomplex.com/series/2017/09/25/a-complete-beginners-guide-to-django-part-4.html

class accounts.views.ActivationComplete(**kwargs)[source]

Bases: django.contrib.auth.mixins.LoginRequiredMixin, django.views.generic.base.TemplateView

template_name = 'registration/activation_complete.html'
class accounts.views.ActivationView(**kwargs)[source]

Bases: registration.backends.default.views.ActivationView

activate(*args, **kwargs)[source]

Given an an activation key, look up and activate the user account corresponding to that key (if possible).

After successful activation, the signal registration.signals.user_activated will be sent, with the newly activated User as the keyword argument user and the class of this backend as the sender.

get(request, *args, **kwargs)[source]
get_success_url(user)[source]
success_url = 'accounts:registration_activation_complete'
template_name = 'registration/activation_failed.html'
exception accounts.views.MailAlreadyRegisteredException[source]

Bases: Exception

class accounts.views.MyAccountView(**kwargs)[source]

Bases: django.contrib.auth.mixins.LoginRequiredMixin, django.views.generic.edit.UpdateView

form_class

alias of accounts.forms.MyAccountForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_object()[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]

Override default function

model

alias of django.contrib.auth.models.User

success_url
template_name = 'accounts/update_user.html'
class accounts.views.ResendActivationView(**kwargs)[source]

Bases: registration.backends.default.views.ResendActivationView

form_valid(form)[source]

Regardless if resend_activation is successful, display the same confirmation template.

registration_profile

alias of accounts.models.MyRegistrationProfile

render_form_submitted_template(form)[source]

Renders resend activation complete template with the submitted email.

class accounts.views.SignUpView(**kwargs)[source]

Bases: registration.backends.default.views.RegistrationView

form_class

alias of accounts.forms.SignUpForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

register(form)[source]

Given a username, email address and password, register a new user account, which will initially be inactive. Along with the new User object, a new registration.models.RegistrationProfile will be created, tied to that User, containing the activation key which will be used for this account. An email will be sent to the supplied email address; this email should contain an activation link. The email will be rendered using two templates. See the documentation for RegistrationProfile.send_activation_email() for information about these templates and the contexts provided to them. After the User and RegistrationProfile are created and the activation email is sent, the signal registration.signals.user_registered will be sent, with the new User as the keyword argument user and the class of this backend as the sender.

success_url = 'accounts:registration_complete'
template_name = 'accounts/signup.html'