Views
GenericContentPermissionMixinBuilder
¶
Bases: View
Used to build permission mixins.
This view protect any child view that would be showing an object that is restricted based on two properties.
Attributes:
Name | Type | Description |
---|---|---|
raised_error |
permission to be raised |
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. |
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 |
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. |
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. |
UserIsRootMixin
¶
Bases: GenericContentPermissionMixinBuilder
Allow only root admins.
Raises:
Type | Description |
---|---|
PermissionDenied
|
if the user isn't root |
FormerSubscriberMixin
¶
Bases: AccessMixin
Check if the user was at least an old subscriber.
Raises:
Type | Description |
---|---|
PermissionDenied
|
if the user never subscribed. |
SubscriberMixin
¶
Bases: AccessMixin
TabedViewMixin
¶
Bases: View
Basic functions for displaying tabs in the template.
QuickNotifMixin
¶
get_context_data(**kwargs)
¶
Add quick notifications to context.
Source code in core/views/__init__.py
DetailFormView
¶
Bases: SingleObjectMixin
, FormView
Class that allow both a detail view and a form view.
get_object()
¶
SithFile
¶
Bases: Model
clean()
¶
Cleans up the file.
Source code in core/models.py
apply_rights_recursively(*, only_folders=False)
¶
Apply the rights of this file to all children recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
only_folders
|
bool
|
If True, only apply the rights to SithFiles that are folders. |
False
|
Source code in core/models.py
copy_rights()
¶
Copy, if possible, the rights of the parent folder.
move_to(parent)
¶
Move a file to a new parent.
parent
must be a SithFile with the is_folder=True
property. Otherwise, this function doesn't change
anything.
This is done only at the DB level, so that it's very fast for the user. Indeed, this function doesn't modify
SithFiles recursively, so it stays efficient even with top-level folders.
Source code in core/models.py
MultipleFileInput
¶
Bases: ClearableFileInput
MultipleFileField(*args, **kwargs)
¶
MultipleImageField(*args, **kwargs)
¶
AddFilesForm
¶
Bases: Form
FileListView
¶
Bases: ListView
FileEditView
¶
Bases: CanEditMixin
, UpdateView
FileEditPropForm
¶
Bases: ModelForm
FileEditPropView
¶
Bases: CanEditPropMixin
, UpdateView
FileView
¶
Bases: CanViewMixin
, DetailView
, FormMixin
Handle the upload of new files into a folder.
handle_clipboard(request, obj)
staticmethod
¶
Handle the clipboard in the view.
This method can fail, since it does not catch the exceptions coming from below, allowing proper handling in the calling view. Use this method like this:
FileView.handle_clipboard(request, self.object)
request
is usually the self.request obj in your view
obj
is the SithFile object you want to put in the clipboard, or
where you want to paste the clipboard
Source code in core/views/files.py
FileDeleteView
¶
Bases: CanEditPropMixin
, DeleteView
FileModerationView
¶
Bases: TemplateView
FileModerateView
¶
Bases: CanEditPropMixin
, SingleObjectMixin
RealGroup
¶
Bases: Group
RealGroups are created by the developer.
Most of the time they match a number in settings to be easily used for permissions.
EditMembersForm(*args, **kwargs)
¶
Bases: Form
Add and remove members from a Group.
Source code in core/views/group.py
GroupListView
¶
Bases: CanEditMixin
, ListView
Displays the Group list.
GroupEditView
¶
Bases: CanEditMixin
, UpdateView
Edit infos of a Group.
GroupCreateView
¶
Bases: CanCreateMixin
, CreateView
Add a new Group.
GroupTemplateView
¶
Bases: CanEditMixin
, DetailFormView
Display all users in a given Group Allow adding and removing users from it.
GroupDeleteView
¶
Bases: CanEditMixin
, DeleteView
Delete a Group.
LockError
¶
Bases: Exception
There was a lock error on the object.
Page
¶
Bases: Model
The page class to build a Wiki
Each page may have a parent and it's URL is of the form my.site/page/
Be careful with the _full_name attribute: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when playing with a Page object, use get_full_name() instead!
save(*args, **kwargs)
¶
Performs some needed actions before and after saving a page in database.
Source code in core/models.py
get_page_by_full_name(name)
staticmethod
¶
Quicker to get a page with that method rather than building the request every time.
clean()
¶
Cleans up only the name for the moment, but this can be used to make any treatment before saving the object.
Source code in core/models.py
is_locked()
¶
Is True if the page is locked, False otherwise.
This is where the timeout is handled, so a locked page for which the timeout is reach will be unlocked and this function will return False.
Source code in core/models.py
set_lock(user)
¶
Sets a lock on the current page or raise an AlreadyLocked exception.
Source code in core/models.py
set_lock_recursive(user)
¶
unset_lock_recursive()
¶
unset_lock()
¶
get_lock()
¶
Returns the page's mutex containing the time and the user in a dict.
get_full_name()
¶
Computes the real full_name of the page based on its name and its parent's name You can and must rely on this function when working on a page object that is not freshly fetched from the DB (For example when treating a Page object coming from a form).
Source code in core/models.py
PageRev
¶
Bases: Model
True content of the page.
Each page object has a revisions field that is a list of PageRev, ordered by date. my_page.revisions.last() gives the PageRev object that is the most up-to-date, and thus, is the real content of the page. The content is in PageRev.title and PageRev.content .
CanEditPagePropMixin
¶
Bases: CanEditPropMixin
PageListView
¶
Bases: CanViewMixin
, ListView
PageView
¶
Bases: CanViewMixin
, DetailView
PageHistView
¶
Bases: CanViewMixin
, DetailView
PageRevView
¶
Bases: CanViewMixin
, DetailView
PageCreateView
¶
Bases: CanCreateMixin
, CreateView
PagePropView
¶
Bases: CanEditPagePropMixin
, UpdateView
PageEditViewBase
¶
Bases: CanEditMixin
, UpdateView
PageEditView
¶
Bases: PageEditViewBase
PageDeleteView
¶
Bases: CanEditPagePropMixin
, DeleteView
Notification
¶
Bases: Model
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
NotificationList
¶
Bases: ListView
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
Gift
¶
Bases: Model
Preferences
¶
Bases: Model
SithLoginView
¶
Bases: LoginView
The login View.
SithPasswordChangeView
¶
Bases: PasswordChangeView
Allows a user to change its password.
SithPasswordChangeDoneView
¶
Bases: PasswordChangeDoneView
Allows a user to change its password.
SithPasswordResetView
¶
Bases: PasswordResetView
Allows someone to enter an email address for resetting password.
SithPasswordResetDoneView
¶
Bases: PasswordResetDoneView
Confirm that the reset email has been sent.
SithPasswordResetConfirmView
¶
Bases: PasswordResetConfirmView
Provide a reset password form.
SithPasswordResetCompleteView
¶
Bases: PasswordResetCompleteView
Confirm the password has successfully been reset.
UserCreationView
¶
Bases: FormView
UserTabsMixin
¶
Bases: TabedViewMixin
UserView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
Display a user's profile.
UserPicturesView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
Display a user's pictures.
UserGodfathersView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
, FormView
Display a user's godfathers.
UserGodfathersTreeView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
Display a user's family tree.
UserStatsView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
Display a user's stats.
UserMiniView
¶
Bases: CanViewMixin
, DetailView
Display a user's profile.
UserListView
¶
Bases: ListView
, CanEditPropMixin
Displays the user list.
UserUpdateProfileView
¶
Bases: UserTabsMixin
, CanEditMixin
, UpdateView
Edit a user's profile.
remove_restricted_fields(request)
¶
Removes edit_once and board_only fields.
Source code in core/views/user.py
UserClubView
¶
Bases: UserTabsMixin
, CanViewMixin
, DetailView
Display the user's club(s).
UserPreferencesView
¶
Bases: UserTabsMixin
, CanEditMixin
, UpdateView
Edit a user's preferences.
UserUpdateGroupView
¶
Bases: UserTabsMixin
, CanEditPropMixin
, UpdateView
Edit a user's groups.
UserToolsView
¶
Bases: LoginRequiredMixin
, QuickNotifMixin
, UserTabsMixin
, TemplateView
Displays the logged user's tools.
UserAccountBase
¶
Bases: UserTabsMixin
, DetailView
Base class for UserAccount.
UserAccountView
¶
Bases: UserAccountBase
Display a user's account.
UserAccountDetailView
¶
Bases: UserAccountBase
, YearMixin
, MonthMixin
Display a user's account for month.
GiftCreateView
¶
Bases: CreateView
GiftDeleteView
¶
Bases: CanEditPropMixin
, DeleteView
forbidden(request, exception)
¶
Source code in core/views/__init__.py
not_found(request, exception)
¶
internal_servor_error(request)
¶
can_edit_prop(obj, user)
¶
Can the user edit the properties of the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
Object to test for permission |
required |
user
|
User
|
core.models.User to test permissions against |
required |
Returns:
Type | Description |
---|---|
bool
|
True if user is authorized to edit object properties else False |
Examples:
Source code in core/views/__init__.py
can_edit(obj, user)
¶
Can the user edit the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
Object to test for permission |
required |
user
|
User
|
core.models.User to test permissions against |
required |
Returns:
Type | Description |
---|---|
bool
|
True if user is authorized to edit object else False |
Examples:
Source code in core/views/__init__.py
can_view(obj, user)
¶
Can the user see the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
Object to test for permission |
required |
user
|
User
|
core.models.User to test permissions against |
required |
Returns:
Type | Description |
---|---|
bool
|
True if user is authorized to see object else False |
Examples:
Source code in core/views/__init__.py
send_file(request, file_id, file_class=SithFile, file_attr='file')
¶
Send a protected file, if the user can see it.
In prod, the server won't handle the download itself, but set the appropriate headers in the response to make the reverse-proxy deal with it. In debug mode, the server will directly send the file.
Source code in core/views/files.py
index(request, context=None)
¶
notification(request, notif_id)
¶
Source code in core/views/site.py
search_user(query)
¶
Source code in core/views/site.py
search_club(query, *, as_json=False)
¶
Source code in core/views/site.py
search_view(request)
¶
search_user_json(request)
¶
search_json(request)
¶
logout(request)
¶
password_root_change(request, user_id)
¶
Allows a root user to change someone's password.