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
TheEighthBlock
during which anEighthActivity
has been scheduled- activity¶
The scheduled
EighthActivity
- members¶
The
User
s who have signed up for anEighthBlock
- 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¶
EighthSponsor
s that will override theEighthActivity
’s default sponsors
- rooms¶
EighthRoom
s that will override theEighthActivity
’s default rooms
- attendance_taken¶
Whether the
EighthSponsor
for the scheduledEighthActivity
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:
id (AutoField) – Primary key: ID
created_time (DateTimeField) – Created time
last_modified_time (DateTimeField) – Last modified time
admin_comments (CharField) – Admin comments
title (CharField) – Title
comments (CharField) – Comments
capacity (SmallIntegerField) – Capacity
both_blocks (BooleanField) – Both blocks
special (BooleanField) – Special
administrative (BooleanField) – Administrative
restricted (BooleanField) – Restricted
sticky (BooleanField) – Sticky
attendance_taken (BooleanField) – Attendance taken
cancelled (BooleanField) – Cancelled
archived_member_count (SmallIntegerField) – Archived member count
Relationship fields:
- Parameters:
block (
ForeignKey
toEighthBlock
) – Block (related name:eighthscheduledactivity
)activity (
ForeignKey
toEighthActivity
) – Activity (related name:eighthscheduledactivity
)members (
ManyToManyField
toUser
) – Members (related name:eighthscheduledactivity_set
)waitlist (
ManyToManyField
toUser
) – Waitlist (related name:eighthscheduledactivity_scheduledactivity_set
)sticky_students (
ManyToManyField
toUser
) – Sticky students (related name:sticky_scheduledactivity_set
)sponsors (
ManyToManyField
toEighthSponsor
) – Sponsors (related name:eighthscheduledactivity
)rooms (
ManyToManyField
toEighthRoom
) – Rooms (related name:eighthscheduledactivity
)
Reverse relationships:
- Parameters:
eighthsignup_set (Reverse
ForeignKey
fromEighthSignup
) – All eighthsignup set of this eighth scheduled activity (related name ofscheduled_activity
)eighthwaitlist_set (Reverse
ForeignKey
fromEighthWaitlist
) – All eighthwaitlist set of this eighth scheduled activity (related name ofscheduled_activity
)event (Reverse
ForeignKey
fromEvent
) – All events of this eighth scheduled activity (related name ofscheduled_activity
)
Methods
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 an EighthScheduledActivity and send a notification email to signed-up students.
Returns whether this scheduled activity is administrative.
Returns a QuerySet of all the rooms associated with either this EighthScheduledActivity or its EighthActivity.
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.Retrieves the name of this activity's account with the finance office, if any.
Returns a QuerySet of the members that you do not have permission to view.
Gets whether this scheduled activity is restricted.
Returns whether this scheduled activity is special.
Retrieves the capacity for the scheduled activity, taking into account activity defaults and overrides.
Retrieves the rooms for the scheduled activity, taking into account activity defaults and overrides.
Retrieves the sponsors for the scheduled activity, taking into account activity defaults and overrides.
Returns a QuerySet of the members that you have permission to view, sorted alphabetically.
Given a request, returns an unsorted QuerySet of the members that the requesting user has permission to view.
Returns whether there are passes that have not been acknowledged.
Check if the scheduled activity or activity is sticky
Returns whether the scheduled activity is almost full (>=90%).
Gets whether this scheduled activity runs both blocks.
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 the activity is overbooked (>100%) capacity.
Returns whether it is too early to sign up for the activity if it is a presign.
Check if the given user is stickied to this activity.
Notifies all users on the given EighthWaitlist objects that the activity they are on the waitlist for has an open spot.
save
Save model without saving a historical record
Sets the given users to the sticky students list for this activity.
Uncancel an EighthScheduledActivity.
Returns whether the given user is a sponsor of the activity.
Attributes
Type:
ForeignKey
toEighthActivity
activity_id
Internal field, use
activity
instead.Type:
CharField
administrative
Type:
BooleanField
archived_member_count
Type:
SmallIntegerField
Type:
BooleanField
block
Type:
ForeignKey
toEighthBlock
block_id
Internal field, use
block
instead.Type:
BooleanField
Type:
BooleanField
capacity
Type:
SmallIntegerField
Type:
CharField
eighthsignup_set
Type: Reverse
ForeignKey
fromEighthSignup
eighthwaitlist_set
Type: Reverse
ForeignKey
fromEighthWaitlist
event_set
Type: Reverse
ForeignKey
fromEvent
Gets the full title for the activity, appending the title of the scheduled activity to the activity's name.
history
id
Type:
AutoField
Type:
ManyToManyField
toUser
objects
restricted
Type:
BooleanField
Type:
ManyToManyField
toEighthRoom
Type:
BooleanField
Type:
ManyToManyField
toEighthSponsor
sticky
Type:
BooleanField
sticky_students
Type:
ManyToManyField
toUser
title
Type:
CharField
Gets the title for the activity, appending the title of the scheduled activity to the activity's name and flags.
waitlist
Type:
ManyToManyField
toUser
- _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.
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.