courses.admin

Add models to interface.

Module Contents

class courses.admin.UserAdmin

Bases: django.contrib.auth.admin.UserAdmin

Add moodle id to the User Admin interface.

courses.admin.manual_inactivity(modeladmin, request, queryset)

Add an option to manually check the inactivity.

Parameters
  • modeladmin (CourseAdmin) – Representation of a model in the admin interface. Not being used.

  • request (WSGIRequest) – HttpRequest representing the current request. Not being used.

  • queryset (QuerySet) – Class containing the set of objects selected by the user.

courses.admin.short_description = Perform inactivity check.

Description that is displayed in the user interface

courses.admin.manual_deadline(modeladmin, request, queryset)

Add an option to manually check the deadlines.

Parameters
  • modeladmin (CourseAdmin) – Representation of a model in the admin interface. Not being used.

  • request (WSGIRequest) – HttpRequest representing the current request. Not being used.

  • queryset (QuerySet) – Class containing the set of objects selected by the user.

courses.admin.short_description = Perform upcoming deadline check.

Description that is displayed in the user interface

class courses.admin.ResourceInline

Bases: django.contrib.admin.TabularInline

Create the horizontal resource layout for the internal resource.

get_queryset(self, request)

Overwrite the standard get_queryset function, to only select the resources that are internal.

Parameters

request (WSGIRequest) – The get_queryset request. Not being used.

Returns

All the resources that are internal.

Return type

QuerySet

has_change_permission(self, request, obj=None)

Overwrite the standard has_change_permission function, to make it read-only.

Parameters
  • request (WSGIRequest) – The has_change_permission request. Not being used.

  • obj (Course) – The Course object. Not being used.

Returns

False, everything here is read-only.

Return type

bool

has_add_permission(self, request, obj=None)

Overwrite the standard has_add_permission function, to remove add resource button.

Parameters
  • request (WSGIRequest) – The has_add_permission request. Not being used.

  • obj (Course) – The Course object. Not being used.

Returns

False, no objects should be added, since they are loaded from Moodle.

Return type

bool

has_delete_permission(self, request, obj=None)

Overwrite the standard has_delete_permission function, to remove delete resource button.

Parameters
  • request (WSGIRequest) – The has_delete_permission request. Not being used.

  • obj (Course) – The Course object. Not being used.

Returns

False, nothing should be deleted from Mofa since it is loaded from Moodle.

Return type

bool

class courses.admin.ResourceInlineExternal

Bases: django.contrib.admin.TabularInline

Create the horizontal resource layout for external resource.

get_queryset(self, request)

Overwrite the standard get_queryset function, to only select the resources that are external.

Parameters

request (WSGIRequest) – The get_queryset request.

Returns

All the resources that are external.

Return type

QuerySet

class courses.admin.ResourceSubjForm(*args, **kwargs)

Bases: django.forms.ModelForm

Create resource form and sort them alphabetically.

class courses.admin.QuestionForm(*args, **kwargs)

Bases: django.forms.ModelForm

Display only the resources of the course of the quiz questions.

class courses.admin.QuestionInline

Bases: django.contrib.admin.TabularInline

Create questions horizontal layout.

has_add_permission(self, request, obj=None)

Overwrite the standard has_add_permission function, to remove add content button.

Parameters
  • request (WSGIRequest) – The has_add_permission request.

  • obj (Question) – The Question object. Not being used.

Returns

False, no objects should be added, since they are loaded from Moodle.

has_delete_permission(self, request, obj=None)

Overwrite the standard has_delete_permission function, to remove delete content button.

Parameters
  • request (WSGIRequest) – The has_delete_permission request.

  • obj (Question) – The Question object. Not being used.

Returns

False, nothing should be deleted from Mofa since it is loaded from Moodle.

class courses.admin.AssessmentAdmin

Bases: django.contrib.admin.ModelAdmin

Abstract class that filter queryset and checks permissions.

get_queryset(self, request)

Filter queryset to only show assessments the user has access to.

Parameters

request (WSGIRequest) – The get_queryset request.

Returns

All the assessments a user has access to.

Return type

QuerySet

has_view_or_change_permission(self, request, obj=None)

Restrict the user from viewing/changing assessments the user has access to.

Parameters
  • request (WSGIRequest) – The has_view_or_change_permission request.

  • obj (Assessment) – The Assessment object

Returns

Whether this user can access this Assessment.

Return type

QuerySet

has_delete_permission(self, request, obj=None)

Restrict the user from deleting this assistant if no permission was given.

has_add_permission(self, request)

Set add permission on false. Assessments are loaded from Moodle, should not be added manually.

Parameters

request (WSGIRequest) – The add_permission request.

Returns

False, disable add permissions.

Return type

bool

class courses.admin.QuizAdmin

Bases: courses.admin.AssessmentAdmin

Admin page for quizzes.

class Media

Include extra css.

class courses.admin.CourseAdmin

Bases: django.contrib.admin.ModelAdmin

Whitelist the parameters shown in the admin panel. Add the manual actions.

class Media

Include extra css.

delete_queryset(self, request, queryset)

Call delete on every course individually when deleting multiple courses.

Parameters
  • request (WSGIRequest) – The delete_queryset request.

  • queryset (QuerySet) – All selected courses

has_view_or_change_permission(self, request, obj=None)

Restrict the user from viewing/changing courses the user has access to.

Parameters
  • request (WSGIRequest) – The has_view_or_change_permission request.

  • obj (Course) – The course object.

Returns

Whether this user can access this Course.

Return type

bool

get_queryset(self, request)

Filter queryset to only show courses the user has access to.

Parameters

request (WSGIRequest) – The get_queryset request.

Returns

All courses a user has access to.

Return type

QuerySet

has_add_permission(self, request)

Set add_permission on false. Courses are loaded from Moodle, should not be added manually.

Parameters

request (WSGIRequest) – The add_permission request.

Returns

False, disable add permissions.

Return type

bool

class courses.admin.SubjectAdmin

Bases: django.contrib.admin.ModelAdmin

Admin page for subjects.

get_queryset(self, request)

Filter queryset to only show subjects the user has access to.

Parameters

request (WSGIRequestf) – The get_queryset request.

Returns

QuerySet filter on whether a user has access to this subject.

Return type

QuerySet

has_view_or_change_permission(self, request, obj=None)

Restrict the user from viewing/changing this subject if no permission was given.

Parameters

request (WSGIRequest) – The has_view_or_change_permission request.

Returns

Bool whether or not a user can access the subject.

Return type

bool

has_add_permission(self, request)

Restrict the user from adding an subject if no permission was given.

Parameters

request (WSGIRequest) – The has_add_permission request.

Returns

Bool whether or not a user can add a new subject.

Return type

bool

has_delete_permission(self, request, obj=None)

Restrict the user from deleting this subject if no permission was given.

Parameters

request (WSGIRequest) – The has_delete_permission request.

Returns

Bool whether or not a user can delete a subject.

Return type

bool

formfield_for_foreignkey(self, db_field, request, **kwargs)

Filter the dropdown for choosing the course (based on the courses that the user can edit).

Parameters
  • request (WSGIRequest) – The formfield_for_foreignkey request.

  • db_field (QuerySet) – The db_field of the dropdown menu.

Returns

QuerySet for corresponding dropdown menu.

Return type

QuerySet

static warnings(obj)

Add warnings to an subject when there is no statement forwarder of the assistant in LL.

Parameters

obj (Subject) – The subject object.

Returns

A warning when a subject has no resource.

Return type

str

class courses.admin.AssignmentAdmin

Bases: courses.admin.AssessmentAdmin

Admin page for assignment.

class courses.admin.ChoiceAdmin

Bases: courses.admin.AssessmentAdmin

Admin page for assignment.