uaccounts package

Submodules

uaccounts.admin module

class uaccounts.admin.UserProfileAdmin(model, admin_site)[source]

Bases: django.contrib.auth.admin.UserAdmin

inlines = [<class 'uaccounts.admin.UserProfileInline'>]
media
class uaccounts.admin.UserProfileInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

can_delete = False
max_num = 1
media
model

alias of UserProfile

uaccounts.decorators module

uaccounts.decorators.guest(view)[source]

Ensure user is not logged in.

uaccounts.decorators.pending(view)[source]

Ensure user is logged in and pending.

uaccounts.decorators.personal(view)[source]

Ensure user is logged in and active.

uaccounts.forms module

class uaccounts.forms.ChangePasswordForm(user, *args, **kwargs)[source]

Bases: django.contrib.auth.forms.SetPasswordForm

Change password form. User sets directly the new password (twice) without entering the old password.

base_fields = OrderedDict([('new_password1', <django.forms.fields.CharField object at 0x03C48F30>), ('new_password2', <django.forms.fields.CharField object at 0x03CEBB10>)])
declared_fields = OrderedDict([('new_password1', <django.forms.fields.CharField object at 0x03C48F30>), ('new_password2', <django.forms.fields.CharField object at 0x03CEBB10>)])
error_messages = {'password_mismatch': 'The two passwords did not match'}
media
class uaccounts.forms.EditProfileForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None)[source]

Bases: django.forms.models.ModelForm

Edit profile form.

class Meta[source]
error_messages = {'status': {'max_length': 'Status must consist of 200 characters maximum'}, 'website': {'invalid': 'Invalid website URL'}}
fields = ['gender', 'date_of_birth', 'status', 'website']
model

alias of UserProfile

EditProfileForm.YEARS = [1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015]
EditProfileForm.base_fields = OrderedDict([('gender', <django.forms.fields.TypedChoiceField object at 0x03CEBD10>), ('date_of_birth', <django.forms.fields.DateField object at 0x03CEBBD0>), ('status', <django.forms.fields.CharField object at 0x03CEBDF0>), ('website', <django.forms.fields.URLField object at 0x03CEBE90>), ('avatar', <django.forms.fields.ImageField object at 0x03CEBBF0>)])
EditProfileForm.declared_fields = OrderedDict([('date_of_birth', <django.forms.fields.DateField object at 0x03CEBBD0>), ('avatar', <django.forms.fields.ImageField object at 0x03CEBBF0>)])
EditProfileForm.media
EditProfileForm.save()[source]

Resize and set new avatar, or just delete the old one.

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

Bases: django.forms.models.ModelForm

Edit user form.

class Meta[source]
fields = ['first_name', 'last_name']
model

alias of User

EditUserForm.base_fields = OrderedDict([('first_name', <django.forms.fields.CharField object at 0x03CEBF50>), ('last_name', <django.forms.fields.CharField object at 0x03CEBFF0>)])
EditUserForm.declared_fields = OrderedDict()
EditUserForm.media
class uaccounts.forms.EmailAddressForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False)[source]

Bases: django.forms.forms.Form

Form with an email address as the only field. Used for “forgot password” and “add email”.

base_fields = OrderedDict([('email', <django.forms.fields.EmailField object at 0x03CEBA70>)])
declared_fields = OrderedDict([('email', <django.forms.fields.EmailField object at 0x03CEBA70>)])
media
class uaccounts.forms.LoginForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False)[source]

Bases: django.forms.forms.Form

User login form.

base_fields = OrderedDict([('username', <django.forms.fields.CharField object at 0x03CEB810>), ('password', <django.forms.fields.CharField object at 0x03CEB850>), ('remember', <django.forms.fields.BooleanField object at 0x03CEB890>)])
declared_fields = OrderedDict([('username', <django.forms.fields.CharField object at 0x03CEB810>), ('password', <django.forms.fields.CharField object at 0x03CEB850>), ('remember', <django.forms.fields.BooleanField object at 0x03CEB890>)])
media
class uaccounts.forms.RegistrationForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None)[source]

Bases: django.contrib.auth.forms.UserCreationForm

User registration form.

class Meta
error_messages = {'username': {'max_length': 'Username must consist of 30 characters maximum', 'unique': 'Username is already in use', 'required': 'Username is required'}}
fields = (u'username',)
model

alias of User

RegistrationForm.base_fields = OrderedDict([(u'username', <django.forms.fields.CharField object at 0x03CEB490>), ('password1', <django.forms.fields.CharField object at 0x03CEB8D0>), ('password2', <django.forms.fields.CharField object at 0x03CEB950>), ('email', <django.forms.fields.EmailField object at 0x03CEB990>)])
RegistrationForm.clean_email()[source]

Make sure email address is unique.

RegistrationForm.clean_username()[source]

Make sure username does not exceed minimum length.

RegistrationForm.declared_fields = OrderedDict([('password1', <django.forms.fields.CharField object at 0x03CEB8D0>), ('password2', <django.forms.fields.CharField object at 0x03CEB950>), ('email', <django.forms.fields.EmailField object at 0x03CEB990>)])
RegistrationForm.error_messages = {'password_mismatch': 'The two passwords did not match', 'email_unique': 'Email address is already in use', 'username_min_length': 'Username must consist of 4 characters minimum'}
RegistrationForm.media
RegistrationForm.save()[source]

Set email address, set the user as inactive and create a user profile.

uaccounts.models module

class uaccounts.models.Avatar(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Profile avatar, stores height and width.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Avatar.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Avatar.image

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

Avatar.objects = <django.db.models.manager.Manager object>
Avatar.profile
class uaccounts.models.EmailAddress(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Email address belonging to a user profile.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception EmailAddress.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

EmailAddress.get_next_by_modified(*moreargs, **morekwargs)
EmailAddress.get_previous_by_modified(*moreargs, **morekwargs)
EmailAddress.objects = <django.db.models.manager.Manager object at 0x0377DC30>
EmailAddress.profile
EmailAddress.set_primary()[source]

Set this as primary, after unsetting all the rest the user has.

EmailAddress.verification
class uaccounts.models.UserProfile(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Contains user details and information.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

UserProfile.GENDERS = (('-', <django.utils.functional.__proxy__ object at 0x037755B0>), ('m', <django.utils.functional.__proxy__ object at 0x03775610>), ('f', <django.utils.functional.__proxy__ object at 0x03775650>))
UserProfile.GENDER_FEMALE = 'f'
UserProfile.GENDER_MALE = 'm'
UserProfile.GENDER_UNSPECIFIED = '-'
exception UserProfile.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

UserProfile.avatar
UserProfile.email

Primary email, an EmailAddress instance, or None if none exist.

UserProfile.emails
UserProfile.get_gender_display(*moreargs, **morekwargs)
UserProfile.get_next_by_updated(*moreargs, **morekwargs)
UserProfile.get_previous_by_updated(*moreargs, **morekwargs)
UserProfile.objects = <django.db.models.manager.Manager object at 0x0377D6F0>
UserProfile.save(*args, **kwargs)[source]

Add the existing email address.

UserProfile.user
class uaccounts.models.VerificationCode(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Verification code of an email address, also used to activate user account and to change forgotten password.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception VerificationCode.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

VerificationCode.email
VerificationCode.objects = <django.db.models.manager.Manager object at 0x0377DF70>
VerificationCode.url

String to be part of the verification URL.

uaccounts.settings module

uaccounts.urls module

uaccounts.utils module

exception uaccounts.utils.VerificationError[source]

Bases: exceptions.Exception

Failed to verify token.

uaccounts.utils.profile_emails(profile, get_unverified=False)[source]

Return a dict of user profile’s emails, divided into primary, rest and optionally unverified. Also pass their total count.

uaccounts.utils.verification_mail(request, email, subject, template, action)[source]

Delete email’s verification code if it exists and then create a new one. Then construct and send the respective email.

uaccounts.utils.verify_token(token, max_age)[source]

Try to verify token and return the respective VerificationCode instance. Raise VerificationError on failure.

uaccounts.views module

uaccounts.views.activate(request, *args, **kwargs)[source]

Try to activate account using given token.

uaccounts.views.add_email(request, *args, **kwargs)[source]

Add new email address. Used through AJAX.

POST data: email

uaccounts.views.change(request, *args, **kwargs)[source]

If confirmation code is valid, show the password change form or try to change the password.

context
  • form: “change password” form
uaccounts.views.edit(request, *args, **kwargs)[source]

Show “edit profile” page or process the profile editing.

context
  • form: “edit profile” form
uaccounts.views.forgot(request, *args, **kwargs)[source]

Create a “forgot password” verification code and send the respective email, or just show the “forgot password” page.

context
  • email: email address the mail was sent to
  • form: “forgot password” form
  • error: error message
uaccounts.views.index(request, *args, **kwargs)[source]

User’s homepage.

context
  • primary: primary email
  • secondary: list of verified emails
  • unverified: list of unverified emails
  • count: total email count
  • home: parent url
uaccounts.views.log_in(request, *args, **kwargs)[source]

Show the login form, or log the user in. If they are already logged in, redirect to index.

context
  • form: login form
  • error: error message
uaccounts.views.log_out(request)[source]

Log the user out.

uaccounts.views.primary_email(request, *args, **kwargs)[source]

Set an email address as user’s primary. Used through AJAX.

POST data: id

uaccounts.views.register(request, *args, **kwargs)[source]

Show the registration form, or register a new user. If they are logged in, redirect to index.

context
  • form: registration form
uaccounts.views.remove_email(request, *args, **kwargs)[source]

Remove an email address. Used through AJAX.

POST data: id

uaccounts.views.send(request, *args, **kwargs)[source]

Create activation code, send account activation email and show the pending page.

uaccounts.views.verify(request, *args, **kwargs)[source]

Try to verify email address using given token.

uaccounts.views.verify_email(request, *args, **kwargs)[source]

Send email address verification mail. Used through AJAX.

POST data: id

Module contents