UserProperties¶
Qualified name: intranet.apps.users.models.UserProperties
- class intranet.apps.users.models.UserProperties(id, user, _address, self_show_pictures, parent_show_pictures, self_show_address, parent_show_address, self_show_telephone, parent_show_telephone, self_show_eighth, parent_show_eighth, self_show_schedule, parent_show_schedule)[source]¶
Bases:
Model
- Parameters:
id (AutoField) – Primary key: ID
self_show_pictures (BooleanField) – Self show pictures
parent_show_pictures (BooleanField) – Parent show pictures
self_show_address (BooleanField) – Self show address
parent_show_address (BooleanField) – Parent show address
self_show_telephone (BooleanField) – Self show telephone
parent_show_telephone (BooleanField) – Parent show telephone
self_show_eighth (BooleanField) – Self show eighth
parent_show_eighth (BooleanField) – Parent show eighth
self_show_schedule (BooleanField) – Self show schedule
parent_show_schedule (BooleanField) – Parent show schedule
Relationship fields:
- Parameters:
user (
OneToOneField
toUser
) – User (related name:properties
)_address (
OneToOneField
toAddress
) – address (related name:userproperties
)_schedule (
ManyToManyField
toSection
) –schedule (related name:
_students
)User preference permissions (privacy options) When setting permissions, use set_permission(permission, value , parent=False) The permission attribute should be the part after “self_” or “parent_”
e.g. show_pictures
If you’re setting permission of the student, but the parent permission is false, the method will fail and return False.
To define a new permission, just create two new BooleanFields in the same pattern as below.
Methods
Checks if attribute is visible to public (ignoring whether the user sending the HTTP request has permission to access it).
Checks privacy options to see if an attribute is visible to the user sending the current HTTP request.
Checks if a user the HTTP request sender (accessing own info)
Sets permission for personal information.
Attributes
id
Type:
AutoField
objects
parent_show_address
Type:
BooleanField
parent_show_eighth
Type:
BooleanField
parent_show_pictures
Type:
BooleanField
parent_show_schedule
Type:
BooleanField
parent_show_telephone
Type:
BooleanField
self_show_address
Type:
BooleanField
self_show_eighth
Type:
BooleanField
self_show_pictures
Type:
BooleanField
self_show_schedule
Type:
BooleanField
self_show_telephone
Type:
BooleanField
user
Type:
OneToOneField
toUser
user_id
Internal field, use
user
instead.- _current_user_override() bool [source]¶
Return whether the currently logged in user is a teacher, and can view all of a student’s information regardless of their privacy settings.
- Returns:
Whether the currently logged in user can view all of a student’s information regardless of their privacy settings.
- _schedule¶
Type:
ManyToManyField
toSection
schedule (related name:
_students
)User preference permissions (privacy options) When setting permissions, use set_permission(permission, value , parent=False) The permission attribute should be the part after “self_” or “parent_”
e.g. show_pictures
If you’re setting permission of the student, but the parent permission is false, the method will fail and return False.
To define a new permission, just create two new BooleanFields in the same
- attribute_is_public(permission: str) bool [source]¶
Checks if attribute is visible to public (ignoring whether the user sending the HTTP request has permission to access it).
- Parameters:
permission – The name of the permission to check.
- Returns:
Whether the given permission is public.
- attribute_is_visible(permission: str) bool [source]¶
Checks privacy options to see if an attribute is visible to the user sending the current HTTP request.
- Parameters:
permission – The name of the permission to check.
- Returns:
Whether the user sending the current HTTP request has permission to view the given permission.
- is_http_request_sender() bool [source]¶
Checks if a user the HTTP request sender (accessing own info)
Used primarily to load private personal information from the cache. (A student should see all info on his or her own profile regardless of how the permissions are set.)
- Returns:
Whether the user is the sender of the current HTTP request.
- set_permission(permission: str, value: bool, parent: bool = False, admin: bool = False) bool [source]¶
Sets permission for personal information.
Returns False silently if unable to set permission. Returns True if successful.
- Parameters:
permission – The name of the permission to set.
value – The value to set the permission to.
parent – Whether to set the parent’s permission instead of the student’s permission. If
parent
isTrue
andvalue
isFalse
, both the parent and the student’s permissions will be set toFalse
.admin – If set to
True
, this will allow changing the student’s permission even if the parent’s permission is set toFalse
(normally, this causes an error).