Core data models

class aleksis.core.models.Activity(id, extended_data, user, title, description, app)[source]
Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • user (ForeignKey to Person) – User

  • title (CharField) – Title

  • description (TextField) – Description

  • app (CharField) – Application

exception DoesNotExist
exception MultipleObjectsReturned
class aleksis.core.models.Announcement(id, extended_data, title, description, link, valid_from, valid_until)[source]
Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • title (CharField) – Title

  • description (TextField) – Description

  • link (URLField) – Link

  • valid_from (DateTimeField) – Date and time from when to show

  • valid_until (DateTimeField) – Date and time until when to show

exception DoesNotExist
exception MultipleObjectsReturned
classmethod for_person_at_time(person, when=None)[source]

Get all announcements for one person at a certain time

Return type

List

property recipient_persons

Return a list of Persons this announcement is relevant for

Return type

Sequence[Person]

classmethod relevant_for(obj)[source]

Get a QuerySet with all announcements relevant for a certain Model (e.g. a Group) or a set of models in a QuerySet.

Return type

QuerySet

class aleksis.core.models.AnnouncementRecipient(id, extended_data, announcement, content_type, recipient_id)[source]
Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • announcement (ForeignKey to Announcement) – Announcement

  • content_type (ForeignKey to ContentType) – Content type

  • recipient_id (PositiveIntegerField) – Recipient id

exception DoesNotExist
exception MultipleObjectsReturned
property persons

Return a list of Persons selected by this recipient object

If the recipient is a Person, return that object. If not, it returns the list from the announcement_recipients field on the target model.

Return type

Sequence[Person]

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(DhasboardWIdget):
    template = "myapp/widget.html"

    def get_context(self):
        context = {"some_content": "foo"}
        return context

    class Meta:
        proxy = True

    media = Media(css={
            'all': ('pretty.css',)
        },
        js=('animations.js', 'actions.js')
    )
Parameters
  • id (AutoField) – Id

  • polymorphic_ctype (ForeignKey to ContentType) – Polymorphic ctype

  • title (CharField) – Widget title

  • active (BooleanField) – Activate widget

exception DoesNotExist
exception MultipleObjectsReturned
static get_media(widgets)[source]

Return all media required to render the selected widgets.

class aleksis.core.models.Group(*args, **kwargs)[source]

Any kind of group of persons in a school, including, but not limited classes, clubs, and the like.

Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • name (CharField) – Long name of group

  • short_name (CharField) – Short name of group

  • members (ManyToManyField) – Members

  • owners (ManyToManyField) – Owners

  • parent_groups (ManyToManyField) – Parent groups

exception DoesNotExist
exception MultipleObjectsReturned
class aleksis.core.models.Notification(id, extended_data, sender, recipient, title, description, link, read, sent)[source]
Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • sender (CharField) – Sender

  • recipient (ForeignKey to Person) – Recipient

  • title (CharField) – Title

  • description (TextField) – Description

  • link (URLField) – Link

  • read (BooleanField) – Read

  • sent (BooleanField) – Sent

exception DoesNotExist
exception MultipleObjectsReturned
save(**kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class aleksis.core.models.Person(*args, **kwargs)[source]

A model describing any person related to a school, including, but not limited to, students, teachers and guardians (parents).

Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • user (OneToOneField to User) – User

  • is_active (BooleanField) – Is person active?

  • first_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

  • sex (CharField) – Sex

  • photo (ImageCropField) – Photo

  • photo_cropping (ImageRatioField) – Photo cropping. None

  • import_ref (CharField) – Reference id of import source

  • primary_group (ForeignKey to Group) – Primary group

  • guardians (ManyToManyField) – Guardians / parents

exception DoesNotExist
exception MultipleObjectsReturned
property is_teacher

Check if the user has lessons as a teacher

property lesson_periods_as_participant

Return a QuerySet containing all `LessonPeriod`s this person participates in (as student).

Note

Only available when AlekSIS-App-Chronos is installed.

Date

2019-11-07

Authors
property lesson_periods_as_teacher

Return a QuerySet containing all `Lesson`s this person gives (as teacher).

Note

Only available when AlekSIS-App-Chronos is installed.

Date

2019-11-07

Authors
property lessons_as_participant

Return a QuerySet containing all `Lesson`s this person participates in (as student).

Note

Only available when AlekSIS-App-Chronos is installed.

Date

2019-11-07

Authors
mark_absent(day, from_period=0, absent=True, excused=False, remarks='')

Mark a person absent for all lessons in a day, optionally starting with a selected period number.

This function creates PersonalNote objects for every LessonPeriod the person participates in on the selected day and marks them as absent/excused.

..note:: Only available when AlekSIS-App-Alsijil is installed.

Date

2019-11-10

Authors
property primary_group_short_name

Returns the short_name field of the primary group related object.

Return type

Optional[str]

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

property timetable_object

Return the object which has the user’s timetable

Return type

Union[Group, Person, None]

property timetable_type

Return which type of timetable this user has

Return type

Optional[str]

class aleksis.core.models.School(*args, **kwargs)[source]

A school that will have many other objects linked to it. AlekSIS has multi-tenant support by linking all objects to a school, and limiting all features to objects related to the same school as the currently logged-in user.

Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • name (CharField) – Name

  • name_official (CharField) – Official name. Official name of the school, e.g. as given by supervisory authority

  • logo (ImageCropField) – School logo

  • logo_cropping (ImageRatioField) – Logo cropping. None

exception DoesNotExist
exception MultipleObjectsReturned
class aleksis.core.models.SchoolTerm(*args, **kwargs)[source]

Information about a term (limited time frame) that data can be linked to.

Parameters
  • id (AutoField) – Id

  • extended_data (JSONField) – Extended data

  • caption (CharField) – Visible caption of the term

  • date_start (DateField) – Effective start date of term

  • date_end (DateField) – Effective end date of term

  • current (NullBooleanField) – Current

exception DoesNotExist
exception MultipleObjectsReturned
save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.