-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from CentreForDigitalHumanities/feature/admin
Feature/admin
- Loading branch information
Showing
19 changed files
with
698 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Annotation, Publication | ||
from .models import ( | ||
Annotation, | ||
ArticleTerm, | ||
ContinuationAnnotation, | ||
LidiaTerm, | ||
Publication, | ||
Language, | ||
TermGroup, | ||
Category, | ||
) | ||
|
||
|
||
class ContinuationInline(admin.TabularInline): | ||
model = ContinuationAnnotation | ||
fk_name = "start_annotation" | ||
ordering = ("sort_index",) | ||
fields = ["textselection", "sort_index"] | ||
extra = 0 | ||
|
||
|
||
class TermGroupInline(admin.TabularInline): | ||
model = TermGroup | ||
fk_name = "annotation" | ||
ordering = ("index",) | ||
fields = ["termtype", "articleterm", "category", "lidiaterm"] | ||
extra = 0 | ||
|
||
|
||
class AnnotationAdmin(admin.ModelAdmin): | ||
pass | ||
list_display = ["zotero_annotation", "lidia_id", "parent_attachment", "argname", "arglang", "page_start"] | ||
list_filter = ["parent_attachment", "arglang"] | ||
ordering = ("parent_attachment", "sort_index") | ||
inlines = [ | ||
ContinuationInline, | ||
TermGroupInline, | ||
] | ||
|
||
|
||
class PublicationAdmin(admin.ModelAdmin): | ||
pass | ||
list_display = ["zotero_id", "attachment_id", "title"] | ||
|
||
|
||
admin.site.register(Annotation, AnnotationAdmin) | ||
admin.site.register(Publication, PublicationAdmin) | ||
admin.site.register(Language) | ||
admin.site.register(Category) | ||
admin.site.register(LidiaTerm) | ||
admin.site.register(ArticleTerm) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.contrib.auth.models import Group, Permission | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Create user groups that allow viewing all or restricted "\ | ||
"annotation data" | ||
|
||
def handle(self, *args, **options): | ||
# For now, only create a 'view all' group - no distinction yet | ||
# between all or restricted access | ||
view_all, _ = Group.objects.get_or_create(name="view_all") | ||
models = [ | ||
'publication', 'language', 'annotation', 'articleterm', | ||
'lidiaterm', 'category', 'termgroup' | ||
] | ||
permissions = [] | ||
for model in models: | ||
permissions.append(Permission.objects.get_by_natural_key( | ||
"view_" + model, "lidia", model | ||
)) | ||
view_all.permissions.add(*permissions) |
Oops, something went wrong.