Models
- class lunes_cms.cms.models.AlternativeWord(*args, **kwargs)
Bases:
Model
Contains alternative words that can be linked to a document
- Parameters:
id (AutoField) – Primary key: ID
alt_word (CharField) – Alternative word
article (IntegerField) – Article
Relationship fields:
- Parameters:
document (
ForeignKey
toDocument
) – Document (related name:alternatives
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- article
Type:
IntegerField
Article
Choices:
0
1
2
3
4
- document
Type:
ForeignKey
toDocument
Document (related name:
alternatives
)
- get_article_display(*, field=<django.db.models.IntegerField: article>)
Shows the label of the
article
. Seeget_FOO_display()
for more information.
- 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:
id (AutoField) – Primary key: ID
released (BooleanField) – Released
title (CharField) – Discipline
description (CharField) – Description
icon (ImageField) – Icon
creator_is_admin (BooleanField) – Admin
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:discipline
)parent (
TreeForeignKey
toDiscipline
) – Parent (related name:children
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
children (Reverse
TreeForeignKey
fromDiscipline
) – All children of this discipline (related name ofparent
)training_sets (Reverse
ManyToManyField
fromTrainingSet
) – All training sets of this discipline (related name ofdiscipline
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- children
Type: Reverse
TreeForeignKey
fromDiscipline
All children of this discipline (related name of
parent
)
- created_by
Type:
ForeignKey
toGroup
Created by (related name:
discipline
)
- created_by_id
Internal field, use
created_by
instead.
- creator_is_admin
Type:
BooleanField
Admin
- feedback
Type: Reverse
GenericRelation
fromDiscipline
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.
- icon
Type:
ImageField
Icon
- image_tag()
Image thumbnail to display a preview of the icon
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- 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:
- level
Type:
PositiveIntegerField
Level
- lft
Type:
PositiveIntegerField
Lft
- parent
Type:
TreeForeignKey
toDiscipline
Parent (related name:
children
)
- released
Type:
BooleanField
Released
- rght
Type:
PositiveIntegerField
Rght
- training_sets
Type: Reverse
ManyToManyField
fromTrainingSet
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:
id (AutoField) – Primary key: ID
word_type (CharField) – Word type
word (CharField) – Word
article (IntegerField) – Article
audio (FileField) – Audio
example_sentence (TextField) – Example sentence
creation_date (DateTimeField) – Creation date
creator_is_admin (BooleanField) – Admin
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:document
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
alternatives (Reverse
ForeignKey
fromAlternativeWord
) – All alternatives of this vocabulary (related name ofdocument
)document_image (Reverse
ForeignKey
fromDocumentImage
) – All document image of this vocabulary (related name ofdocument
)training_sets (Reverse
ManyToManyField
fromTrainingSet
) – All training sets of this vocabulary (related name ofdocuments
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- alternatives
Type: Reverse
ForeignKey
fromAlternativeWord
All alternatives of this vocabulary (related name of
document
)
- article
Type:
IntegerField
Article
Choices:
0
1
2
3
4
- 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
toGroup
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
fromDocumentImage
All document image of this vocabulary (related name of
document
)
- feedback
Type: Reverse
GenericRelation
fromDocument
All + of this feedback (related name of
feedback
)
- get_article_display(*, field=<django.db.models.IntegerField: article>)
Shows the label of the
article
. Seeget_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
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- get_word_type_display(*, field=<django.db.models.CharField: word_type>)
Shows the label of the
word_type
. Seeget_FOO_display()
for more information.
- 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
fromTrainingSet
All training sets of this vocabulary (related name of
documents
)
- class lunes_cms.cms.models.DocumentImage(*args, **kwargs)
Bases:
Model
Contains images and its titles that can be linked to a document object.
- Parameters:
id (AutoField) – Primary key: ID
image (ImageField) – Image
confirmed (BooleanField) – Confirmed
Relationship fields:
- Parameters:
document (
ForeignKey
toDocument
) – 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
toDocument
Document (related name:
document_image
)
- 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:
- 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:
id (AutoField) – Primary key: ID
object_id (PositiveIntegerField) – Object id. The id of the object this feedback entry refers to.
comment (TextField) – Comment
created_date (DateTimeField) – Submitted on. The time and date when the feedback was submitted.
content_object (GenericForeignKey) – Generic foreign key to the
ContentType
specified incontent_type
Relationship fields:
- Parameters:
content_type (
ForeignKey
toContentType
) – Content type. The content type this feedback entry refers to. (related name:feedback
)read_by (
ForeignKey
toUser
) – 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
- content_object
Provide a generic many-to-one relation through the
content_type
andobject_id
fields.This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.
- content_object_link()
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:
- content_type
Type:
ForeignKey
toContentType
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
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- 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
toUser
Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name:
feedback
)
- 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
toGroup
) – 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:
- get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)
Finds next instance based on
creation_date
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- group
Type:
ForeignKey
toGroup
Group (related name:
api_keys
)
- 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:
- objects = <django.db.models.Manager object>
- qr_code_link(link, title=None)
- revoked
Type:
BooleanField
Revoked. If the API key is revoked, clients cannot use it anymore.
- class lunes_cms.cms.models.Sponsor(*args, **kwargs)
Bases:
Model
Model to manage our sponsors that are shown in the app.
- Parameters:
id (AutoField) – Primary key: ID
name (CharField) – Name
url (URLField) – URL
logo (ImageField) – Logo
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- logo
Type:
ImageField
Logo
- objects = <django.db.models.Manager object>
- 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:
id (AutoField) – Primary key: ID
released (BooleanField) – Released
title (CharField) – Training set
description (CharField) – Description
icon (ImageField) – Icon
creator_is_admin (BooleanField) – Admin
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:trainingset
)parent (
TreeForeignKey
toTrainingSet
) – Parent (related name:children
)documents (
ManyToManyField
toDocument
) – Document (related name:training_sets
)discipline (
ManyToManyField
toDiscipline
) – Discipline (related name:training_sets
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
children (Reverse
TreeForeignKey
fromTrainingSet
) – All children of this training set (related name ofparent
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- children
Type: Reverse
TreeForeignKey
fromTrainingSet
All children of this training set (related name of
parent
)
- created_by
Type:
ForeignKey
toGroup
Created by (related name:
trainingset
)
- created_by_id
Internal field, use
created_by
instead.
- creator_is_admin
Type:
BooleanField
Admin
- discipline
Type:
ManyToManyField
toDiscipline
Discipline (related name:
training_sets
)
- documents
Type:
ManyToManyField
toDocument
Document (related name:
training_sets
)
- feedback
Type: Reverse
GenericRelation
fromTrainingSet
All + of this feedback (related name of
feedback
)
- icon
Type:
ImageField
Icon
- image_tag()
Image thumbnail to display a preview of the icon
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- level
Type:
PositiveIntegerField
Level
- lft
Type:
PositiveIntegerField
Lft
- parent
Type:
TreeForeignKey
toTrainingSet
Parent (related name:
children
)
- 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
- 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.).
- lunes_cms.cms.models.convert_umlaute_images(instance, filename)
Convert file name of images to handle all kind of characters (including “Umlaute” etc.).
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:
id (AutoField) – Primary key: ID
alt_word (CharField) – Alternative word
article (IntegerField) – Article
Relationship fields:
- Parameters:
document (
ForeignKey
toDocument
) – Document (related name:alternatives
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- article
Type:
IntegerField
Article
Choices:
0
1
2
3
4
- document
Type:
ForeignKey
toDocument
Document (related name:
alternatives
)
- get_article_display(*, field=<django.db.models.IntegerField: article>)
Shows the label of the
article
. Seeget_FOO_display()
for more information.
- 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:
id (AutoField) – Primary key: ID
released (BooleanField) – Released
title (CharField) – Discipline
description (CharField) – Description
icon (ImageField) – Icon
creator_is_admin (BooleanField) – Admin
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:discipline
)parent (
TreeForeignKey
toDiscipline
) – Parent (related name:children
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
children (Reverse
TreeForeignKey
fromDiscipline
) – All children of this discipline (related name ofparent
)training_sets (Reverse
ManyToManyField
fromTrainingSet
) – All training sets of this discipline (related name ofdiscipline
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- children
Type: Reverse
TreeForeignKey
fromDiscipline
All children of this discipline (related name of
parent
)
- created_by
Type:
ForeignKey
toGroup
Created by (related name:
discipline
)
- created_by_id
Internal field, use
created_by
instead.
- creator_is_admin
Type:
BooleanField
Admin
- feedback
Type: Reverse
GenericRelation
fromDiscipline
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.
- icon
Type:
ImageField
Icon
- image_tag()
Image thumbnail to display a preview of the icon
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- 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:
- level
Type:
PositiveIntegerField
Level
- lft
Type:
PositiveIntegerField
Lft
- parent
Type:
TreeForeignKey
toDiscipline
Parent (related name:
children
)
- released
Type:
BooleanField
Released
- rght
Type:
PositiveIntegerField
Rght
- training_sets
Type: Reverse
ManyToManyField
fromTrainingSet
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:
id (AutoField) – Primary key: ID
word_type (CharField) – Word type
word (CharField) – Word
article (IntegerField) – Article
audio (FileField) – Audio
example_sentence (TextField) – Example sentence
creation_date (DateTimeField) – Creation date
creator_is_admin (BooleanField) – Admin
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:document
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
alternatives (Reverse
ForeignKey
fromAlternativeWord
) – All alternatives of this vocabulary (related name ofdocument
)document_image (Reverse
ForeignKey
fromDocumentImage
) – All document image of this vocabulary (related name ofdocument
)training_sets (Reverse
ManyToManyField
fromTrainingSet
) – All training sets of this vocabulary (related name ofdocuments
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- alternatives
Type: Reverse
ForeignKey
fromAlternativeWord
All alternatives of this vocabulary (related name of
document
)
- article
Type:
IntegerField
Article
Choices:
0
1
2
3
4
- 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
toGroup
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
fromDocumentImage
All document image of this vocabulary (related name of
document
)
- feedback
Type: Reverse
GenericRelation
fromDocument
All + of this feedback (related name of
feedback
)
- get_article_display(*, field=<django.db.models.IntegerField: article>)
Shows the label of the
article
. Seeget_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
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- get_word_type_display(*, field=<django.db.models.CharField: word_type>)
Shows the label of the
word_type
. Seeget_FOO_display()
for more information.
- 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
fromTrainingSet
All training sets of this vocabulary (related name of
documents
)
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:
id (AutoField) – Primary key: ID
image (ImageField) – Image
confirmed (BooleanField) – Confirmed
Relationship fields:
- Parameters:
document (
ForeignKey
toDocument
) – 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
toDocument
Document (related name:
document_image
)
- 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:
- 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:
id (AutoField) – Primary key: ID
object_id (PositiveIntegerField) – Object id. The id of the object this feedback entry refers to.
comment (TextField) – Comment
created_date (DateTimeField) – Submitted on. The time and date when the feedback was submitted.
content_object (GenericForeignKey) – Generic foreign key to the
ContentType
specified incontent_type
Relationship fields:
- Parameters:
content_type (
ForeignKey
toContentType
) – Content type. The content type this feedback entry refers to. (related name:feedback
)read_by (
ForeignKey
toUser
) – 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
- content_object
Provide a generic many-to-one relation through the
content_type
andobject_id
fields.This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.
- content_object_link()
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:
- content_type
Type:
ForeignKey
toContentType
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
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- 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
toUser
Marked as read by. The user who marked this feedback as read. If the feedback is unread, this field is empty. (related name:
feedback
)
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
toGroup
) – 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:
- get_next_by_creation_date(*, field=<django.db.models.DateTimeField: creation_date>, is_next=True, **kwargs)
Finds next instance based on
creation_date
. Seeget_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
. Seeget_previous_by_FOO()
for more information.
- group
Type:
ForeignKey
toGroup
Group (related name:
api_keys
)
- 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:
- objects = <django.db.models.Manager object>
- qr_code_link(link, title=None)
- revoked
Type:
BooleanField
Revoked. If the API key is revoked, clients cannot use it anymore.
Sponsor
- class lunes_cms.cms.models.sponsor.Sponsor(*args, **kwargs)
Bases:
Model
Model to manage our sponsors that are shown in the app.
- Parameters:
id (AutoField) – Primary key: ID
name (CharField) – Name
url (URLField) – URL
logo (ImageField) – Logo
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- logo
Type:
ImageField
Logo
- objects = <django.db.models.Manager object>
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.).
- lunes_cms.cms.models.static.convert_umlaute_images(instance, filename)
Convert file name of images to handle all kind of characters (including “Umlaute” etc.).
- 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:
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:
id (AutoField) – Primary key: ID
released (BooleanField) – Released
title (CharField) – Training set
description (CharField) – Description
icon (ImageField) – Icon
creator_is_admin (BooleanField) – Admin
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
created_by (
ForeignKey
toGroup
) – Created by (related name:trainingset
)parent (
TreeForeignKey
toTrainingSet
) – Parent (related name:children
)documents (
ManyToManyField
toDocument
) – Document (related name:training_sets
)discipline (
ManyToManyField
toDiscipline
) – Discipline (related name:training_sets
)feedback (
GenericRelation
toFeedback
) – Feedback (related name:+
)
Reverse relationships:
- Parameters:
children (Reverse
TreeForeignKey
fromTrainingSet
) – All children of this training set (related name ofparent
)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- children
Type: Reverse
TreeForeignKey
fromTrainingSet
All children of this training set (related name of
parent
)
- created_by
Type:
ForeignKey
toGroup
Created by (related name:
trainingset
)
- created_by_id
Internal field, use
created_by
instead.
- creator_is_admin
Type:
BooleanField
Admin
- discipline
Type:
ManyToManyField
toDiscipline
Discipline (related name:
training_sets
)
- documents
Type:
ManyToManyField
toDocument
Document (related name:
training_sets
)
- feedback
Type: Reverse
GenericRelation
fromTrainingSet
All + of this feedback (related name of
feedback
)
- icon
Type:
ImageField
Icon
- image_tag()
Image thumbnail to display a preview of the icon
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- level
Type:
PositiveIntegerField
Level
- lft
Type:
PositiveIntegerField
Lft
- parent
Type:
TreeForeignKey
toTrainingSet
Parent (related name:
children
)
- 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
- tree_id
Type:
PositiveIntegerField
Tree id