Core data models¶
-
class
aleksis.core.models.
Activity
(*args, **kwargs)[source]¶ Activity of a user to trace some actions done in AlekSIS in displayable form.
- Parameters
id (BigAutoField) – Id
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
user (ForeignKey to
Person
) – Usertitle (CharField) – Title
description (TextField) – Description
app (CharField) – Application
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
AdditionalField
(*args, **kwargs)[source]¶ An additional field that can be linked to a group.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
title (CharField) – Title of field
field_type (CharField) – Type of field
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
Announcement
(*args, **kwargs)[source]¶ Announcement model.
Persistent announcement to display to groups or persons in various places during a specific time range.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
title (CharField) – Title
description (TextField) – Description
link (URLField) – Link to detailed view
valid_from (DateTimeField) – Date and time from when to show
valid_until (DateTimeField) – Date and time until when to show
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
AnnouncementQuerySet
(model=None, query=None, using=None, hints=None)[source]¶ Queryset for announcements providing time-based utility functions.
-
class
aleksis.core.models.
AnnouncementRecipient
(*args, **kwargs)[source]¶ Announcement recipient model.
Generalisation of a recipient for an announcement, used to wrap arbitrary objects that can receive announcements.
Contract: Objects to serve as recipient have a property announcement_recipients returning a flat list of Person objects.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
announcement (ForeignKey to
Announcement
) – Announcementcontent_type (ForeignKey to
ContentType
) – Content typerecipient_id (PositiveIntegerField) – Recipient id
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
CustomMenu
(*args, **kwargs)[source]¶ A custom menu to display in the footer.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
name (CharField) – Menu id
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
CustomMenuItem
(*args, **kwargs)[source]¶ Single item in a custom menu.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
menu (ForeignKey to
CustomMenu
) – Menuname (CharField) – Name
url (URLField) – Link
icon (CharField) – Icon
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
DashboardWidget
(*args, **kwargs)[source]¶ Base class for dashboard widgets on the index page.
To implement a widget, add a model that subclasses DashboardWidget, sets the template and implements the get_context method to return a dictionary to be passed as context to the template.
If your widget does not add any database fields, you should mark it as a proxy model.
You can provide a Media meta class with custom JS and CSS files which will be added to html head. For further information on media definition see https://docs.djangoproject.com/en/3.0/topics/forms/media/
Example:
from django.forms.widgets import Media from aleksis.core.models import DashboardWidget class MyWidget(DashboardWidget): template = "myapp/widget.html" def get_context(self, request): context = {"some_content": "foo"} return context class Meta: proxy = True media = Media(css={ 'all': ('pretty.css',) }, js=('animations.js', 'actions.js') )
- Parameters
id (BigAutoField) – Id
polymorphic_ctype (ForeignKey to
ContentType
) – Polymorphic ctypetitle (CharField) – Widget title
active (BooleanField) – Activate widget
broken (BooleanField) – Widget is broken
size_s (PositiveSmallIntegerField) – Size on mobile devices. <= 600 px, 12 columns
size_m (PositiveSmallIntegerField) – Size on tablet devices. > 600 px, 12 columns
size_l (PositiveSmallIntegerField) – Size on desktop devices. > 992 px, 12 columns
size_xl (PositiveSmallIntegerField) – Size on large desktop devices. > 1200 px>, 12 columns
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
DashboardWidgetOrder
(id, site, extended_data, widget, person, order, default)[source]¶ - Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
widget (ForeignKey to
DashboardWidget
) – Dashboard widgetperson (ForeignKey to
Person
) – Personorder (PositiveIntegerField) – Order
default (BooleanField) – Part of the default dashboard
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
DataCheckResult
(*args, **kwargs)[source]¶ Save the result of a data check for a specific object.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
check (CharField) – Related data check task
content_type (ForeignKey to
ContentType
) – Content typeobject_id (CharField) – Object id
solved (BooleanField) – Issue solved
sent (BooleanField) – Notification sent
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
DummyPerson
(*args, **kwargs)[source]¶ A dummy person that is not stored into the database.
Used to temporarily inject a Person object into a User.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
user (OneToOneField to
User
) – Linked userfirst_name (CharField) – First name
last_name (CharField) – Last name
additional_name (CharField) – Additional name(s)
short_name (CharField) – Short name
street (CharField) – Street
housenumber (CharField) – Street number
postal_code (CharField) – Postal code
place (CharField) – Place
phone_number (PhoneNumberField) – Home phone
mobile_number (PhoneNumberField) – Mobile phone
email (EmailField) – E-mail address
date_of_birth (DateField) – Date of birth
place_of_birth (CharField) – Place of birth
sex (CharField) – Sex
photo (ImageField) – Photo. This is an official photo, used for official documents and for internal use cases.
avatar (ImageField) – Display picture / avatar. This is a picture or an avatar for public display.
primary_group (ForeignKey to
Group
) – Primary groupdescription (TextField) – Description
guardians (ManyToManyField) – Guardians / parents
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
ExternalLinkWidget
(id, polymorphic_ctype, title, active, broken, size_s, size_m, size_l, size_xl, dashboardwidget_ptr, url, icon_url)[source]¶ - Parameters
id (BigAutoField) – Id
polymorphic_ctype (ForeignKey to
ContentType
) – Polymorphic ctypetitle (CharField) – Widget title
active (BooleanField) – Activate widget
broken (BooleanField) – Widget is broken
size_s (PositiveSmallIntegerField) – Size on mobile devices. <= 600 px, 12 columns
size_m (PositiveSmallIntegerField) – Size on tablet devices. > 600 px, 12 columns
size_l (PositiveSmallIntegerField) – Size on desktop devices. > 992 px, 12 columns
size_xl (PositiveSmallIntegerField) – Size on large desktop devices. > 1200 px>, 12 columns
dashboardwidget_ptr (OneToOneField to
DashboardWidget
) – Dashboardwidget ptrurl (URLField) – Url
icon_url (URLField) – Icon url
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
GlobalPermissions
(*args, **kwargs)[source]¶ Container for global permissions.
- Parameters
id (BigAutoField) – Id
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
Group
(*args, **kwargs)[source]¶ Group model.
Any kind of group of persons in a school, including, but not limited classes, clubs, and the like.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
school_term (ForeignKey to
SchoolTerm
) – Linked school termname (CharField) – Long name
short_name (CharField) – Short name
group_type (ForeignKey to
GroupType
) – Type of groupphoto (ImageField) – Photo. This is an official photo, used for official documents and for internal use cases.
avatar (ImageField) – Display picture / avatar. This is a picture or an avatar for public display.
members (ManyToManyField) – Members
owners (ManyToManyField) – Owners
parent_groups (ManyToManyField) – Parent groups
additional_fields (ManyToManyField) – Additional fields
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
property
announcement_recipients
¶ Flat list of all members and owners to fulfill announcement API contract.
-
property
child_groups_recursive
¶ Get all child groups recursively.
- Return type
CTEQuerySet
-
property
django_group
¶ Get Django group for this group.
-
property
members_recursive
¶ Get all members of this group and its child groups.
- Return type
-
property
owners_recursive
¶ Get all ownerss of this group and its parent groups.
- Return type
-
property
parent_groups_recursive
¶ Get all parent groups recursively.
- Return type
CTEQuerySet
-
refresh_from_db
(using=None, fields=None)¶ Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
-
save
(force=False, *args, **kwargs)[source]¶ Ensure all functionality of our extensions that needs saving gets it.
-
save_base
(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)¶ Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
-
class
aleksis.core.models.
GroupPreferenceModel
(*args, **kwargs)[source]¶ Preference model to hold pereferences valid for members of a group.
- Parameters
id (BigAutoField) – Id
section (CharField) – Section name
name (CharField) – Name
raw_value (TextField) – Raw value
instance (ForeignKey to
Group
) – Instance
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
GroupType
(*args, **kwargs)[source]¶ Group type model.
Descriptive type of a group; used to tag groups and for apps to distinguish how to display or handle a certain group.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
name (CharField) – Title of type
description (CharField) – Description
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
Notification
(*args, **kwargs)[source]¶ Notification to submit to a user.
- Parameters
id (BigAutoField) – Id
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
sender (CharField) – Sender
recipient (ForeignKey to
Person
) – Recipienttitle (CharField) – Title
description (TextField) – Description
link (URLField) – Link
read (BooleanField) – Read
sent (BooleanField) – Sent
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
OAuthAccessToken
(*args, **kwargs)[source]¶ Placeholder for customising the AccessToken model.
- Parameters
id (BigAutoField) – Id
user (ForeignKey to
User
) – Usersource_refresh_token (OneToOneField to
OAuthRefreshToken
) – Source refresh tokentoken (CharField) – Token
id_token (OneToOneField to
OAuthIDToken
) – Id tokenapplication (ForeignKey to
OAuthApplication
) – Applicationexpires (DateTimeField) – Expires
scope (TextField) – Scope
created (DateTimeField) – Created
updated (DateTimeField) – Updated
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
OAuthApplication
(*args, **kwargs)[source]¶ Modified OAuth application class that supports Grant Flows configured in preferences.
- Parameters
id (BigAutoField) – Id
client_id (CharField) – Client id
user (ForeignKey to
User
) – Userredirect_uris (TextField) – Redirect uris. Allowed URIs list, space separated
client_type (CharField) – Client type
client_secret (CharField) – Client secret
name (CharField) – Name
skip_authorization (BooleanField) – Skip authorization
created (DateTimeField) – Created
updated (DateTimeField) – Updated
algorithm (CharField) – Algorithm
authorization_grant_type (CharField) – Authorization grant type
allowed_scopes (ArrayField) – Allowed scopes that clients can request
icon (ImageField) – Icon. This image will be shown as icon in the authorization flow. It should be squared.
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
OAuthGrant
(*args, **kwargs)[source]¶ Placeholder for customising the Grant model.
- Parameters
id (BigAutoField) – Id
user (ForeignKey to
User
) – Usercode (CharField) – Code
application (ForeignKey to
OAuthApplication
) – Applicationexpires (DateTimeField) – Expires
redirect_uri (TextField) – Redirect uri
scope (TextField) – Scope
created (DateTimeField) – Created
updated (DateTimeField) – Updated
code_challenge (CharField) – Code challenge
code_challenge_method (CharField) – Code challenge method
nonce (CharField) – Nonce
claims (TextField) – Claims
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
OAuthIDToken
(*args, **kwargs)[source]¶ Placeholder for customising the IDToken model.
- Parameters
id (BigAutoField) – Id
user (ForeignKey to
User
) – Userjti (UUIDField) – Jwt token id
application (ForeignKey to
OAuthApplication
) – Applicationexpires (DateTimeField) – Expires
scope (TextField) – Scope
created (DateTimeField) – Created
updated (DateTimeField) – Updated
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
OAuthRefreshToken
(*args, **kwargs)[source]¶ Placeholder for customising the RefreshToken model.
- Parameters
id (BigAutoField) – Id
user (ForeignKey to
User
) – Usertoken (CharField) – Token
application (ForeignKey to
OAuthApplication
) – Applicationaccess_token (OneToOneField to
OAuthAccessToken
) – Access tokencreated (DateTimeField) – Created
updated (DateTimeField) – Updated
revoked (DateTimeField) – Revoked
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
PDFFile
(*args, **kwargs)[source]¶ Link to a rendered PDF file.
- Parameters
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
Person
(*args, **kwargs)[source]¶ Person model.
A model describing any person related to a school, including, but not limited to, students, teachers and guardians (parents).
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
user (OneToOneField to
User
) – Linked userfirst_name (CharField) – First name
last_name (CharField) – Last name
additional_name (CharField) – Additional name(s)
short_name (CharField) – Short name
street (CharField) – Street
housenumber (CharField) – Street number
postal_code (CharField) – Postal code
place (CharField) – Place
phone_number (PhoneNumberField) – Home phone
mobile_number (PhoneNumberField) – Mobile phone
email (EmailField) – E-mail address
date_of_birth (DateField) – Date of birth
place_of_birth (CharField) – Place of birth
sex (CharField) – Sex
photo (ImageField) – Photo. This is an official photo, used for official documents and for internal use cases.
avatar (ImageField) – Display picture / avatar. This is a picture or an avatar for public display.
primary_group (ForeignKey to
Group
) – Primary groupdescription (TextField) – Description
guardians (ManyToManyField) – Guardians / parents
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
property
age
¶ Age of the person at current time.
-
auto_select_primary_group
(pattern=None, field=None, force=False)[source]¶ Auto-select the primary group among the groups the person is member of.
Uses either the pattern passed as argument, or the pattern configured system-wide.
Does not do anything if either no pattern is defined or the user already has a primary group, unless force is True.
- Return type
-
property
mail_sender_via
¶ E-mail sender for via addresses, in “Name via Site <email>” format.
- Return type
-
property
member_of_recursive
¶ Get all groups this person is a member of, recursively.
- Return type
-
notify_about_changed_data
(changed_fields, recipients=None)[source]¶ Notify (configured) recipients about changed data of this person.
-
property
owner_of_recursive
¶ Get all groups this person is a member of, recursively.
- Return type
-
property
primary_group_short_name
¶ Return the short_name field of the primary group related object.
-
refresh_from_db
(using=None, fields=None)¶ Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
-
save
(*args, **kwargs)[source]¶ Ensure all functionality of our extensions that needs saving gets it.
-
save_base
(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)¶ Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
-
class
aleksis.core.models.
PersonGroupThrough
(*args, **kwargs)[source]¶ Through table for many-to-many relationship of group members.
It does not have any fields on its own; these are generated upon instantiation by inspecting the additional fields selected for the linked group.
- Parameters
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
PersonInvitation
(*args, **kwargs)[source]¶ Custom model for invitations to allow to generate invitations codes without email address.
- Parameters
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
PersonPreferenceModel
(*args, **kwargs)[source]¶ Preference model to hold pereferences valid for a person.
- Parameters
id (BigAutoField) – Id
section (CharField) – Section name
name (CharField) – Name
raw_value (TextField) – Raw value
instance (ForeignKey to
Person
) – Instance
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
SchoolTerm
(*args, **kwargs)[source]¶ School term model.
This is used to manage start and end times of a school term and link data to it.
- Parameters
id (BigAutoField) – Id
site (ForeignKey to
Site
) – Siteextended_data (JSONField) – Extended data
name (CharField) – Name
date_start (DateField) – Start date
date_end (DateField) – End date
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
SitePreferenceModel
(*args, **kwargs)[source]¶ Preference model to hold pereferences valid for a site.
- Parameters
id (BigAutoField) – Id
section (CharField) – Section name
name (CharField) – Name
raw_value (TextField) – Raw value
instance (ForeignKey to
Site
) – Instance
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
TaskUserAssignment
(id, site, extended_data, task_result, user)[source]¶ - Parameters
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
class
aleksis.core.models.
UserAdditionalAttributes
(*args, **kwargs)[source]¶ Additional attributes for Django user accounts.
These attributes are explicitly linked to a User, not to a Person.
- Parameters
id (BigAutoField) – Id
user (OneToOneField to
User
) – Linked userattributes (JSONField) – Additional attributes
-
exception
DoesNotExist
¶
-
exception
MultipleObjectsReturned
¶
-
aleksis.core.models.
save_group_on_m2m_changed
(sender, instance, action, reverse, model, pk_set, **kwargs)[source]¶ Ensure user and group data is synced to Django’s models.
AlekSIS maintains personal information and group meta-data / membership in its Person and Group models. As third-party libraries have no knowledge about this, we need to keep django.contrib.auth in sync.
This signal handler triggers a save of group objects whenever a membership changes. The save() code will decide whether to update the Django objects or not.
- Return type