EighthActivity¶
Qualified name: intranet.apps.eighth.models.EighthActivity
- class intranet.apps.eighth.models.EighthActivity(*args, **kwargs)[source]¶
Bases:
AbstractBaseEighthModel
Represents an eighth period activity. .. attribute:: name
The name of the activity, max length 100 characters.
- type:
str
- description¶
The description of the activity, shown on the signup page below the other information. Information on an EighthScheduledActivity basis can be found in the “comments” field of that model. Max length 2000 characters.
- Type:
- sponsors¶
The default activity-level sponsors for the activity. On an EighthScheduledActivity basis, you should NOT query this field. Instead, use scheduled_activity.get_true_sponsors()
- Type:
- rooms¶
The default activity-level rooms for the activity. On an EighthScheduledActivity basis, you should NOT query this field. Use scheduled_activity.get_true_rooms()
- Type:
list
ofEighthRoom
- default_capacity¶
The default capacity, which overrides the sum of the default rooms when scheduling the activity. By default, this has a null value and is ignored.
- Type:
- presign¶
If True, the activity can only be signed up for within 2 days of the day that the activity is scheduled.
- Type:
- one_a_day¶
If True, a student can only sign up for one instance of this activity per day.
- Type:
- 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.
- Type:
- sticky¶
If True, then students who sign up or are placed in this activity cannot switch out of it. A sticky activity should also be restricted, unless you’re mean.
- Type:
- special¶
If True, then the activity receives a special designation on the signup list, and is stuck to the top of the list.
- Type:
- administrative¶
If True, then students cannot see the activity in their signup list. However, the activity still exists in the system and can be seen by administrators. Students can still sign up for the activity through the API – this does not prevent students from signing up for it, and just merely hides it from view. An administrative activity should be restricted.
- Type:
- finance¶
The account name of the club with the Finance Office. If blank or null, there is no account.
- Type:
- restricted¶
Whether the signups for the activity are restricted to certain users/groups or if there are blacklisted users.
- Type:
- users_allowed¶
Individual users allowed to sign up for this activity. Extensive use of this is discouraged; make a group instead through the “Add and Assign Empty Group” button on the Edit Activity page. Only takes effect if the activity is restricted.
- Type:
list
ofUser
- groups_allowed¶
Individual groups allowed to sign up for this activity. Only takes effect if the activity is restricted.
- Type:
list
ofGroup
- users_blacklisted¶
Individual users who are not allowed to sign up for this activity. Only takes effect if the activity is not restricted.
- Type:
list
ofUser
- freshman_allowed¶
Whether freshmen are allowed to sign up for this activity. Only takes effect if the activity is restricted.
- Type:
- sophomores_allowed¶
Whether sophomores are allowed to sign up for this activity. Only takes effect if the activity is restricted.
- Type:
- juniors_allowed¶
Whether juniors are allowed to sign up for this activity. Only takes effect if the activity is restricted.
- Type:
- seniors_allowed¶
Whether seniors are allowed to sign up for this activity. Only takes effect if the activity is restricted.
- Type:
- wed_a¶
Whether the activity generally meets on Wednesday A blocks. Does not affect schedule, is just information for the Eighth Office.
- Type:
- wed_b¶
Whether the activity generally meets on Wednesday B blocks. Does not affect schedule, is just information for the Eighth Office.
- Type:
- fri_a¶
Whether the activity generally meets on Friday A blocks. Does not affect schedule, is just information for the Eighth Office.
- Type:
- fri_b¶
Whether the activity generally meets on Friday B blocks. Does not affect schedule, is just information for the Eighth Office.
- Type:
- similarities¶
A ManyToManyField of EighthActivitySimilarity objects which are similar to this activity.
- Type:
- deleted¶
Whether the activity still technically exists in the system, but was marked to be deleted.
- Type:
- Parameters:
id (AutoField) – Primary key: ID
created_time (DateTimeField) – Created time
last_modified_time (DateTimeField) – Last modified time
name (CharField) – Name
description (CharField) – Description
default_capacity (SmallIntegerField) – Default capacity
presign (BooleanField) – Presign
one_a_day (BooleanField) – One a day
both_blocks (BooleanField) – Both blocks
sticky (BooleanField) – Sticky
special (BooleanField) – Special
administrative (BooleanField) – Administrative
finance (CharField) – Finance
restricted (BooleanField) – Restricted
freshmen_allowed (BooleanField) – Freshmen allowed
sophomores_allowed (BooleanField) – Sophomores allowed
juniors_allowed (BooleanField) – Juniors allowed
seniors_allowed (BooleanField) – Seniors allowed
wed_a (BooleanField) – Meets Wednesday A
wed_b (BooleanField) – Meets Wednesday B
fri_a (BooleanField) – Meets Friday A
fri_b (BooleanField) – Meets Friday B
subscriptions_enabled (BooleanField) – Subscriptions enabled
admin_comments (CharField) – Admin comments
deleted (BooleanField) – Deleted
Relationship fields:
- Parameters:
sponsors (
ManyToManyField
toEighthSponsor
) – Sponsors (related name:eighthactivity
)rooms (
ManyToManyField
toEighthRoom
) – Rooms (related name:eighthactivity
)users_allowed (
ManyToManyField
toUser
) – Users allowed (related name:restricted_activity_set
)groups_allowed (
ManyToManyField
toGroup
) – Groups allowed (related name:restricted_activity_set
)users_blacklisted (
ManyToManyField
toUser
) – Users blacklisted (related name:eighthactivity
)subscribers (
ManyToManyField
toUser
) – Subscribers (related name:subscribed_activity_set
)officers (
ManyToManyField
toUser
) – Officers (related name:officer_for_set
)club_sponsors (
ManyToManyField
toUser
) – Club sponsors (related name:club_sponsor_for_set
)favorites (
ManyToManyField
toUser
) – Favorites (related name:favorited_activity_set
)similarities (
ManyToManyField
toEighthActivitySimilarity
) – Similarities (related name:activity_set
)
Reverse relationships:
- Parameters:
announcement (Reverse
ForeignKey
fromAnnouncement
) – All announcements of this eighth activity (related name ofactivity
)eighthblock (Reverse
ManyToManyField
fromEighthBlock
) – All eighth blocks of this eighth activity (related name ofactivities
)eighthscheduledactivity (Reverse
ForeignKey
fromEighthScheduledActivity
) – All eighth scheduled activities of this eighth activity (related name ofactivity
)
Methods
Returns all available IDs not used by an EighthActivity.
Returns 'default_capacity' if it is set.
Removes any subscribers who are not allowed to subscribe to the activity.
Returns all EighthScheduledActivitys scheduled this year for this activity.
Returns whether a user can subscribe to the activity.
Finds the restricted activities available to the given user.
Save model without saving a historical record
Attributes
Type:
CharField
Type:
BooleanField
The publicly visible activity ID.
announcement_set
Type: Reverse
ForeignKey
fromAnnouncement
Type:
BooleanField
club_sponsors
Type:
ManyToManyField
toUser
Type:
SmallIntegerField
Type:
BooleanField
Type:
CharField
eighthblock_set
Type: Reverse
ManyToManyField
fromEighthBlock
eighthscheduledactivity_set
Type: Reverse
ForeignKey
fromEighthScheduledActivity
Type:
ManyToManyField
toUser
Type:
CharField
Return a QuerySet of user id's and counts that have signed up for this activity more than settings.SIMILAR_THRESHOLD times.
freshmen_allowed
Type:
BooleanField
Type:
BooleanField
Type:
BooleanField
Type:
ManyToManyField
toGroup
history
id
Type:
AutoField
Returns whether an activity is "active." An activity is considered to be active if it has been scheduled at all this year. Returns: Whether the activity is active.
Returns whether this activity has more than
settings.SIMILAR_THRESHOLD * 2
frequent_users.Type:
BooleanField
name
Type:
CharField
Return the activity name with special, both blocks, restricted, administrative, sticky, and deleted flags.
Returns the activity's name with flags. These flags indicate whether the activity is special, both blocks, administrative, sticky, and/or cancelled. Returns: The activity name with all flags except the "restricted" flag.
objects
Type:
ManyToManyField
toUser
Type:
BooleanField
Type:
BooleanField
Type:
BooleanField
Type:
ManyToManyField
toEighthRoom
Type:
BooleanField
Type:
ManyToManyField
toEighthActivitySimilarity
Type:
BooleanField
Type:
BooleanField
Type:
ManyToManyField
toEighthSponsor
Type:
BooleanField
Type:
ManyToManyField
toUser
subscriptions_enabled
Type:
BooleanField
undeleted_objects
Type:
ManyToManyField
toUser
Type:
ManyToManyField
toUser
Type:
BooleanField
Type:
BooleanField
- _name_with_flags(include_restricted: bool, title: str | None = None) str [source]¶
Generates the activity’s name with flags. :param include_restricted: Whether to include the “restricted” flag. :param title: An optional title to add after the activity name (but before the flags)
- Returns:
The activity name with all the appropriate flags.
- classmethod available_ids() List[int] [source]¶
Returns all available IDs not used by an EighthActivity. :returns: A list of the available activity IDs.
- capacity() int [source]¶
Returns ‘default_capacity’ if it is set. Otherwise, returns the total capacity of all the activity’s rooms. :returns: The activity’s capacity.
- clean_subscribers()[source]¶
Removes any subscribers who are not allowed to subscribe to the activity.
- property frequent_users: QuerySet | Collection[User]¶
Return a QuerySet of user id’s and counts that have signed up for this activity more than settings.SIMILAR_THRESHOLD times. This is used for suggesting activities to users. :returns: A QuerySet of users who attend this activity frequently.
- get_active_schedulings() QuerySet | Collection[EighthScheduledActivity] [source]¶
Returns all EighthScheduledActivitys scheduled this year for this activity. :returns: EighthScheduledActivitys of this activity occurring this year.
- property is_active: bool¶
Returns whether an activity is “active.” An activity is considered to be active if it has been scheduled at all this year.
- Returns:
Whether the activity is active.
- property is_popular: bool¶
Returns whether this activity has more than
settings.SIMILAR_THRESHOLD * 2
frequent_users. :returns: Whether this activity has more thansettings.SIMILAR_THRESHOLD * 2
frequent_users.
- is_subscribable_for_user(user) bool [source]¶
Returns whether a user can subscribe to the activity.
- Parameters:
user – The user to check.
- Returns:
Whether the user can subscribe to the activity.
- property name_with_flags: str¶
Return the activity name with special, both blocks, restricted, administrative, sticky, and deleted flags. :returns: The activity name with all flags.
- property name_with_flags_no_restricted: str¶
Returns the activity’s name with flags. These flags indicate whether the activity is special, both blocks, administrative, sticky, and/or cancelled.
- Returns:
The activity name with all flags except the “restricted” flag.
- classmethod restricted_activities_available_to_user(user: User) List[int] [source]¶
Finds the restricted activities available to the given user. :param user: The User to find the restricted activities for.
- Returns:
The restricted activities available to the user.
- 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.