Accounts

This module is used to maintain user accounts and profile information.

Models

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

Officer headshots

Parameters:
  • id (AutoField) – Id (required)
  • officer (OneToOneField to User) – Officer (required)
  • img (ImageField) – Image (required)
exception DoesNotExist
exception MultipleObjectsReturned
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

img

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

objects = <django.db.models.manager.Manager object>
officer

OneToOneField(related_name=”img”, on_delete=CASCADE(), to= User)

officer_id

Raw (integer) FK for officer

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

Used for temporarily saving the last code sent to a user to verify their phone number

Parameters:
  • id (AutoField) – Id (required)
  • user (OneToOneField to User) – User (required)
  • code (BigIntegerField) – Code (required)
  • timestamp (DateTimeField) – Timestamp (required)
exception DoesNotExist
exception MultipleObjectsReturned
code

BigIntegerField()

get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)
get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=False, **kwargs)
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

objects = <django.db.models.manager.Manager object>
timestamp

DateTimeField(auto_now_add=True)

user

OneToOneField(related_name=”verification_codes”, on_delete=CASCADE(), to= User)

user_id

Raw (integer) FK for user

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

Extended User Class

Parameters:
  • id (AutoField) – Id (required)
  • password (CharField) – Password (required)
  • last_login (DateTimeField) – Last login
  • is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them. (default=False)
  • username (CharField) – Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. (required)
  • first_name (CharField) – First name (required)
  • last_name (CharField) – Last name (required)
  • email (EmailField) – Email address (required)
  • is_staff (BooleanField) – Designates whether the user can log into this admin site. (default=False)
  • is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts. (default=True)
  • date_joined (DateTimeField) – Date joined (default=<function now at 0x7f6463fb18c0>)
  • title (CharField) – Officer position
  • wpibox (IntegerField) – Wpi box number
  • phone (CharField) – Phone number
  • carrier (CharField) – By selecting your cellular carrier you consent to receiving text messages from LNL (default=)
  • addr (TextField) – Address / office location
  • mdc (CharField) – Mdc
  • nickname (CharField) – Nickname
  • student_id (PositiveIntegerField) – Student id
  • class_year (PositiveIntegerField) – Class year
  • locked (BooleanField) – Locked (default=False)
  • away_exp (DateField) – Away status expiration
  • onboarded (BooleanField) – Onboarding complete (default=False)
  • groups (ManyToManyField to Group) – The groups this user belongs to. A user will get all permissions granted to each of their groups. (required)
  • user_permissions (ManyToManyField to Permission) – Specific permissions for this user. (required)
exception DoesNotExist
exception MultipleObjectsReturned
access_logs

Reverse Manager for inventory.AccessRecord’s users

addr

TextField(verbose_name=”Address / Office Location”, blank=True, null=True)

all_orgs

All organizations the user is associated with

auth_token

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

away_exp

DateField(verbose_name=”Away Status Expiration”, blank=True, null=True)

baseevent_set

Reverse Manager for events.BaseEvent’s contact

billingemail_set

Reverse Manager for events.BillingEmail’s email_to_users

carrier

CharField(verbose_name=”Cellular Carrier”, max_length=25, blank=True, null=True, default=””, choices=[(‘’, ‘Opt-out’), (‘txt.att.net’, ‘AT&T’), (‘myboostmobile.com’, ‘Boost Mobile’), (‘mms.cricketwireless.net’, ‘Cricket’), (‘msg.fi.google.com’, ‘Google Fi’), (‘mymetropcs.com’, ‘Metro PCS’), (‘mmst5.tracfone.com’, ‘Simple Mobile’), (‘messaging.sprintpcs.com’, ‘Sprint’), (‘tmomail.net’, ‘T-Mobile’), (‘vtext.com’, ‘Verizon’), (‘vmobl.com’, ‘Virgin Mobile’), (‘vmobile.ca’, ‘Virgin Mobile Canada’), (‘vtext.com’, ‘Xfinity Mobile’)], help_text=”By selecting your cellular carrier you consent to receiving text messages from LNL”)

Cellular carrier: By selecting your cellular carrier you consent to receiving text messages from LNL

ccinstances

Reverse Manager for events.EventCCInstance’s crew_chief

ccreport_set

Reverse Manager for events.CCReport’s crew_chief

ccreportreminders

Reverse Manager for events.ReportReminder’s crew_chief

class_year

PositiveIntegerField(blank=True, null=True)

connected_services

Reverse Manager for data.Extension’s users

crewchiefx

Reverse Manager for events.Event’s crew_chief

crewx

Reverse Manager for events.Event’s crew

equipmentmaintentry_set

Reverse Manager for inventory.EquipmentMaintEntry’s user

event_records

Reverse Manager for events.CrewAttendanceRecord’s user

eventapprovals

Reverse Manager for events.BaseEvent’s approved_by

eventbillingreview

Reverse Manager for events.BaseEvent’s reviewed_by

eventcancellations

Reverse Manager for events.BaseEvent’s cancelled_by

eventclosings

Reverse Manager for events.BaseEvent’s closed_by

get_carrier_display(*, field=<django.db.models.fields.CharField: carrier>)
get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
group_str

Groups the user belongs to

groups

Reverse Manager for accounts.User’s groups

has_perm(perm, obj=None)[source]

Returns True if the user has the specified permission. This method queries all available auth backends, but returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general. If an object is provided, permissions for this specific object are checked.

This differs from the default in that superusers, while still having every permission, will be allowed after the logic has executed. This helps with typos in permission strings.

hours

Reverse Manager for events.Hours’s user

id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

img

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

is_complete

Returns false if the user’s profile is incomplete. The user will be constantly reminded to complete their profile.

is_lnl

Is an LNL member

laptoppasswordretrieval_set

Reverse Manager for devices.LaptopPasswordRetrieval’s user

locked

BooleanField(default=False)

logentry_set

Reverse Manager for admin.LogEntry’s user

mdc

CharField(verbose_name=”MDC”, max_length=32, blank=True, null=True)

mdc_name
meeting_set

Reverse Manager for meetings.Meeting’s attendance

mtgattachment_set

Reverse Manager for meetings.MtgAttachment’s author

multibillingemail_set

Reverse Manager for events.MultiBillingEmail’s email_to_users

name

User’s full name

nickname

CharField(verbose_name=”Nickname”, max_length=32, blank=True, null=True)

officehour_set

Reverse Manager for events.OfficeHour’s officer

onboarded

BooleanField(verbose_name=”Onboarding Complete”, default=False)

onboardingrecord_set

Reverse Manager for pages.OnboardingRecord’s user

onboardingscreen_set

Reverse Manager for pages.OnboardingScreen’s users

orgowner

Reverse Manager for events.Organization’s user_in_charge

orgs

Organizations the user belongs to

orgusers

Reverse Manager for events.Organization’s associated_users

owns

Organizations the user owns

phone

CharField(verbose_name=”Phone Number”, max_length=24, blank=True, null=True)

preferences

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

projectionist

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

revision_set

Reverse Manager for reversion.Revision’s user

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

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

smsmessage_set

Reverse Manager for emails.SMSMessage’s user

student_id

PositiveIntegerField(verbose_name=”Student ID”, blank=True, null=True)

stupidcat_set

Reverse Manager for data.StupidCat’s user

submitter

Reverse Manager for events.BaseEvent’s submitted_by

surveys

Reverse Manager for events.PostEventSurvey’s person

title

CharField(verbose_name=”Officer Position”, max_length=60, blank=True, null=True)

token_requests

Reverse Manager for api.TokenRequest’s user

trainings

Reverse Manager for members.Trainee’s person

trainings_entered

Reverse Manager for members.Training’s recorded_by

trainings_revoked

Reverse Manager for members.Trainee’s revoked_by

trainings_run

Reverse Manager for members.Training’s trainer

user_permissions

Reverse Manager for accounts.User’s user_permissions

verification_codes

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

verification_events

Reverse Manager for events.OrgBillingVerificationEvent’s verified_by

workdayentries

Reverse Manager for events.Event2019’s workday_entered_by

wpibox

IntegerField(verbose_name=”WPI Box Number”, blank=True, null=True)

xfer_initiated

Reverse Manager for events.OrganizationTransfer’s initiator

xfer_new

Reverse Manager for events.OrganizationTransfer’s new_user_in_charge

xfer_old

Reverse Manager for events.OrganizationTransfer’s old_user_in_charge

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

User-specific settings

Parameters:
  • id (AutoField) – Id (required)
  • user (OneToOneField to User) – User (required)
  • theme (CharField) – Theme (default=default)
  • rt_token (CharField) – Rt auth token
exception DoesNotExist
exception MultipleObjectsReturned
get_theme_display(*, field=<django.db.models.fields.CharField: theme>)
id

AutoField(verbose_name=”ID”, primary_key=True, serialize=False, auto_created=True)

objects = <django.db.models.manager.Manager object>
rt_token

CharField(verbose_name=”RT Auth Token”, max_length=256, blank=True, null=True)

theme

CharField(max_length=12, default=”default”, choices=[(‘default’, ‘Default’)])

user

OneToOneField(related_name=”preferences”, on_delete=CASCADE(), to= User)

user_id

Raw (integer) FK for user

accounts.models.officer_img_cleanup(sender, instance, **kwargs)[source]

When an instance of OfficerImg is deleted, delete the respective files as well.

Parameters:instance – An OfficerImg instance
accounts.models.path_and_rename(instance, filename)[source]

Determine path for storing officer headshots. Will rename with officer’s username.

Parameters:
  • instance – An OfficerImg instance
  • filename – The original name of the uploaded file
Returns:

New path to save file to


Views

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

Lists active LNL members

accounts_disabled_column = False
name = 'Active List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.AllMembersList(**kwargs)[source]

Lists all LNL members

accounts_disabled_column = False
name = 'All Members List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.AlumniList(**kwargs)[source]

Lists LNL alumni

accounts_disabled_column = False
name = 'Alumni List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.AssociateList(**kwargs)[source]

Lists associate LNL members

accounts_disabled_column = False
name = 'Associate List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.AwayList(**kwargs)[source]

Lists LNL members on away status

accounts_disabled_column = False
name = 'Away List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.BaseUserList(**kwargs)[source]

Basic structure for user lists

context_object_name = 'users'
get_context_data(**kwargs)[source]

Get the context for this view.

model

alias of accounts.models.User

name = 'User List'
perms = ['accounts.view_user']
template_name = 'users.html'
class accounts.views.InactiveList(**kwargs)[source]

Lists inactive LNL members

accounts_disabled_column = True
name = 'Inactive List'
perms = ['accounts.view_member']
positions = False
queryset
class accounts.views.LimboList(**kwargs)[source]

Lists unassociated users

accounts_disabled_column = False
name = 'Users without Association'
positions = False
queryset
class accounts.views.MeDirectView(**kwargs)[source]

Redirects to a user’s profile page

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

Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.

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

Lists LNL officers

accounts_disabled_column = False
name = 'Officer List'
perms = ['accounts.view_member']
positions = True
queryset
class accounts.views.PasswordSetView(**kwargs)[source]

Set a non-SSO login password

dispatch(request, pk, *args, **kwargs)[source]
form_valid(form)[source]

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

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of accounts.models.User

template_name = 'form_crispy.html'
user = None
class accounts.views.UserAddView(**kwargs)[source]

Add a new user manually (should rarely be used - LDAP does this for us)

form_class

alias of accounts.forms.UserAddForm

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of accounts.models.User

perms = 'accounts.add_user'
template_name = 'form_crispy.html'
class accounts.views.UserDetailView(**kwargs)[source]

View user profile

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

model

alias of accounts.models.User

perms = ['accounts.view_user']
slug_field = 'username'
slug_url_kwarg = 'username'
template_name = 'userdetail.html'
user_passes_test(request, *args, **kwargs)[source]
class accounts.views.UserUpdateView(**kwargs)[source]

Update user profile

form_class

alias of accounts.forms.UserEditForm

form_valid(form)[source]

If the form is valid, save the associated model.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of accounts.models.User

perms = 'accounts.change_user'
slug_field = 'username'
slug_url_kwarg = 'username'
template_name = 'form_crispy_cbv.html'
user_passes_test(request, *args, **kwargs)[source]
accounts.views.application_scope_request(request)[source]

Prompt the user to allow applications connected to the LNLDB to interact with one another. Redirects to the application’s callback uri.

accounts.views.mdc(request)[source]

Displays a list of radio MDCs for LNL members

accounts.views.mdc_raw(request)[source]

Downloads a CSV file containing the radio MDCs of LNL members

accounts.views.officer_photos(request, pk=None)[source]

Update officer headshot (displayed on the main LNL website about page)

accounts.views.secretary_dashboard(request)[source]

Dashboard for the secretary. Lists important member counts used in voting and suggests users to activate, deactivate, associate, or take off away status.

accounts.views.shame(request)[source]

The LNL Crew Chief Report Hall of Shame. Tracks members who fail to complete event reports and lists the top 10 on a leaderboard.

accounts.views.smart_login(request)[source]

Intelligent signin handler. Presents the Sign in with Microsoft option if enabled. If already logged in, redirects to the requested page (can be used to check for an active session). Also checks for the Prefer SAML cookie and automatically attempts to log in via Microsoft SSO if present. Falls back on Django’s native login form otherwise.


Forms

class accounts.forms.LoginForm(*args, **kwargs)[source]
base_fields = {'password': <django.forms.fields.CharField object>, 'username': <django.contrib.auth.forms.UsernameField object>}
declared_fields = {'password': <django.forms.fields.CharField object>, 'username': <django.contrib.auth.forms.UsernameField object>}
media
class accounts.forms.OfficerPhotoForm(*args, **kwargs)[source]
class Meta[source]
fields = ['img']
model

alias of accounts.models.OfficerImg

base_fields = {'img': <django.forms.fields.ImageField object>}
declared_fields = {}
media
class accounts.forms.SMSOptInForm(*args, **kwargs)[source]
class Meta[source]
fields = ('phone', 'carrier')
model

alias of accounts.models.User

base_fields = {'carrier': <django.forms.fields.ChoiceField object>, 'phone': <django.forms.fields.CharField object>}
declared_fields = {'carrier': <django.forms.fields.ChoiceField object>, 'phone': <django.forms.fields.CharField object>}
media
class accounts.forms.UserAddForm(*args, **kwargs)[source]
class Meta[source]
fields = ['username', 'email', 'first_name', 'last_name']
model

alias of accounts.models.User

base_fields = {'email': <django.forms.fields.EmailField 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>}
clean_password2()[source]
declared_fields = {'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>}
error_messages = {'password_mismatch': "The two password fields didn't match."}
media
save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class accounts.forms.UserEditForm(*args, **kwargs)[source]
class FieldAccess[source]
edit_groups = <data.forms.FieldAccessLevel object>
edit_mdc = <data.forms.FieldAccessLevel object>
edit_student_id = <data.forms.FieldAccessLevel object>
hasperm = <data.forms.FieldAccessLevel object>
thisisme = <data.forms.FieldAccessLevel object>
unaffiliated = <data.forms.FieldAccessLevel object>
class Meta[source]
fields = ['username', 'email', 'first_name', 'last_name', 'nickname', 'groups', 'addr', 'wpibox', 'mdc', 'phone', 'class_year', 'student_id', 'away_exp', 'carrier', 'title']
model

alias of accounts.models.User

base_fields = {'addr': <django.forms.fields.CharField object>, 'away_exp': <django.forms.fields.DateField object>, 'carrier': <django.forms.fields.TypedChoiceField object>, 'class_year': <django.forms.fields.IntegerField object>, 'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'last_name': <django.forms.fields.CharField object>, 'mdc': <django.forms.fields.CharField object>, 'nickname': <django.forms.fields.CharField object>, 'phone': <django.forms.fields.CharField object>, 'student_id': <django.forms.fields.IntegerField object>, 'title': <django.forms.fields.CharField object>, 'username': <django.forms.fields.CharField object>, 'wpibox': <django.forms.fields.IntegerField object>}
clean_student_id()[source]
declared_fields = {}
media