-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathadmin.py
More file actions
42 lines (35 loc) · 1.16 KB
/
admin.py
File metadata and controls
42 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Django Admin pages for Collection models.
"""
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from .models import Collection
class CollectionAdmin(admin.ModelAdmin):
"""
The Collection model admin.
Allows users to easily disable/enable (aka soft delete and restore) or bulk delete Collections.
"""
readonly_fields = ["collection_code", "learning_package"]
list_filter = ["enabled"]
list_display = ["collection_code", "title", "enabled", "modified"]
fieldsets = [
(
"",
{
"fields": ["collection_code", "learning_package"],
}
),
(
_("Edit only in Studio"),
{
"fields": ["title", "enabled", "description", "created_by"],
"description": _("⚠ Changes made here should be done in Studio Django Admin, not the LMS."),
}
),
]
def has_add_permission(self, request, *args, **kwargs):
"""
Disallow adding new collections via Django Admin.
"""
return False # pragma: no cover
admin.site.register(Collection, CollectionAdmin)