EighthScheduledActivity

Qualified name: intranet.apps.eighth.models.EighthScheduledActivity

class intranet.apps.eighth.models.EighthScheduledActivity(*args, **kwargs)[source]

Bases: AbstractBaseEighthModel

Represents the relationship between an activity and a block in which it has been scheduled. .. attribute:: block

EighthBlock The EighthBlock during which an EighthActivity has been scheduled

activity

The scheduled EighthActivity

members

The Users who have signed up for an EighthBlock

both_blocks

If True, a signup for an EighthScheduledActivity during an A or B block will enforce and automatically trigger a signup on the other block. Does not enforce signups for blocks other than A and B.

comments

Notes for students

admin_comments

Notes for the Eighth Office

sponsors

EighthSponsors that will override the EighthActivity’s default sponsors

rooms

EighthRooms that will override the EighthActivity’s default rooms

attendance_taken

Whether the EighthSponsor for the scheduled EighthActivity has taken attendance yet

special

Whether this scheduled instance of the activity is special. If not set, falls back on the EighthActivity’s special setting.

cancelled

whether the EighthScheduledActivity has been cancelled

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

Methods

add_user

Signs up a user to this scheduled activity if possible. This is where the magic happens. Raises an exception if there's a problem signing the user up unless the signup is forced and the requesting user has permission. :param user: The user to add to the scheduled activity. :param request: The request object associated with the signup action. Should always be passed if applicable, as some information is extracted from the request. :param force: Whether to force the signup. :param no_after_deadline: Whether to mark the user as not having signed up after the deadline, regardless of whether they did or not. :param add_to_waitlist: Explicitly add the user to the waitlist.

cancel

Cancel an EighthScheduledActivity and send a notification email to signed-up students.

get_administrative

Returns whether this scheduled activity is administrative.

get_all_associated_rooms

Returns a QuerySet of all the rooms associated with either this EighthScheduledActivity or its EighthActivity.

get_both_blocks_sibling

If this is a both-blocks activity, get the other EighthScheduledActivity object that occurs on the other block. both_blocks means A and B block, NOT all of the blocks on that day. :returns: EighthScheduledActivity object if found. None, if the activity cannot have a sibling.

get_finance

Retrieves the name of this activity's account with the finance office, if any.

get_hidden_members

Returns a QuerySet of the members that you do not have permission to view.

get_restricted

Gets whether this scheduled activity is restricted.

get_special

Returns whether this scheduled activity is special.

get_true_capacity

Retrieves the capacity for the scheduled activity, taking into account activity defaults and overrides.

get_true_rooms

Retrieves the rooms for the scheduled activity, taking into account activity defaults and overrides.

get_true_sponsors

Retrieves the sponsors for the scheduled activity, taking into account activity defaults and overrides.

get_viewable_members

Returns a QuerySet of the members that you have permission to view, sorted alphabetically.

get_viewable_members_serializer

Given a request, returns an unsorted QuerySet of the members that the requesting user has permission to view.

has_open_passes

Returns whether there are passes that have not been acknowledged.

is_activity_sticky

Check if the scheduled activity or activity is sticky

is_almost_full

Returns whether the scheduled activity is almost full (>=90%).

is_both_blocks

Gets whether this scheduled activity runs both blocks.

is_full

Returns whether the scheduled activity is full. :param nocache: Whether to disable caching for the query that checks the scheduled activity's current capacity.

is_overbooked

Returns whether the activity is overbooked (>100%) capacity.

is_too_early_to_signup

Returns whether it is too early to sign up for the activity if it is a presign.

is_user_stickied

Check if the given user is stickied to this activity.

notify_waitlist

Notifies all users on the given EighthWaitlist objects that the activity they are on the waitlist for has an open spot.

save

save_without_historical_record

Save model without saving a historical record

set_sticky_students

Sets the given users to the sticky students list for this activity.

uncancel

Uncancel an EighthScheduledActivity.

user_is_sponsor

Returns whether the given user is a sponsor of the activity.

Attributes

activity

Type: ForeignKey to EighthActivity

activity_id

Internal field, use activity instead.

admin_comments

Type: CharField

administrative

Type: BooleanField

archived_member_count

Type: SmallIntegerField

attendance_taken

Type: BooleanField

block

Type: ForeignKey to EighthBlock

block_id

Internal field, use block instead.

both_blocks

Type: BooleanField

cancelled

Type: BooleanField

capacity

Type: SmallIntegerField

comments

Type: CharField

eighthsignup_set

Type: Reverse ForeignKey from EighthSignup

eighthwaitlist_set

Type: Reverse ForeignKey from EighthWaitlist

event_set

Type: Reverse ForeignKey from Event

full_title

Gets the full title for the activity, appending the title of the scheduled activity to the activity's name.

history

id

Type: AutoField

members

Type: ManyToManyField to User

objects

restricted

Type: BooleanField

rooms

Type: ManyToManyField to EighthRoom

special

Type: BooleanField

sponsors

Type: ManyToManyField to EighthSponsor

sticky

Type: BooleanField

sticky_students

Type: ManyToManyField to User

title

Type: CharField

title_with_flags

Gets the title for the activity, appending the title of the scheduled activity to the activity's name and flags.

waitlist

Type: ManyToManyField to User

_get_viewable_members(user: User) QuerySet | Collection[User][source]

Get an unsorted QuerySet of the members that you have permission to view. :param user: The user who is attempting to view the member list.

Returns:

Unsorted QuerySet of the members that you have permission to view.

add_user(user: AbstractBaseUser, request: HttpRequest | None = None, force: bool = False, no_after_deadline: bool = False, add_to_waitlist: bool = False)[source]

Signs up a user to this scheduled activity if possible. This is where the magic happens. Raises an exception if there’s a problem signing the user up unless the signup is forced and the requesting user has permission. :param user: The user to add to the scheduled activity. :param request: The request object associated with the signup action. Should always be passed if applicable,

as some information is extracted from the request.

Parameters:
  • force – Whether to force the signup.

  • no_after_deadline – Whether to mark the user as not having signed up after the deadline, regardless of whether they did or not.

  • add_to_waitlist – Explicitly add the user to the waitlist.

cancel()[source]

Cancel an EighthScheduledActivity and send a notification email to signed-up students. This method should be always be called instead of setting the ‘cancelled’ flag manually. (Note: To avoid spamming students signed up for both-block activities, an email is not sent for the B-block activity in both-block activities.)

property full_title: str

Gets the full title for the activity, appending the title of the scheduled activity to the activity’s name. :returns: The full title for the scheduled activity, without flags.

get_administrative() bool[source]

Returns whether this scheduled activity is administrative. :returns: Whether this activity is administrative

get_all_associated_rooms() QuerySet | Collection[EighthRoom][source]

Returns a QuerySet of all the rooms associated with either this EighthScheduledActivity or its EighthActivity. :returns: A QuerySet of all the rooms associated with either this EighthScheduledActivity or its EighthActivity.

get_both_blocks_sibling() EighthScheduledActivity | None[source]

If this is a both-blocks activity, get the other EighthScheduledActivity object that occurs on the other block. both_blocks means A and B block, NOT all of the blocks on that day. :returns: EighthScheduledActivity object if found.

None, if the activity cannot have a sibling.

get_finance() str[source]

Retrieves the name of this activity’s account with the finance office, if any. :returns: The name of this activity’s account with the finance office.

get_hidden_members(user: User | None = None) QuerySet | Collection[User][source]

Returns a QuerySet of the members that you do not have permission to view. :param user: The user who is attempting to view the member list.

Returns:

Unsorted QuerySet of the members that you do not have permission to view.

get_restricted() bool[source]

Gets whether this scheduled activity is restricted. :returns: Whether this scheduled activity is restricted.

get_special() bool[source]

Returns whether this scheduled activity is special. :returns: Whether this scheduled activity is special.

get_true_capacity() int[source]

Retrieves the capacity for the scheduled activity, taking into account activity defaults and overrides. :returns: The true capacity of the scheduled activity.

get_true_rooms() QuerySet | Collection[EighthRoom][source]

Retrieves the rooms for the scheduled activity, taking into account activity defaults and overrides. :returns: The true room list of the scheduled activity.

get_true_sponsors() QuerySet | Collection[EighthSponsor][source]

Retrieves the sponsors for the scheduled activity, taking into account activity defaults and overrides. :returns: The sponsors for this scheduled activity.

get_viewable_members(user: User | None = None) QuerySet | Collection[User][source]

Returns a QuerySet of the members that you have permission to view, sorted alphabetically. :param user: The user who is attempting to view the member list.

Returns:

QuerySet of the members that you have permission to view, sorted alphabetically.

get_viewable_members_serializer(request) QuerySet | Collection[User][source]

Given a request, returns an unsorted QuerySet of the members that the requesting user has permission to view. :param request: The request object associated with the member list query.

Returns:

Unsorted QuerySet of the members that you have permission to view.

has_open_passes() bool[source]

Returns whether there are passes that have not been acknowledged. :returns: Whether this activity has open passes.

is_activity_sticky() bool[source]

Check if the scheduled activity or activity is sticky

Warning

This method does NOT take into account individual user stickies. In 99.9% of cases, you should use is_user_stickied() instead.

is_almost_full() bool[source]

Returns whether the scheduled activity is almost full (>=90%). :returns: Whether this scheduled activity is at least 90% full.

is_both_blocks() bool[source]

Gets whether this scheduled activity runs both blocks. :returns: Whether this scheduled activity runs both blocks.

is_full(nocache: bool = False) bool[source]

Returns whether the scheduled activity is full. :param nocache: Whether to disable caching for the query that checks the scheduled activity’s

current capacity.

Returns:

Whether this scheduled activity is full.

is_overbooked() bool[source]

Returns whether the activity is overbooked (>100%) capacity. :returns: Whether this scheduled activity is overbooked.

is_too_early_to_signup(now: ~datetime.datetime | None = None) -> (<class 'bool'>, <module 'datetime' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/datetime.py'>)[source]

Returns whether it is too early to sign up for the activity if it is a presign. This contains the 2 day pre-signup logic. :param now: A datetime object to use for the check instead of the current time.

Returns:

Whether it is too early to sign up for this scheduled activity and when the activity opens for signups.

is_user_stickied(user: AbstractBaseUser) bool[source]

Check if the given user is stickied to this activity.

Parameters:

user – The user to check for stickiness.

notify_waitlist(waitlists: Iterable[EighthWaitlist])[source]

Notifies all users on the given EighthWaitlist objects that the activity they are on the waitlist for has an open spot. :param waitlists: The EighthWaitlist objects whose users should be notified that the activity has an open slot.

save_without_historical_record(*args, **kwargs)

Save model without saving a historical record

Make sure you know what you’re doing before you use this method.

set_sticky_students(users: Sequence[AbstractBaseUser]) None[source]

Sets the given users to the sticky students list for this activity.

This also sends emails to students.

Parameters:

users – The users to add to the sticky students list.

Returns:

A tuple of the new stickied students and the unstickied students.

property title_with_flags: str

Gets the title for the activity, appending the title of the scheduled activity to the activity’s name and flags. :returns: The full title for the scheduled activity, with flags.

uncancel()[source]

Uncancel an EighthScheduledActivity. This does nothing besides unset the cancelled flag and save the object.

user_is_sponsor(user: User) bool[source]

Returns whether the given user is a sponsor of the activity. :param user: The user to check for sponsorship of this activity.

Returns:

Whether the given user is a sponsor of the activity.