Models

class lunes_cms.cms.models.AlternativeWord(*args, **kwargs)

Bases: Model

Contains alternative words that can be linked to a document

Parameters:

Relationship fields:

Parameters:

document (ForeignKey to Document) – Document (related name: alternatives)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

alt_word

Type: CharField

Alternative word

article

Type: IntegerField

Article

Choices:

  • 0

  • 1

  • 2

  • 3

  • 4

document

Type: ForeignKey to Document

Document (related name: alternatives)

document_id

Internal field, use document instead.

get_article_display(*, field=<django.db.models.IntegerField: article>)

Shows the label of the article. See get_FOO_display() for more information.

id

Type: AutoField

Primary key: ID

objects = <django.db.models.Manager object>
class lunes_cms.cms.models.Discipline(*args, **kwargs)

Bases: MPTTModel

Disciplines for training sets. They have a title, a description, a icon and contain training sets with the same topic. Inherits from mptt.models.MPTTModel.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

children

Type: Reverse TreeForeignKey from Discipline

All children of this discipline (related name of parent)

created_by

Type: ForeignKey to Group

Created by (related name: discipline)

created_by_id

Internal field, use created_by instead.

creator_is_admin

Type: BooleanField

Admin

description

Type: CharField

Description

feedback

Type: Reverse GenericRelation from Discipline

All + of this feedback (related name of feedback)

get_nested_training_sets()

Returns a list of distinct training set ids that are part of this discipline or one of its child elements.

Returns:

training set ids

Return type:

list(int)

icon

Type: ImageField

Icon

id

Type: AutoField

Primary key: ID

image_tag()

Image thumbnail to display a preview of the icon

Returns:

img HTML tag to display an image thumbnail

Return type:

str

is_valid()

Checks if a discipline itself or one of its children has at least one training set. If so, it is considered valid.

Returns:

True if discipline is valid

Return type:

bool

level

Type: PositiveIntegerField

Level

lft

Type: PositiveIntegerField

Lft

parent

Type: TreeForeignKey to Discipline

Parent (related name: children)

parent_id

Internal field, use parent instead.

released

Type: BooleanField

Released

rght

Type: PositiveIntegerField

Rght

title

Type: CharField

Discipline

training_sets

Type: Reverse ManyToManyField from TrainingSet

All training sets of this discipline (related name of discipline)

tree_id

Type: PositiveIntegerField

Tree id

class lunes_cms.cms.models.Document(*args, **kwargs)

Bases: Model

Contains a word type, a word, an article and an audio. Relates to training sets and inherits from models.Model.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

alternatives

Type: Reverse ForeignKey from AlternativeWord

All alternatives of this vocabulary (related name of document)

article

Type: IntegerField

Article

Choices:

  • 0

  • 1

  • 2

  • 3

  • 4

audio

Type: FileField

Audio

property converted

Function that converts the uploaded audio to .mp3 and returns the converted file

Parameters:

self (class: models.Document) – A handle to the models.Document

Returns:

File containing .mp3 audio

Return type:

.mp3 File

created_by

Type: ForeignKey to Group

Created by (related name: document)

created_by_id

Internal field, use created_by instead.

creation_date

Type: DateTimeField

Creation date

creator_is_admin

Type: BooleanField

Admin

document_image

Type: Reverse ForeignKey from DocumentImage

All document image of this vocabulary (related name of document)

example_sentence

Type: TextField

Example sentence

feedback

Type: Reverse GenericRelation from Document

All + of this feedback (related name of feedback)

get_article_display(*, field=<django.db.models.IntegerField: article>)

Shows the label of the article. See get_FOO_display() for more information.

get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)

Finds next instance based on creation_date. See get_next_by_FOO() for more information.

get_previous_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=False, **kwargs)

Finds previous instance based on creation_date. See get_previous_by_FOO() for more information.

get_word_type_display(*, field=<django.db.models.CharField: word_type>)

Shows the label of the word_type. See get_FOO_display() for more information.

id

Type: AutoField

Primary key: ID

objects = <django.db.models.Manager object>
save(*args, **kwargs)

Overwrite djangos save function to convert audio files to mp3 format (original file is saved as backup).

training_sets

Type: Reverse ManyToManyField from TrainingSet

All training sets of this vocabulary (related name of documents)

word

Type: CharField

Word

word_type

Type: CharField

Word type

Choices:

  • Nomen

  • Verb

  • Adjektiv

  • Numeral

  • Pronomen

  • Adverb

class lunes_cms.cms.models.DocumentImage(*args, **kwargs)

Bases: Model

Contains images and its titles that can be linked to a document object.

Parameters:

Relationship fields:

Parameters:

document (ForeignKey to Document) – Document (related name: document_image)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

confirmed

Type: BooleanField

Confirmed

crop_img()

Function that crops the image and pastes it into a blurred background image

Parameters:

self (class: DocumentImage) – A handle to the DocumentImage

Returns:

None

Return type:

None

document

Type: ForeignKey to Document

Document (related name: document_image)

document_id

Internal field, use document instead.

id

Type: AutoField

Primary key: ID

image

Type: ImageField

Image

image_tag()

Image thumbnail to display a preview of a image in the editing section of the DocumentImage admin.

Returns:

img HTML tag to display an image thumbnail

Return type:

str

objects = <django.db.models.Manager object>
save(*args, **kwargs)

Overwrite djangos save function to scale images into a uniform size that is defined in the Static module.

save_original_img()

Function to save rough image with ‘_original’ extension

Parameters:

self (class: model.DocumentImage) – A handle to the model.DocumentImage

Returns:

None

Return type:

None

class lunes_cms.cms.models.Feedback(*args, **kwargs)

Bases: Model

Model to store feedback about disciplines, training sets and vocabulary words

Parameters:

Relationship fields:

Parameters:
  • content_type (ForeignKey to ContentType) – Content type. The content type this feedback entry refers to. (related name: feedback)

  • read_by (ForeignKey to User) – Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name: feedback)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

comment

Type: TextField

Comment

content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

Include a link to the edit form of the content object in list display

Returns:

Link to the edit form of the content object

Return type:

str

content_type

Type: ForeignKey to ContentType

Content type. The content type this feedback entry refers to. (related name: feedback)

content_type_id

Internal field, use content_type instead.

created_date

Type: DateTimeField

Submitted on. The time and date when the feedback was submitted.

get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)

Finds next instance based on created_date. See get_next_by_FOO() for more information.

get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)

Finds previous instance based on created_date. See get_previous_by_FOO() for more information.

id

Type: AutoField

Primary key: ID

object_id

Type: PositiveIntegerField

Object id. The id of the object this feedback entry refers to.

objects = <django.db.models.Manager object>
read_by

Type: ForeignKey to User

Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name: feedback)

read_by_id

Internal field, use read_by instead.

class lunes_cms.cms.models.GroupAPIKey(*args, **kwargs)

Bases: Model

Model that handles api keys associated with a user group.

Parameters:
  • id (AutoField) – Primary key: ID

  • token (CharField) – Token. 10-50 characters, only digits and upper case letters allowed.

  • revoked (BooleanField) – Revoked. If the API key is revoked, clients cannot use it anymore.

  • expiry_date (DateTimeField) – Expiration date. Once API key expires, clients cannot use it anymore.

  • creation_date (DateTimeField) – Creation date

Relationship fields:

Parameters:

group (ForeignKey to Group) – Group (related name: api_keys)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

creation_date

Type: DateTimeField

Creation date

expiry_date

Type: DateTimeField

Expiration date. Once API key expires, clients cannot use it anymore.

classmethod get_from_token(token)

returns a group api which maches to the given token

Parameters:

token (str) – token

Returns:

Group API Key object

Return type:

GroupAPIKey

get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)

Finds next instance based on creation_date. See get_next_by_FOO() for more information.

get_previous_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=False, **kwargs)

Finds previous instance based on creation_date. See get_previous_by_FOO() for more information.

group

Type: ForeignKey to Group

Group (related name: api_keys)

group_id

Internal field, use group instead.

id

Type: AutoField

Primary key: ID

is_valid()

An API key is valid if it is not revoked and the exiry date (if set) is not in the past.

Returns:

Whether the API key is valid

Return type:

bool

objects = <django.db.models.Manager object>
qr_code()
Returns:

QR code image for the token with download link

Return type:

str

Returns:

Download link to the QR code for the token

Return type:

str

Parameters:
  • link (str) – The link text/image (needs to be properly escaped)

  • title (str) – The link title (optional, needs to be properly escaped)

Returns:

HTML Link to the QR code for the token

Return type:

str

property qr_code_url
Returns:

URL to the QR code for the token

Return type:

str

revoked

Type: BooleanField

Revoked. If the API key is revoked, clients cannot use it anymore.

token

Type: CharField

Token. 10-50 characters, only digits and upper case letters allowed.

class lunes_cms.cms.models.Sponsor(*args, **kwargs)

Bases: Model

Model to manage our sponsors that are shown in the app.

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

Type: AutoField

Primary key: ID

Type: ImageField

Logo

name

Type: CharField

Name

objects = <django.db.models.Manager object>
url

Type: URLField

URL

class lunes_cms.cms.models.Static

Bases: object

Module for static and global variables

admin_group = 'Lunes'
article_choices = [(0, 'keiner'), (1, 'der'), (2, 'die'), (3, 'das'), (4, 'die (Plural)')]
blurr_radius = 30
default_group_name = None
img_size = (1024, 768)
word_type_choices = [('Nomen', 'Substantiv'), ('Verb', 'Verb'), ('Adjektiv', 'Adjektiv'), ('Numeral', 'Numeral'), ('Pronomen', 'Pronomen'), ('Adverb', 'Adverb')]
class lunes_cms.cms.models.TrainingSet(*args, **kwargs)

Bases: MPTTModel

Training sets are part of disciplines, have a title, a description an icon and relates to documents and disciplines. Inherits from mptt.models.MPTTModel.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

children (Reverse TreeForeignKey from TrainingSet) – All children of this training set (related name of parent)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

children

Type: Reverse TreeForeignKey from TrainingSet

All children of this training set (related name of parent)

created_by

Type: ForeignKey to Group

Created by (related name: trainingset)

created_by_id

Internal field, use created_by instead.

creator_is_admin

Type: BooleanField

Admin

description

Type: CharField

Description

discipline

Type: ManyToManyField to Discipline

Discipline (related name: training_sets)

documents

Type: ManyToManyField to Document

Document (related name: training_sets)

feedback

Type: Reverse GenericRelation from TrainingSet

All + of this feedback (related name of feedback)

icon

Type: ImageField

Icon

id

Type: AutoField

Primary key: ID

image_tag()

Image thumbnail to display a preview of the icon

Returns:

img HTML tag to display an image thumbnail

Return type:

str

level

Type: PositiveIntegerField

Level

lft

Type: PositiveIntegerField

Lft

parent

Type: TreeForeignKey to TrainingSet

Parent (related name: children)

parent_id

Internal field, use parent instead.

released

Type: BooleanField

Released

rght

Type: PositiveIntegerField

Rght

save(*args, **kwargs)

Overwrite djangos save function to assure that no child elements are created.

Raises:

ValidationError – Exception if child training set is created

style_description_field()

This function adds css classes to description field :return: description field HTML code incl. CSS classes :rtype: str

title

Type: CharField

Training set

tree_id

Type: PositiveIntegerField

Tree id

lunes_cms.cms.models.convert_umlaute_audio(instance, filename)

Convert file name of audios to handle all kind of characters (including “Umlaute” etc.).

Parameters:
  • instance (django.db.models) – instance where the current file is being attached

  • filename (str) – name of the file

Returns:

file path of converted audio

Return type:

str

lunes_cms.cms.models.convert_umlaute_images(instance, filename)

Convert file name of images to handle all kind of characters (including “Umlaute” etc.).

Parameters:
  • instance (django.db.models) – instance where the current file is being attached

  • filename (str) – name of the file

Returns:

file path of converted image

Return type:

str

Alternative Word

class lunes_cms.cms.models.alternative_word.AlternativeWord(*args, **kwargs)

Bases: Model

Contains alternative words that can be linked to a document

Parameters:

Relationship fields:

Parameters:

document (ForeignKey to Document) – Document (related name: alternatives)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

alt_word

Type: CharField

Alternative word

article

Type: IntegerField

Article

Choices:

  • 0

  • 1

  • 2

  • 3

  • 4

document

Type: ForeignKey to Document

Document (related name: alternatives)

document_id

Internal field, use document instead.

get_article_display(*, field=<django.db.models.IntegerField: article>)

Shows the label of the article. See get_FOO_display() for more information.

id

Type: AutoField

Primary key: ID

objects = <django.db.models.Manager object>

Content Type

Discipline

class lunes_cms.cms.models.discipline.Discipline(*args, **kwargs)

Bases: MPTTModel

Disciplines for training sets. They have a title, a description, a icon and contain training sets with the same topic. Inherits from mptt.models.MPTTModel.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

children

Type: Reverse TreeForeignKey from Discipline

All children of this discipline (related name of parent)

created_by

Type: ForeignKey to Group

Created by (related name: discipline)

created_by_id

Internal field, use created_by instead.

creator_is_admin

Type: BooleanField

Admin

description

Type: CharField

Description

feedback

Type: Reverse GenericRelation from Discipline

All + of this feedback (related name of feedback)

get_nested_training_sets()

Returns a list of distinct training set ids that are part of this discipline or one of its child elements.

Returns:

training set ids

Return type:

list(int)

icon

Type: ImageField

Icon

id

Type: AutoField

Primary key: ID

image_tag()

Image thumbnail to display a preview of the icon

Returns:

img HTML tag to display an image thumbnail

Return type:

str

is_valid()

Checks if a discipline itself or one of its children has at least one training set. If so, it is considered valid.

Returns:

True if discipline is valid

Return type:

bool

level

Type: PositiveIntegerField

Level

lft

Type: PositiveIntegerField

Lft

parent

Type: TreeForeignKey to Discipline

Parent (related name: children)

parent_id

Internal field, use parent instead.

released

Type: BooleanField

Released

rght

Type: PositiveIntegerField

Rght

title

Type: CharField

Discipline

training_sets

Type: Reverse ManyToManyField from TrainingSet

All training sets of this discipline (related name of discipline)

tree_id

Type: PositiveIntegerField

Tree id

Document

class lunes_cms.cms.models.document.Document(*args, **kwargs)

Bases: Model

Contains a word type, a word, an article and an audio. Relates to training sets and inherits from models.Model.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

alternatives

Type: Reverse ForeignKey from AlternativeWord

All alternatives of this vocabulary (related name of document)

article

Type: IntegerField

Article

Choices:

  • 0

  • 1

  • 2

  • 3

  • 4

audio

Type: FileField

Audio

property converted

Function that converts the uploaded audio to .mp3 and returns the converted file

Parameters:

self (class: models.Document) – A handle to the models.Document

Returns:

File containing .mp3 audio

Return type:

.mp3 File

created_by

Type: ForeignKey to Group

Created by (related name: document)

created_by_id

Internal field, use created_by instead.

creation_date

Type: DateTimeField

Creation date

creator_is_admin

Type: BooleanField

Admin

document_image

Type: Reverse ForeignKey from DocumentImage

All document image of this vocabulary (related name of document)

example_sentence

Type: TextField

Example sentence

feedback

Type: Reverse GenericRelation from Document

All + of this feedback (related name of feedback)

get_article_display(*, field=<django.db.models.IntegerField: article>)

Shows the label of the article. See get_FOO_display() for more information.

get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)

Finds next instance based on creation_date. See get_next_by_FOO() for more information.

get_previous_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=False, **kwargs)

Finds previous instance based on creation_date. See get_previous_by_FOO() for more information.

get_word_type_display(*, field=<django.db.models.CharField: word_type>)

Shows the label of the word_type. See get_FOO_display() for more information.

id

Type: AutoField

Primary key: ID

objects = <django.db.models.Manager object>
save(*args, **kwargs)

Overwrite djangos save function to convert audio files to mp3 format (original file is saved as backup).

training_sets

Type: Reverse ManyToManyField from TrainingSet

All training sets of this vocabulary (related name of documents)

word

Type: CharField

Word

word_type

Type: CharField

Word type

Choices:

  • Nomen

  • Verb

  • Adjektiv

  • Numeral

  • Pronomen

  • Adverb

Document Image

class lunes_cms.cms.models.document_image.DocumentImage(*args, **kwargs)

Bases: Model

Contains images and its titles that can be linked to a document object.

Parameters:

Relationship fields:

Parameters:

document (ForeignKey to Document) – Document (related name: document_image)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

confirmed

Type: BooleanField

Confirmed

crop_img()

Function that crops the image and pastes it into a blurred background image

Parameters:

self (class: DocumentImage) – A handle to the DocumentImage

Returns:

None

Return type:

None

document

Type: ForeignKey to Document

Document (related name: document_image)

document_id

Internal field, use document instead.

id

Type: AutoField

Primary key: ID

image

Type: ImageField

Image

image_tag()

Image thumbnail to display a preview of a image in the editing section of the DocumentImage admin.

Returns:

img HTML tag to display an image thumbnail

Return type:

str

objects = <django.db.models.Manager object>
save(*args, **kwargs)

Overwrite djangos save function to scale images into a uniform size that is defined in the Static module.

save_original_img()

Function to save rough image with ‘_original’ extension

Parameters:

self (class: model.DocumentImage) – A handle to the model.DocumentImage

Returns:

None

Return type:

None

Feedback

class lunes_cms.cms.models.feedback.Feedback(*args, **kwargs)

Bases: Model

Model to store feedback about disciplines, training sets and vocabulary words

Parameters:

Relationship fields:

Parameters:
  • content_type (ForeignKey to ContentType) – Content type. The content type this feedback entry refers to. (related name: feedback)

  • read_by (ForeignKey to User) – Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name: feedback)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

comment

Type: TextField

Comment

content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

Include a link to the edit form of the content object in list display

Returns:

Link to the edit form of the content object

Return type:

str

content_type

Type: ForeignKey to ContentType

Content type. The content type this feedback entry refers to. (related name: feedback)

content_type_id

Internal field, use content_type instead.

created_date

Type: DateTimeField

Submitted on. The time and date when the feedback was submitted.

get_next_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=True, **kwargs)

Finds next instance based on created_date. See get_next_by_FOO() for more information.

get_previous_by_created_date(*, field=<django.db.models.DateTimeField: created_date>, is_next=False, **kwargs)

Finds previous instance based on created_date. See get_previous_by_FOO() for more information.

id

Type: AutoField

Primary key: ID

object_id

Type: PositiveIntegerField

Object id. The id of the object this feedback entry refers to.

objects = <django.db.models.Manager object>
read_by

Type: ForeignKey to User

Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name: feedback)

read_by_id

Internal field, use read_by instead.

Group

Group API Key

class lunes_cms.cms.models.group_api_key.GroupAPIKey(*args, **kwargs)

Bases: Model

Model that handles api keys associated with a user group.

Parameters:
  • id (AutoField) – Primary key: ID

  • token (CharField) – Token. 10-50 characters, only digits and upper case letters allowed.

  • revoked (BooleanField) – Revoked. If the API key is revoked, clients cannot use it anymore.

  • expiry_date (DateTimeField) – Expiration date. Once API key expires, clients cannot use it anymore.

  • creation_date (DateTimeField) – Creation date

Relationship fields:

Parameters:

group (ForeignKey to Group) – Group (related name: api_keys)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

creation_date

Type: DateTimeField

Creation date

expiry_date

Type: DateTimeField

Expiration date. Once API key expires, clients cannot use it anymore.

classmethod get_from_token(token)

returns a group api which maches to the given token

Parameters:

token (str) – token

Returns:

Group API Key object

Return type:

GroupAPIKey

get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)

Finds next instance based on creation_date. See get_next_by_FOO() for more information.

get_previous_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=False, **kwargs)

Finds previous instance based on creation_date. See get_previous_by_FOO() for more information.

group

Type: ForeignKey to Group

Group (related name: api_keys)

group_id

Internal field, use group instead.

id

Type: AutoField

Primary key: ID

is_valid()

An API key is valid if it is not revoked and the exiry date (if set) is not in the past.

Returns:

Whether the API key is valid

Return type:

bool

objects = <django.db.models.Manager object>
qr_code()
Returns:

QR code image for the token with download link

Return type:

str

Returns:

Download link to the QR code for the token

Return type:

str

Parameters:
  • link (str) – The link text/image (needs to be properly escaped)

  • title (str) – The link title (optional, needs to be properly escaped)

Returns:

HTML Link to the QR code for the token

Return type:

str

property qr_code_url
Returns:

URL to the QR code for the token

Return type:

str

revoked

Type: BooleanField

Revoked. If the API key is revoked, clients cannot use it anymore.

token

Type: CharField

Token. 10-50 characters, only digits and upper case letters allowed.

lunes_cms.cms.models.group_api_key.generate_default_token()

Generate a default random token of upper case letters and digits

Returns:

A default token

Return type:

str

Sponsor

class lunes_cms.cms.models.sponsor.Sponsor(*args, **kwargs)

Bases: Model

Model to manage our sponsors that are shown in the app.

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

Type: AutoField

Primary key: ID

Type: ImageField

Logo

name

Type: CharField

Name

objects = <django.db.models.Manager object>
url

Type: URLField

URL

Static

class lunes_cms.cms.models.static.Static

Bases: object

Module for static and global variables

admin_group = 'Lunes'
article_choices = [(0, 'keiner'), (1, 'der'), (2, 'die'), (3, 'das'), (4, 'die (Plural)')]
blurr_radius = 30
default_group_name = None
img_size = (1024, 768)
word_type_choices = [('Nomen', 'Substantiv'), ('Verb', 'Verb'), ('Adjektiv', 'Adjektiv'), ('Numeral', 'Numeral'), ('Pronomen', 'Pronomen'), ('Adverb', 'Adverb')]
lunes_cms.cms.models.static.convert_umlaute_audio(instance, filename)

Convert file name of audios to handle all kind of characters (including “Umlaute” etc.).

Parameters:
  • instance (django.db.models) – instance where the current file is being attached

  • filename (str) – name of the file

Returns:

file path of converted audio

Return type:

str

lunes_cms.cms.models.static.convert_umlaute_images(instance, filename)

Convert file name of images to handle all kind of characters (including “Umlaute” etc.).

Parameters:
  • instance (django.db.models) – instance where the current file is being attached

  • filename (str) – name of the file

Returns:

file path of converted image

Return type:

str

lunes_cms.cms.models.static.create_user_profile(sender, instance, created, **kwargs)

Automatically adds a group when creating a new user if group name given in Static module

Parameters:
  • sender (django.contrib.auth.models) – user that sends request

  • instance (django.contrib.auth.models) – user that eventually will be added to a new group

  • created (bool) – checks if User is creator

Returns:

False if User is not creator and not part of Static.default_group_name

Return type:

bool

lunes_cms.cms.models.static.upload_sponsor_logos(instance, filename)

Upload path for sponsor logos

Parameters:
  • instance (django.db.models) – instance where the current file is being attached

  • filename (str) – name of the file

Returns:

file path for sponsor logos

Return type:

str

Training Set

class lunes_cms.cms.models.training_set.TrainingSet(*args, **kwargs)

Bases: MPTTModel

Training sets are part of disciplines, have a title, a description an icon and relates to documents and disciplines. Inherits from mptt.models.MPTTModel.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:

children (Reverse TreeForeignKey from TrainingSet) – All children of this training set (related name of parent)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

children

Type: Reverse TreeForeignKey from TrainingSet

All children of this training set (related name of parent)

created_by

Type: ForeignKey to Group

Created by (related name: trainingset)

created_by_id

Internal field, use created_by instead.

creator_is_admin

Type: BooleanField

Admin

description

Type: CharField

Description

discipline

Type: ManyToManyField to Discipline

Discipline (related name: training_sets)

documents

Type: ManyToManyField to Document

Document (related name: training_sets)

feedback

Type: Reverse GenericRelation from TrainingSet

All + of this feedback (related name of feedback)

icon

Type: ImageField

Icon

id

Type: AutoField

Primary key: ID

image_tag()

Image thumbnail to display a preview of the icon

Returns:

img HTML tag to display an image thumbnail

Return type:

str

level

Type: PositiveIntegerField

Level

lft

Type: PositiveIntegerField

Lft

parent

Type: TreeForeignKey to TrainingSet

Parent (related name: children)

parent_id

Internal field, use parent instead.

released

Type: BooleanField

Released

rght

Type: PositiveIntegerField

Rght

save(*args, **kwargs)

Overwrite djangos save function to assure that no child elements are created.

Raises:

ValidationError – Exception if child training set is created

style_description_field()

This function adds css classes to description field :return: description field HTML code incl. CSS classes :rtype: str

title

Type: CharField

Training set

tree_id

Type: PositiveIntegerField

Tree id