Models
Club
¶
Bases: Model
The Club class, made as a tree to allow nice tidy organization.
president()
¶
Fetch the membership of the current president of this club.
check_loop()
¶
Raise a validation error when a loop is found within the parent list.
Source code in club/models.py
is_owned_by(user)
¶
Method to see if that object can be super edited by the given user.
can_be_edited_by(user)
¶
can_be_viewed_by(user)
¶
get_membership_for(user)
¶
Return the current membership the given user.
Note
The result is cached.
Source code in club/models.py
MembershipQuerySet
¶
Bases: QuerySet
ongoing()
¶
board()
¶
Filter all memberships where the user is/was in the board.
Be aware that users who were in the board in the past are included, even if there are no more members.
If you want to get the users who are currently in the board,
mind combining this with the :meth:ongoing
queryset method
Source code in club/models.py
update(**kwargs)
¶
Refresh the cache and edit group ownership.
Update the cache, when necessary, remove users from club groups they are no more in and add them in the club groups they should be in.
Be aware that this adds three db queries : one to retrieve the updated memberships, one to perform group removal and one to perform group attribution.
Source code in club/models.py
delete()
¶
Work just like the default Django's delete() method, but add a cache invalidation for the elements of the queryset before the deletion, and a removal of the user from the club groups.
Be aware that this adds some db queries :
- 1 to retrieve the deleted elements in order to perform post-delete operations. As we can't know if a delete will affect rows or not, this query will always happen
- 1 query to remove the users from the club groups. If the delete operation affected no row, this query won't happen.
Source code in club/models.py
Membership
¶
Bases: Model
The Membership class makes the connection between User and Clubs.
Both Users and Clubs can have many Membership objects
- a user can be a member of many clubs at a time
- a club can have many members at a time too
A User is currently member of all the Clubs where its Membership has an end_date set to null/None. Otherwise, it's a past membership kept because it can be very useful to see who was in which Club in the past.
Mailing
¶
Bases: Model
A Mailing list for a club.
Warning
Remember that mailing lists should be validated by UTBM.
MailingSubscription
¶
Bases: Model
Link between user and mailing list.