User

Qualified name: intranet.apps.users.models.User

class intranet.apps.users.models.User(*args, **kwargs)[source]

Bases: AbstractBaseUser, PermissionsMixin

Django User model subclass

Parameters:

Relationship fields:

Parameters:
  • counselor (ForeignKey to User) – Counselor (related name: students)

  • preferred_photo (OneToOneField to Photo) – Preferred photo (related name: +)

  • primary_email (OneToOneField to Email) – Primary email (related name: +)

  • bus_route (ForeignKey to Route) – Bus route (related name: user)

  • groups (ManyToManyField to Group) – Groups. The groups this user belongs to. A user will get all permissions granted to each of their groups. (related name: user_set)

  • user_permissions (ManyToManyField to Permission) – User permissions. Specific permissions for this user. (related name: user_set)

Reverse relationships:

Parameters:

Methods

absence_count

Return the user's absence count.

absence_info

Returns a QuerySet of the ``EighthSignup``s for which this user was absent.

archive_admin_comments

can_manage_group

Checks whether this user has permission to edit/manage the given group (either a Group or a group name).

get_eighth_sponsor

Return the EighthSponsor that this user is associated with.

get_full_name

Return full name, e.g.

get_gender_display

Shows the label of the gender.

get_short_name

Get short (first) name of a user.

get_signage_user

Returns the user used to authenticate signage displays

get_title_display

Shows the label of the title.

get_user_type_display

Shows the label of the user_type.

handle_delete

Handle a graduated user being deleted.

has_admin_permission

Returns whether a user has an admin permission (explicitly, or implied by being in the "admin_all" group)

has_unvoted_polls

Returns whether there are open polls thet this user has not yet voted in.

member_of

Returns whether a user is a member of a certain group.

should_see_polls

Returns whether the user should have the Polls icon visible

signed_up_next_few_days

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks in the next num_days days.

signed_up_today

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks that are scheduled today.

Attributes

GENDER

TITLES

USERNAME_FIELD

Override default Model Manager (objects) with

USER_TYPES

address

Returns the Address object representing this user's address, or None if it is not set or the current user does not have permission to access it.

admin_comments

Type: TextField

announcement_set

Type: Reverse ForeignKey from Announcement

announcements_hidden

Type: Reverse ManyToManyField from AnnouncementUserMap

announcements_seen

Type: Reverse ManyToManyField from AnnouncementUserMap

answer_set

Type: Reverse ForeignKey from Answer

answervote_set

Type: Reverse ManyToManyField from AnswerVote

approved_event

Type: Reverse ForeignKey from Event

attending

Type: Reverse ManyToManyField from Event

bus_route

Type: ForeignKey to Route

bus_route_id

Internal field, use bus_route instead.

calculatorregistration_set

Type: Reverse ForeignKey from CalculatorRegistration

can_request_parking

Checks if user can view the parking interface.

can_view_eighth

Checks if a user has the show_eighth permission.

can_view_phone

Checks if a user has the show_telephone permission.

carapplication

Type: Reverse ForeignKey from CarApplication

club_sponsor_for_set

Type: Reverse ManyToManyField from EighthActivity

computerregistration_set

Type: Reverse ForeignKey from ComputerRegistration

counselor

Type: ForeignKey to User

counselor_id

Internal field, use counselor instead.

dark_mode_properties

Type: Reverse OneToOneField from UserDarkModeProperties

default_photo

Returns default photo (in binary) that should be used

display_name

Returns self.full_name.

eighthactivity_set

Type: Reverse ManyToManyField from EighthActivity

eighthscheduledactivity_scheduledactivity_set

Type: Reverse ManyToManyField from EighthScheduledActivity

eighthscheduledactivity_set

Type: Reverse ManyToManyField from EighthScheduledActivity

eighthsignup_set

Type: Reverse ForeignKey from EighthSignup

eighthwaitlist_set

Type: Reverse ForeignKey from EighthWaitlist

emails

Type: Reverse ForeignKey from Email

enable_april_fools

Type: BooleanField

enrichmentactivity_set

Type: Reverse ForeignKey from EnrichmentActivity

enrichments_attended

Type: Reverse ManyToManyField from EnrichmentActivity

enrichments_attending

Type: Reverse ManyToManyField from EnrichmentActivity

event_set

Type: Reverse ForeignKey from Event

events_hidden

Type: Reverse ManyToManyField from EventUserMap

favorited_activity_set

Type: Reverse ManyToManyField from EighthActivity

feature_announcements_dismissed

Type: Reverse ManyToManyField from FeatureAnnouncement

feature_announcements_seen

Type: Reverse ManyToManyField from FeatureAnnouncement

feedback_set

Type: Reverse ForeignKey from Feedback

first_login

Type: DateTimeField

first_name

Type: CharField

founditem_set

Type: Reverse ForeignKey from FoundItem

frequent_signups

Return a QuerySet of activity id's and counts for the activities that a given user has signed up for more than settings.SIMILAR_THRESHOLD times

full_name

Return full name, e.g.

full_name_nick

If the user has a nickname, returns their name in the format "Nickname Lastname." Otherwise, this is identical to full_name.

gcmnotification_set

Type: Reverse ForeignKey from GCMNotification

gender

Type: CharField

grade

Returns the grade of a user.

grade_number

Returns the number of the grade this user is currently in (9, 10, 11, or 12 for students).

graduation_year

Type: IntegerField

groups

Type: ManyToManyField to Group

has_senior

Checks if a Senior model (see intranet.apps.seniors.models.Senior exists for the current user.

id

Type: AutoField

ion_username

Returns this user's username.

is_active

Checks if the user is active.

is_alum

Checks if user is an alumnus.

is_announcements_admin

Checks if user is an announcements admin.

is_attendance_taker

Checks if this user can take attendance for an eighth activity.

is_attendance_user

Checks if user is an attendance-only user.

is_board_admin

Checks if user is a board admin.

is_bus_admin

Returns whether the user has the bus admin permission.

is_club_officer

Checks if this user is an officer of an eighth period activity.

is_club_sponsor

Used only for club announcements permissions.

is_eighth_admin

Checks if user is an eighth period admin.

is_eighth_sponsor

Determine whether the given user is associated with an.

is_eighthoffice

Checks if user is an Eighth Period office user.

is_enrichment_admin

Checks if user is an enrichment admin.

is_events_admin

Checks if user is an events admin.

is_female

Returns whether the user is female.

is_global_admin

Checks if user is a global admin.

is_male

Returns whether the user is male.

is_nonbinary

Returns whether the user is non-binary.

is_parking_admin

Checks if user has the admin permission 'parking'.

is_printing_admin

Checks if user has the admin permission 'printing'.

is_restricted

Checks if user needs the restricted view of Ion

is_schedule_admin

Checks if user is a schedule admin.

is_senior

Checks if user is a student in Grade 12.

is_simple_user

Checks if user is a simple user (e.g.

is_staff

Checks if a user should have access to the Django Admin interface.

is_student

Checks if user is a student.

is_teacher

Checks if user is a teacher.

last_first

Return a name in the format of: Lastname, Firstname [(Nickname)]

last_first_id

Return a name in the format of: Lastname, Firstname [(Nickname)] (Student ID/ID/Username)

last_first_initial

Return a name in the format of: Lastname, F [(Nickname)]

last_global_logout_time

Type: DateTimeField

last_name

Type: CharField

logentry_set

Type: Reverse ForeignKey from LogEntry

lostitem_set

Type: Reverse ForeignKey from LostItem

middle_name

Type: CharField

nickname

Type: CharField

nomination_votes

Type: Reverse ForeignKey from Nomination

nomination_votes_received

Type: Reverse ForeignKey from Nomination

non_tj_email

Returns the user's first non-TJ email found, or None if none is found.

notification_email

Returns the notification email.

notificationconfig

Type: Reverse OneToOneField from NotificationConfig

oauth2_provider_accesstoken

Type: Reverse ForeignKey from AccessToken

oauth2_provider_grant

Type: Reverse ForeignKey from Grant

oauth2_provider_idtoken

Type: Reverse ForeignKey from IDToken

oauth2_provider_refreshtoken

Type: Reverse ForeignKey from RefreshToken

oauth_and_api_access

Type: BooleanField

oauth_cslapplication

Type: Reverse ForeignKey from CSLApplication

objects

officer_for_set

Type: Reverse ManyToManyField from EighthActivity

parkingapplication

Type: Reverse ForeignKey from ParkingApplication

parkingapplication_joint

Type: Reverse ForeignKey from ParkingApplication

permissions

Dynamically generate dictionary of privacy options.

phoneregistration_set

Type: Reverse ForeignKey from PhoneRegistration

phones

Type: Reverse ForeignKey from Phone

photos

Type: Reverse ForeignKey from Photo

posted_by

Type: Reverse ForeignKey from AnnouncementRequest

preferred_photo

Type: OneToOneField to Photo

preferred_photo_id

Internal field, use preferred_photo instead.

primary_email

Type: OneToOneField to Email

primary_email_address

primary_email_id

Internal field, use primary_email instead.

printjob_set

Type: Reverse ForeignKey from PrintJob

properties

Type: Reverse OneToOneField from UserProperties

receive_eighth_emails

Type: BooleanField

receive_news_emails

Type: BooleanField

receive_schedule_notifications

Type: BooleanField

recommended_activities

rejected_by

Type: Reverse ForeignKey from AnnouncementRequest

rejected_event

Type: Reverse ForeignKey from Event

request_set

Type: Reverse ForeignKey from Request

restricted_activity_set

Type: Reverse ManyToManyField from EighthActivity

schedule

Returns a QuerySet of the Section objects representing the classes this student is in, or None if the current user does not have permission to list this student's classes.

section_set

Type: Reverse ForeignKey from Section

seen_april_fools

Type: BooleanField

seen_welcome

Type: BooleanField

senior

Type: Reverse OneToOneField from Senior

senioremailforward_set

Type: Reverse ForeignKey from SeniorEmailForward

sex

Returns the gender of this user (male, female, or non-binary).

short_name

Return short name (first name) of a user.

sponsor_obj

Type: Reverse OneToOneField from EighthSponsor

sticky_scheduledactivity_set

Type: Reverse ManyToManyField from EighthScheduledActivity

student_id

Type: CharField

students

Type: Reverse ForeignKey from User

subscribed_activity_set

Type: Reverse ManyToManyField from EighthActivity

teachers_approved

Type: Reverse ManyToManyField from AnnouncementRequest

teachers_requested

Type: Reverse ManyToManyField from AnnouncementRequest

title

Type: CharField

tj_email

Get (or guess) a user's TJ email.

tjstaruuidmap_set

Type: Reverse ForeignKey from TJStarUUIDMap

trustedsession_set

Type: Reverse ForeignKey from TrustedSession

user

Type: Reverse ForeignKey from AnnouncementRequest

user_locked

Type: BooleanField

user_permissions

Type: ManyToManyField to Permission

user_type

Type: CharField

username

Type: CharField

websites

Type: Reverse ForeignKey from Website

USERNAME_FIELD = 'username'

Override default Model Manager (objects) with

_current_user_override() bool[source]

Return whether the currently logged in user is a teacher or eighth admin, and can view all of a student’s information regardless of their privacy settings.

Returns:

Whether the user has permissions to view all of their information regardless of their privacy settings.

absence_count() int[source]

Return the user’s absence count.

If the user has no absences or is not a signup user, returns 0.

Returns:

The number of absences this user has.

absence_info()[source]

Returns a QuerySet of the ``EighthSignup``s for which this user was absent.

Returns:

A QuerySet of the ``EighthSignup``s for which this user was absent.

property address: Address | None

Returns the Address object representing this user’s address, or None if it is not set or the current user does not have permission to access it.

Returns:

The Address representing this user’s address, or None if that is unavailable to the current user.

can_manage_group(group: Group | str) bool[source]

Checks whether this user has permission to edit/manage the given group (either a Group or a group name).

WARNING: Granting permission to edit/manage “admin_” groups gives that user control over nearly all data on Ion!

Parameters:

group – The group to check permissions for.

Returns:

Whether this user has permission to edit/manage the given group.

property can_request_parking: bool

Checks if user can view the parking interface.

Returns:

Whether this user can view the parking interface and request a parking spot.

property can_view_eighth: bool

Checks if a user has the show_eighth permission.

Returns:

Whether this user has made their eighth period signups public.

property can_view_phone: bool

Checks if a user has the show_telephone permission.

Returns:

Whether this user has made their phone number public.

property default_photo: bytes | None

Returns default photo (in binary) that should be used

Returns:

The binary representation of the user’s default photo.

property display_name: str

Returns self.full_name.

Returns:

The user’s full name.

property frequent_signups

Return a QuerySet of activity id’s and counts for the activities that a given user has signed up for more than settings.SIMILAR_THRESHOLD times

property full_name: str

Return full name, e.g. Angela William.

This is required for subclasses of User.

Returns:

The user’s full name (first + “ “ + last).

property full_name_nick: str

If the user has a nickname, returns their name in the format “Nickname Lastname.” Otherwise, this is identical to full_name.

Returns:

The user’s full name, with their nickname substituted for their first name if it is set.

get_eighth_sponsor()[source]

Return the EighthSponsor that this user is associated with.

Returns:

The EighthSponsor that this user is associated with.

get_full_name() str[source]

Return full name, e.g. Angela William.

Returns:

The user’s full name (see full_name).

get_short_name() str[source]

Get short (first) name of a user.

Returns:

The user’s first name (see short_name and first_name).

static get_signage_user() User[source]

Returns the user used to authenticate signage displays

Returns:

The user used to authenticate signage displays

property grade: Grade

Returns the grade of a user.

Returns:

A Grade object representing the user’s current grade.

property grade_number: int

Returns the number of the grade this user is currently in (9, 10, 11, or 12 for students).

Returns:

The number of the grade this user is currently in.

handle_delete()[source]

Handle a graduated user being deleted.

has_admin_permission(perm: str) bool[source]

Returns whether a user has an admin permission (explicitly, or implied by being in the “admin_all” group)

Parameters:

perm – The admin permission to check for.

Returns:

Whether the user has the given admin permission (either explicitly or implicitly)

property has_senior: bool

Checks if a Senior model (see intranet.apps.seniors.models.Senior exists for the current user.

Returns:

Whether a Senior model (see intranet.apps.seniors.models.Senior exists for the current user.

has_unvoted_polls() bool[source]

Returns whether there are open polls thet this user has not yet voted in.

Returns:

Whether there are open polls thet this user has not yet voted in.

property ion_username: str

Returns this user’s username.

Returns:

This user’s username (see username).

property is_active: bool

Checks if the user is active.

This is currently used to catch invalid logins.

Returns:

Whether the user is “active” – i.e. their account is not locked.

property is_alum: bool

Checks if user is an alumnus.

Returns:

Whether this user is an alumnus.

property is_announcements_admin: bool

Checks if user is an announcements admin.

Returns:

Whether this user is an announcement admin.

property is_attendance_taker: bool

Checks if this user can take attendance for an eighth activity.

Returns:

Whether this user can take attendance for an eighth activity.

property is_attendance_user: bool

Checks if user is an attendance-only user.

Returns:

Whether this user is an attendance-only user.

property is_board_admin: bool

Checks if user is a board admin.

Returns:

Whether this user is a board admin.

property is_bus_admin: bool

Returns whether the user has the bus admin permission.

Returns:

Whether the user has the bus admin permission.

property is_club_officer: bool

Checks if this user is an officer of an eighth period activity.

Returns:

Whether this user is an officer of an eighth period activity.

property is_club_sponsor: bool

Used only for club announcements permissions. Not used for eighth period scheduling. Use User.is_eighth_sponsor for that instead.

property is_eighth_admin: bool

Checks if user is an eighth period admin.

Returns:

Whether this user is an eighth period admin.

property is_eighth_sponsor: bool

Determine whether the given user is associated with an.

intranet.apps.eighth.models.EighthSponsor and, therefore, should view activity sponsoring information.

Returns:

Whether this user is an eighth period sponsor.

property is_eighthoffice: bool

Checks if user is an Eighth Period office user.

This is currently hardcoded, but is meant to be used instead of user.id == 9999 or user.username == “eighthoffice”.

Returns:

Whether this user is an Eighth Period office user.

property is_enrichment_admin: bool

Checks if user is an enrichment admin.

Returns:

Whether this user is an enrichment admin.

property is_events_admin: bool

Checks if user is an events admin.

Returns:

Whether this user is an events admin.

property is_female: bool

Returns whether the user is female.

Returns:

Whether this user is female.

property is_global_admin: bool

Checks if user is a global admin.

Returns:

Whether this user is a global admin, defined as having admin_all, Django staff, and Django superuser.

property is_male: bool

Returns whether the user is male.

Returns:

Whether this user is male.

property is_nonbinary: bool

Returns whether the user is non-binary.

Returns:

Whether this user is non-binary.

property is_parking_admin: bool

Checks if user has the admin permission ‘parking’.

Returns:

Whether this user is a parking administrator.

property is_printing_admin: bool

Checks if user has the admin permission ‘printing’.

Returns:

Whether this user is a printing administrator.

property is_restricted: bool

Checks if user needs the restricted view of Ion

This applies to users that are user_type ‘user’, user_type ‘alum’ or user_type ‘service’

Returns:

Whether this user should see a restricted view of Ion.

property is_schedule_admin: bool

Checks if user is a schedule admin.

Returns:

Whether this user is a schedule admin.

property is_senior: bool

Checks if user is a student in Grade 12.

Returns:

Whether this user is a senior.

property is_simple_user: bool

Checks if user is a simple user (e.g. eighth office user)

Returns:

Whether this user is a simple user (e.g. eighth office user).

property is_staff: bool

Checks if a user should have access to the Django Admin interface.

This has nothing to do with staff at TJ - is_staff has to be overridden to make this a valid user model.

Returns:

Whether the user should have access to the Django Admin interface.

property is_student: bool

Checks if user is a student.

Returns:

Whether this user is a student.

property is_teacher: bool

Checks if user is a teacher.

Returns:

Whether this user is a teacher.

property last_first: str

Return a name in the format of: Lastname, Firstname [(Nickname)]

property last_first_id: str

Return a name in the format of: Lastname, Firstname [(Nickname)] (Student ID/ID/Username)

property last_first_initial: str

Return a name in the format of: Lastname, F [(Nickname)]

member_of(group: Group | str) bool[source]

Returns whether a user is a member of a certain group.

Parameters:

group – Either the name of a group or a Group object.

Returns:

Whether the user is a member of the given group.

property non_tj_email: str | None

Returns the user’s first non-TJ email found, or None if none is found.

If a user has a primary email set and it is not their TJ email, use that. Otherwise, use the first email found that is not their TJ email.

Returns:

The first non-TJ email found for a user, or None if no such email is found.

property notification_email: str

Returns the notification email.

If a primary email is set, use it. Otherwise, use the first email on file. If no email addresses exist, use the user’s TJ email.

Returns:

A user’s notification email address.

property permissions: Dict[str, bool]

Dynamically generate dictionary of privacy options.

Returns:

A dictionary mapping the name of each privacy option to a boolean indicating whether it is enabled.

property schedule: QuerySet | Collection[Section] | None

Returns a QuerySet of the Section objects representing the classes this student is in, or None if the current user does not have permission to list this student’s classes.

Returns:

Returns a QuerySet of the Section objects representing the classes this student is in, or None if the current user does not have permission to list this student’s classes.

property sex: str

Returns the gender of this user (male, female, or non-binary).

Returns:

The gender of this user (male, female, or non-binary).

property short_name: str

Return short name (first name) of a user.

This is required for subclasses of User.

Returns:

The user’s fist name.

should_see_polls() bool[source]

Returns whether the user should have the Polls icon visible

signed_up_next_few_days(*, num_days: int = 3) bool[source]

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks in the next num_days days. Otherwise, returns True.

Today is counted as a day, so signed_up_few_next_day(num_days=1) is equivalent to signed_up_today().

Parameters:

num_days – The number of days (including today) on which to search for blocks during which the user is signed up.

Returns:

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks in the next num_days days. Otherwise, returns True.

signed_up_today() bool[source]

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks that are scheduled today. Otherwise, returns True.

Returns:

If the user is a student, returns whether they are signed up for an activity during all eighth period blocks that are scheduled today. Otherwise, returns True.

property tj_email: str

Get (or guess) a user’s TJ email.

If a fcps.edu or tjhsst.edu email is specified in their email list, use that. Otherwise, append the user’s username to the proper email suffix, depending on whether they are a student or teacher.

Returns:

The user’s found or guessed FCPS/TJ email address.