Admins
- class lunes_cms.cms.admins.DisciplineAdmin(model, admin_site)
Bases:
DraggableMPTTAdmin
Admin Interface to for the Discipline module. Inheriting from mptt.admin.DraggableMPTTAdmin.
- class Media
Bases:
object
Media class for admin interface for disciplines
- js = ('js/image_preview.js',)
- actions = ['delete_selected', 'make_released', 'make_unreleased']
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (Discipline) – Discipline object
- Returns:
Either static admin group or user group
- Return type:
- fields = ['released', 'title', 'description', 'icon', 'image_tag', 'parent', 'created_by']
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_form(request, obj=None, **kwargs)
Overwrite django built-in function to define custom choices in MPTT many to many selector for parent disciplines, e.g. users should not see disciplines by superusers. The function modifies the querysets of the corresponding base fields dynamically.
- Parameters:
request (django.http.request) – current user request
obj (django.db.models, optional) – django model object, defaults to None
- Returns:
model form with adjusted querysets
- Return type:
ModelForm
- get_list_display(request)
Return a sequence containing the fields to be displayed on the changelist.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see disciplines of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- list_display = ['tree_actions', 'indented_title', 'released', 'modules_released', 'modules_unreleased', 'words_released', 'creator_group']
- list_display_links = ['indented_title']
- list_filter = ['released']
- list_per_page = 25
- make_released(request, queryset)
Action to release discipline objects. It sets the corresponding boolean field to true.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- make_unreleased(request, queryset)
Action to hide discipline objects. It sets the corresponding boolean field to false.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- property media
- modules_released(obj)
returns HTML Tag of the link to released training sets related to the discipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
HTML Tag of the link to released training sets related to the discipline
- Return type:
- modules_unreleased(obj)
returns HTML Tag of the link to unreleased training sets related to the discipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
HTML Tag of the link to unreleased training sets related to the discipline
- Return type:
- readonly_fields = ['created_by', 'image_tag']
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (Discipline) – discipline object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['title']
- words_released(obj)
returns HTML Tag of the link to released words in the relased training sets related to the descipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
- Return type:
- class lunes_cms.cms.admins.DocumentAdmin(model, admin_site)
Bases:
ModelAdmin
Admin Interface to for the Document module. Inheriting from admin.ModelAdmin.
- class Media
Bases:
object
Media class of admin interface for documents
- js = ('js/image_preview.js',)
- article_display(obj)
Include article of document in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- exclude = ('article_plural', 'creator_is_admin')
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_list_filter(request)
Override djangos get_list_filter function to remove specific list filters that are only relevant for super users.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see documents of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- has_audio(obj)
Include in list display whether a document has an audio file.
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- has_image(obj)
Include in list display whether a document has an image file.
- Parameters:
obj (models.Document) – Document object
- Returns:
Whether the document has at least one confirmed image
- Return type:
- inlines = [<class 'lunes_cms.cms.admins.document_image_admin.DocumentImageAdmin'>, <class 'lunes_cms.cms.admins.alternative_word_admin.AlternativeWordAdmin'>]
- list_display = ('word', 'word_type', 'article_display', 'related_training_set', 'has_audio', 'has_image', 'creator_group', 'creation_date')
- list_filter = (<class 'lunes_cms.cms.list_filter.DocumentDisciplineListFilter'>, <class 'lunes_cms.cms.list_filter.DocumentTrainingSetListFilter'>, <class 'lunes_cms.cms.list_filter.AssignedListFilter'>, <class 'lunes_cms.cms.list_filter.ApprovedImageListFilter'>)
- list_per_page = 25
- property media
- ordering = ['word', 'creation_date']
- readonly_fields = ('created_by',)
Display related training sets in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
comma seperated list of related training sets
- Return type:
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (models.Document) – document object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['word', 'alternatives__alt_word']
- class lunes_cms.cms.admins.FeedbackAdmin(model, admin_site)
Bases:
ModelAdmin
Admin interface for feedback. Inheriting from admin.ModelAdmin.
- actions = ['mark_as_read', 'mark_as_unread']
- has_add_permission(request, obj=None)
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
- list_display = ['comment', 'content_object_link', 'content_type', 'created_date', 'read_by']
- list_filter = ['content_type', 'read_by']
- mark_as_read(request, queryset)
Action to mark selected items as read by user
- Parameters:
request (HttpRequest) – The current request
queryset (QuerySet) – The queryset of selected feedback entries
- mark_as_unread(request, queryset)
Action to mark selected items as unread
- Parameters:
request (HttpRequest) – The current request
queryset (QuerySet) – The queryset of selected feedback entries
- property media
- readonly_fields = ['comment', 'content_object_link', 'content_type', 'created_date', 'read_by']
- search_fields = ['comment']
- sortable_by = ['content_type', 'created_date', 'read_by']
- class lunes_cms.cms.admins.GroupAPIKeyAdmin(model, admin_site)
Bases:
ModelAdmin
Class for admin pannel of GroupAPIKey
- list_display = ['token', 'group', 'is_valid', 'expiry_date', 'qr_code_download_link']
- list_per_page = 25
- property media
- readonly_fields = ['is_valid', 'qr_code']
- search_fields = ['group']
- class lunes_cms.cms.admins.SponsorAdmin(model, admin_site)
Bases:
ModelAdmin
Admin interface that is used to edit sponsor objects in the CMS.
- fields = ['name', 'url', 'logo', 'image_tag']
- has_logo(obj)
Additional field to display whether a logo is set for the sponsor in the list view.
- Returns:
Whether the sponsor has a logo
- Return type:
- image_tag(obj)
Image thumbnail to display a preview of a image in the form view.
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- list_display = ['name', 'has_logo']
- list_per_page = 25
- property media
- readonly_fields = ['image_tag']
- class lunes_cms.cms.admins.TrainingSetAdmin(model, admin_site)
Bases:
DraggableMPTTAdmin
Admin Interface to for the TrainigSet module. Inheriting from mptt.admin.DraggableMPTTAdmin.
- actions = ['make_released', 'make_unreleased']
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
Either static admin group or user group
- Return type:
- exclude = ('creator_is_admin',)
- fields = ['released', 'title', 'description', 'icon', 'image_tag', 'documents', 'discipline', 'created_by']
- form
alias of
TrainingSetForm
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_form(request, obj=None, **kwargs)
Overwrite django built-in function to define custom choices in many to many selectors, e.g. users should not see documents by superusers. The function modifies the querysets of the corresponding base fields dynamically.
- Parameters:
request (django.http.request) – current user request
obj (django.db.models, optional) – django model object, defaults to None
- Returns:
model form with adjusted querysets
- Return type:
ModelForm
- get_list_display(request)
Return a sequence containing the fields to be displayed on the changelist.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see training set of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- list_display = ['tree_actions', 'title', 'released', 'words', 'words_released', 'words_unreleased', 'related_disciplines', 'creator_group']
- list_display_links = ['title']
- list_filter = [<class 'lunes_cms.cms.list_filter.DisciplineListFilter'>, 'released']
- list_per_page = 25
- make_released(request, queryset)
Action to release training set objects. It sets the corresponding boolean field to true.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- make_unreleased(request, queryset)
Action to hide discipline objects. It sets the corresponding boolean field to false.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- property media
- readonly_fields = ['created_by', 'image_tag']
Display related disciplines in list display
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
comma separated list of related disciplines
- Return type:
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (TrainingSet) – training set object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['title']
- words(obj)
returns HTML tag of the link to the list of words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the link to the list of words related to the training set
- Return type:
- words_released(obj)
returns HTML tag of the link to the list of released words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the link to the list of released words related to the training set
- Return type:
- words_unreleased(obj)
returns HTML tag of the Link to the list of unreleased words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the Link to the list of unreleased words related to the training set
- Return type:
Alternative Word Admin
- class lunes_cms.cms.admins.alternative_word_admin.AlternativeWordAdmin(parent_model, admin_site)
Bases:
StackedInline
Admin Interface to for the AlternativeWord module. Inheriting from admin.StackedInline.
- autocomplete_fields = ['document']
- extra = 0
- insert_after = 'autocomplete_fields'
- property media
- model
alias of
AlternativeWord
- search_fields = ['alt_word']
Discipline Admin
- class lunes_cms.cms.admins.discipline_admin.DisciplineAdmin(model, admin_site)
Bases:
DraggableMPTTAdmin
Admin Interface to for the Discipline module. Inheriting from mptt.admin.DraggableMPTTAdmin.
- class Media
Bases:
object
Media class for admin interface for disciplines
- js = ('js/image_preview.js',)
- actions = ['delete_selected', 'make_released', 'make_unreleased']
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (Discipline) – Discipline object
- Returns:
Either static admin group or user group
- Return type:
- fields = ['released', 'title', 'description', 'icon', 'image_tag', 'parent', 'created_by']
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_form(request, obj=None, **kwargs)
Overwrite django built-in function to define custom choices in MPTT many to many selector for parent disciplines, e.g. users should not see disciplines by superusers. The function modifies the querysets of the corresponding base fields dynamically.
- Parameters:
request (django.http.request) – current user request
obj (django.db.models, optional) – django model object, defaults to None
- Returns:
model form with adjusted querysets
- Return type:
ModelForm
- get_list_display(request)
Return a sequence containing the fields to be displayed on the changelist.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see disciplines of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- list_display = ['tree_actions', 'indented_title', 'released', 'modules_released', 'modules_unreleased', 'words_released', 'creator_group']
- list_display_links = ['indented_title']
- list_filter = ['released']
- list_per_page = 25
- make_released(request, queryset)
Action to release discipline objects. It sets the corresponding boolean field to true.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- make_unreleased(request, queryset)
Action to hide discipline objects. It sets the corresponding boolean field to false.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- property media
- modules_released(obj)
returns HTML Tag of the link to released training sets related to the discipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
HTML Tag of the link to released training sets related to the discipline
- Return type:
- modules_unreleased(obj)
returns HTML Tag of the link to unreleased training sets related to the discipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
HTML Tag of the link to unreleased training sets related to the discipline
- Return type:
- readonly_fields = ['created_by', 'image_tag']
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (Discipline) – discipline object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['title']
- words_released(obj)
returns HTML Tag of the link to released words in the relased training sets related to the descipline
- Parameters:
obj (Discipline) – Discipline object
- Returns:
- Return type:
Document Admin
- class lunes_cms.cms.admins.document_admin.DocumentAdmin(model, admin_site)
Bases:
ModelAdmin
Admin Interface to for the Document module. Inheriting from admin.ModelAdmin.
- class Media
Bases:
object
Media class of admin interface for documents
- js = ('js/image_preview.js',)
- article_display(obj)
Include article of document in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- exclude = ('article_plural', 'creator_is_admin')
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_list_filter(request)
Override djangos get_list_filter function to remove specific list filters that are only relevant for super users.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see documents of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- has_audio(obj)
Include in list display whether a document has an audio file.
- Parameters:
obj (models.Document) – Document object
- Returns:
Either static admin group or user group
- Return type:
- has_image(obj)
Include in list display whether a document has an image file.
- Parameters:
obj (models.Document) – Document object
- Returns:
Whether the document has at least one confirmed image
- Return type:
- inlines = [<class 'lunes_cms.cms.admins.document_image_admin.DocumentImageAdmin'>, <class 'lunes_cms.cms.admins.alternative_word_admin.AlternativeWordAdmin'>]
- list_display = ('word', 'word_type', 'article_display', 'related_training_set', 'has_audio', 'has_image', 'creator_group', 'creation_date')
- list_filter = (<class 'lunes_cms.cms.list_filter.DocumentDisciplineListFilter'>, <class 'lunes_cms.cms.list_filter.DocumentTrainingSetListFilter'>, <class 'lunes_cms.cms.list_filter.AssignedListFilter'>, <class 'lunes_cms.cms.list_filter.ApprovedImageListFilter'>)
- list_per_page = 25
- property media
- ordering = ['word', 'creation_date']
- readonly_fields = ('created_by',)
Display related training sets in list display
- Parameters:
obj (models.Document) – Document object
- Returns:
comma seperated list of related training sets
- Return type:
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (models.Document) – document object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['word', 'alternatives__alt_word']
Document Image Admin
- class lunes_cms.cms.admins.document_image_admin.DocumentImageAdmin(parent_model, admin_site)
Bases:
StackedInline
Admin Interface to for the DocumentImage module. Inheriting from admin.StackedInline.
- autocomplete_fields = ['document']
- extra = 0
- fields = ['image', 'image_tag']
- get_fields(request, obj=None)
Override djangos get_fields function to add custom superuser fields to the admin interface if the user has the corresponding access rights.
- insert_after = 'autocomplete_fields'
- property media
- model
alias of
DocumentImage
- readonly_fields = ['image_tag']
- superuser_fields = ['confirmed']
Feedback Admin
- class lunes_cms.cms.admins.feedback_admin.FeedbackAdmin(model, admin_site)
Bases:
ModelAdmin
Admin interface for feedback. Inheriting from admin.ModelAdmin.
- actions = ['mark_as_read', 'mark_as_unread']
- has_add_permission(request, obj=None)
Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
- has_change_permission(request, obj=None)
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
- list_display = ['comment', 'content_object_link', 'content_type', 'created_date', 'read_by']
- list_filter = ['content_type', 'read_by']
- mark_as_read(request, queryset)
Action to mark selected items as read by user
- Parameters:
request (HttpRequest) – The current request
queryset (QuerySet) – The queryset of selected feedback entries
- mark_as_unread(request, queryset)
Action to mark selected items as unread
- Parameters:
request (HttpRequest) – The current request
queryset (QuerySet) – The queryset of selected feedback entries
- property media
- readonly_fields = ['comment', 'content_object_link', 'content_type', 'created_date', 'read_by']
- search_fields = ['comment']
- sortable_by = ['content_type', 'created_date', 'read_by']
Group API Key Admin
- class lunes_cms.cms.admins.group_api_key_admin.GroupAPIKeyAdmin(model, admin_site)
Bases:
ModelAdmin
Class for admin pannel of GroupAPIKey
- list_display = ['token', 'group', 'is_valid', 'expiry_date', 'qr_code_download_link']
- list_per_page = 25
- property media
- readonly_fields = ['is_valid', 'qr_code']
- search_fields = ['group']
Sponsor Admin
- class lunes_cms.cms.admins.sponsor_admin.SponsorAdmin(model, admin_site)
Bases:
ModelAdmin
Admin interface that is used to edit sponsor objects in the CMS.
- fields = ['name', 'url', 'logo', 'image_tag']
- has_logo(obj)
Additional field to display whether a logo is set for the sponsor in the list view.
- Returns:
Whether the sponsor has a logo
- Return type:
- image_tag(obj)
Image thumbnail to display a preview of a image in the form view.
- Returns:
img HTML tag to display an image thumbnail
- Return type:
- list_display = ['name', 'has_logo']
- list_per_page = 25
- property media
- readonly_fields = ['image_tag']
Training Set Admin
- class lunes_cms.cms.admins.training_set_admin.TrainingSetAdmin(model, admin_site)
Bases:
DraggableMPTTAdmin
Admin Interface to for the TrainigSet module. Inheriting from mptt.admin.DraggableMPTTAdmin.
- actions = ['make_released', 'make_unreleased']
- creator_group(obj)
Include creator group of discipline in list display
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
Either static admin group or user group
- Return type:
- exclude = ('creator_is_admin',)
- fields = ['released', 'title', 'description', 'icon', 'image_tag', 'documents', 'discipline', 'created_by']
- form
alias of
TrainingSetForm
- get_action_choices(request)
Overwrite django built-in function to modify action choices. The first option is dropped since it is a place holder.
- Parameters:
request (django.http.request) – current user request
- Returns:
modified action choices
- Return type:
- get_form(request, obj=None, **kwargs)
Overwrite django built-in function to define custom choices in many to many selectors, e.g. users should not see documents by superusers. The function modifies the querysets of the corresponding base fields dynamically.
- Parameters:
request (django.http.request) – current user request
obj (django.db.models, optional) – django model object, defaults to None
- Returns:
model form with adjusted querysets
- Return type:
ModelForm
- get_list_display(request)
Return a sequence containing the fields to be displayed on the changelist.
- get_queryset(request)
Overwrite django built-in function to modify queryset according to user. Users that are not superusers only see training set of their groups.
- Parameters:
request (django.http.request) – current user request
- Returns:
adjusted queryset
- Return type:
QuerySet
- list_display = ['tree_actions', 'title', 'released', 'words', 'words_released', 'words_unreleased', 'related_disciplines', 'creator_group']
- list_display_links = ['title']
- list_filter = [<class 'lunes_cms.cms.list_filter.DisciplineListFilter'>, 'released']
- list_per_page = 25
- make_released(request, queryset)
Action to release training set objects. It sets the corresponding boolean field to true.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- make_unreleased(request, queryset)
Action to hide discipline objects. It sets the corresponding boolean field to false.
- Parameters:
request (django.http.request) – current user request
queryset (QuerySet) – current queryset
- property media
- readonly_fields = ['created_by', 'image_tag']
Display related disciplines in list display
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
comma separated list of related disciplines
- Return type:
- save_model(request, obj, form, change)
Overwrite django built-in function to save user group and admin status of model
- Parameters:
request (django.http.request) – current user request
obj (TrainingSet) – training set object
form (ModelForm) – employed model form
change (bool) – True if change on existing model
- Raises:
IndexError – Error when user is not superuser and doesn’t belong to any group
- search_fields = ['title']
- words(obj)
returns HTML tag of the link to the list of words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the link to the list of words related to the training set
- Return type:
- words_released(obj)
returns HTML tag of the link to the list of released words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the link to the list of released words related to the training set
- Return type:
- words_unreleased(obj)
returns HTML tag of the Link to the list of unreleased words related to the training set
- Parameters:
obj (TrainingSet) – Training set object
- Returns:
HTML tag of the Link to the list of unreleased words related to the training set
- Return type: