Views
OperationLog
¶
Bases: Model
General purpose log object to register operations.
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
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
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 |
Customer
¶
Bases: Model
Customer data of a User.
It adds some basic customers' information, such as the account ID, and is used by other accounting classes as reference to the customer, rather than using User.
can_buy: bool
property
¶
Check if whether this customer has the right to purchase any item.
This must be not confused with the Product.can_be_sold_to(user) method as the present method returns an information about a customer whereas the other tells something about the relation between a User (not a Customer, don't mix them) and a Product.
save(*args, allow_negative=False, is_selling=False, **kwargs)
¶
is_selling : tell if the current action is a selling allow_negative : ignored if not a selling. Allow a selling to put the account in negative Those two parameters avoid blocking the save method of a customer if his account is negative.
Source code in counter/models.py
get_or_create(user)
classmethod
¶
Work in pretty much the same way as the usual get_or_create method, but with the default field replaced by some under the hood.
If the user has an account, return it as is. Else create a new account with no money on it and a new unique account id
Example : ::
user = User.objects.get(pk=1)
account, created = Customer.get_or_create(user)
if created:
print(f"created a new account with id {account.id}")
else:
print(f"user has already an account, with {account.id} € on it"
Source code in counter/models.py
ForumMessageMeta
¶
Bases: Model
MergeForm
¶
Bases: Form
SelectUserForm
¶
Bases: Form
MergeUsersView
¶
Bases: FormView
DeleteAllForumUserMessagesView
¶
Bases: FormView
Delete all forum messages from an user.
Messages are soft deleted and are still visible from admins GUI frontend to the dedicated command.
OperationLogListView
¶
Bases: ListView
, CanEditPropMixin
List all logs.
__merge_subscriptions(u1, u2)
¶
Give all the subscriptions of the second user to first one.
If some subscriptions are still active, update their end date to increase the overall subscription time of the first user.
Some examples : - if u1 is not subscribed, his subscription end date become the one of u2 - if u1 is subscribed but not u2, nothing happen - if u1 is subscribed for, let's say, 2 remaining months and u2 is subscribed for 3 remaining months, he shall then be subscribed for 5 months
Source code in rootplace/views.py
__merge_pictures(u1, u2)
¶
Source code in rootplace/views.py
merge_users(u1, u2)
¶
Merge u2 into u1.
This means that u1 shall receive everything that belonged to u2 :
- pictures
- refills of the sith account
- purchases of any item bought on the eboutic or the counters
- subscriptions
- godfathers
- godchildren
If u1 had no account id, he shall receive the one of u2. If u1 and u2 were both in the middle of a subscription, the remaining durations stack If u1 had no profile picture, he shall receive the one of u2
Source code in rootplace/views.py
delete_all_forum_user_messages(user, moderator, *, verbose=False)
¶
Soft delete all messages of a user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
User
|
core.models.User the user to delete messages from |
required |
moderator
|
User
|
core.models.User the one marked as the moderator. |
required |
verbose
|
bool
|
bool if True, print the deleted messages |
False
|