Views
Club
¶
Bases: Model
The Club class, made as a tree to allow nice tidy organization.
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)
¶
can_be_edited_by(user)
¶
can_be_viewed_by(user)
¶
Method to see if that object can be seen by the given user.
get_membership_for(user)
¶
Return the current membership the given user.
Note
The result is cached.
Source code in club/models.py
User
¶
Bases: AbstractBaseUser
Defines the base user class, useable in every app.
This is almost the same as the auth module AbstractUser since it inherits from it, but some fields are required, and the username is generated automatically with the name of the user (see generate_username()).
Added field: nick_name, date_of_birth Required fields: email, first_name, last_name, date_of_birth
cached_groups: list[Group]
property
¶
Get the list of groups this user is in.
The result is cached for the default duration (should be 5 minutes)
Returns: A list of all the groups this user is in.
is_in_group(*, pk=None, name=None)
¶
Check if this user is in the given group. Either a group id or a group name must be provided. If both are passed, only the id will be considered.
The group will be fetched using the given parameter. If no group is found, return False. If a group is found, check if this user is in the latter.
Returns:
Type | Description |
---|---|
bool
|
True if the user is the group, else False |
Source code in core/models.py
age()
¶
Return the age this user has the day the method is called. If the user has not filled his age, return 0.
Source code in core/models.py
get_full_name()
¶
get_short_name()
¶
get_display_name()
¶
Returns the display name of the user.
A nickname if possible, otherwise, the full name.
get_age()
¶
get_family(godfathers_depth=4, godchildren_depth=4)
¶
Get the family of the user, with the given depth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
godfathers_depth
|
NonNegativeInt
|
The number of generations of godfathers to fetch |
4
|
godchildren_depth
|
NonNegativeInt
|
The number of generations of godchildren to fetch |
4
|
Returns:
Type | Description |
---|---|
set[through]
|
A list of family relationships in this user's family |
Source code in core/models.py
email_user(subject, message, from_email=None, **kwargs)
¶
Sends an email to this User.
generate_username()
¶
Generates a unique username based on the first and last names.
For example: Guy Carlier gives gcarlier, and gcarlier1 if the first one exists.
Returns:
Type | Description |
---|---|
str
|
The generated username. |
Source code in core/models.py
is_owner(obj)
¶
Determine if the object is owned by the user.
Source code in core/models.py
can_edit(obj)
¶
Determine if the object can be edited by the user.
Source code in core/models.py
can_view(obj)
¶
Determine if the object can be viewed by the user.
Source code in core/models.py
clubs_with_rights()
¶
The list of clubs where the user has rights
CanCreateMixin
¶
Bases: View
Protect any child view that would create an object.
Raises:
Type | Description |
---|---|
PermissionDenied
|
If the user has not the necessary permission to create the object of the view. |
CanEditMixin
¶
Bases: GenericContentPermissionMixinBuilder
Ensure the user has permission to edit this view's object.
Raises:
Type | Description |
---|---|
PermissionDenied
|
if the user cannot edit this view's object. |
CanEditPropMixin
¶
Bases: GenericContentPermissionMixinBuilder
Ensure the user has owner permissions on the child view object.
In other word, you can make a view with this view as parent,
and it will be retricted to the users that are in the
object's owner_group or that pass the obj.can_be_viewed_by
test.
Raises:
Type | Description |
---|---|
PermissionDenied
|
If the user cannot see the object |
CanViewMixin
¶
Bases: GenericContentPermissionMixinBuilder
Ensure the user has permission to view this view's object.
Raises:
Type | Description |
---|---|
PermissionDenied
|
if the user cannot edit this view's object. |
QuickNotifMixin
¶
get_context_data(**kwargs)
¶
Add quick notifications to context.
Source code in core/views/__init__.py
TabedViewMixin
¶
Bases: View
Basic functions for displaying tabs in the template.
Trombi
¶
Bases: Model
Main class of the trombi, the Trombi itself.
It contains the deadlines for the users, and the link to the club that makes its Trombi.
TrombiClubMembership
¶
Bases: Model
A membership in a club.
TrombiComment
¶
Bases: Model
A comment given by someone to someone else in the same Trombi instance.
TrombiUser
¶
Bases: Model
Bound between a User
and a Trombi
.
This class is here to avoid cross-references between the core, club, and trombi modules. It also adds the pictures to the profile without needing all the security like the other SithFiles.
TrombiTabsMixin
¶
Bases: TabedViewMixin
UserIsInATrombiMixin
¶
Bases: View
Check if the requested user has a trombi_user attribute.
TrombiForm
¶
Bases: ModelForm
TrombiCreateView
¶
Bases: CanCreateMixin
, CreateView
Create a trombi for a club.
post(request, *args, **kwargs)
¶
Affect club.
Source code in trombi/views.py
TrombiEditView
¶
Bases: CanEditPropMixin
, TrombiTabsMixin
, UpdateView
AddUserForm
¶
Bases: Form
TrombiDetailView
¶
Bases: CanEditMixin
, QuickNotifMixin
, TrombiTabsMixin
, DetailView
TrombiExportView
¶
Bases: CanEditMixin
, TrombiTabsMixin
, DetailView
TrombiDeleteUserView
¶
Bases: CanEditPropMixin
, TrombiTabsMixin
, DeleteView
TrombiModerateCommentsView
¶
Bases: CanEditPropMixin
, QuickNotifMixin
, TrombiTabsMixin
, DetailView
TrombiModerateForm
¶
Bases: Form
TrombiModerateCommentView
¶
Bases: DetailView
TrombiModelChoiceField
¶
Bases: ModelChoiceField
UserTrombiForm
¶
Bases: Form
UserTrombiToolsView
¶
Bases: LoginRequiredMixin
, QuickNotifMixin
, TrombiTabsMixin
, TemplateView
Display a user's trombi tools.
UserTrombiEditPicturesView
¶
Bases: TrombiTabsMixin
, UserIsInATrombiMixin
, UpdateView
UserTrombiEditProfileView
¶
Bases: QuickNotifMixin
, TrombiTabsMixin
, UserIsInATrombiMixin
, UpdateView
UserTrombiResetClubMembershipsView
¶
Bases: UserIsInATrombiMixin
, RedirectView
UserTrombiDeleteMembershipView
¶
Bases: TrombiTabsMixin
, CanEditMixin
, DeleteView
UserTrombiAddMembershipView
¶
Bases: TrombiTabsMixin
, CreateView
UserTrombiEditMembershipView
¶
Bases: CanEditMixin
, TrombiTabsMixin
, UpdateView
UserTrombiProfileView
¶
Bases: TrombiTabsMixin
, DetailView
TrombiCommentFormView
¶
Bases: LoginRequiredMixin
, View
Create/edit a trombi comment.
TrombiCommentCreateView
¶
Bases: TrombiCommentFormView
, CreateView
TrombiCommentEditView
¶
Bases: TrombiCommentFormView
, CanViewMixin
, UpdateView