Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/admin #7

Merged
merged 25 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9941bba
Activate custom admin site
tijmenbaarda Nov 6, 2023
f25852b
Activate password reset views
tijmenbaarda Nov 6, 2023
7893f88
Basic admin enrichment
tijmenbaarda Nov 6, 2023
7e2f793
Add admin command for group creation
tijmenbaarda Nov 7, 2023
38f5001
Upgrade dependencies
tijmenbaarda Nov 7, 2023
30f973d
Remove debug leftover
tijmenbaarda Nov 7, 2023
88fc917
Remove tuple-creating comma
tijmenbaarda Nov 7, 2023
b50b548
Outfactor populate script
tijmenbaarda Nov 7, 2023
5183031
Add migration file
tijmenbaarda Nov 7, 2023
231c81f
Use correct field names in YAML repr
tijmenbaarda Nov 7, 2023
99bd318
Ignore non-LIDIA annotations
tijmenbaarda Nov 7, 2023
1fe9ea2
Add LIDIA ID and use in relations
tijmenbaarda Nov 7, 2023
37acdf1
Find language names for codes
tijmenbaarda Nov 7, 2023
7aad1f6
Add admin forms for missing models
tijmenbaarda Nov 7, 2023
f03e096
Avoid creation of languages with empty-string code
tijmenbaarda Nov 7, 2023
12ca760
Include the sort index
tijmenbaarda Nov 7, 2023
332bea8
Change zotero_id to OneToOneField
tijmenbaarda Nov 7, 2023
89d3cfb
Make sure leftover placeholders are deleted
tijmenbaarda Nov 7, 2023
69f4f09
Change admin URL to site root
tijmenbaarda Nov 7, 2023
4cbf304
Generate term groups
tijmenbaarda Nov 8, 2023
f5abf64
Remove leftover print()
tijmenbaarda Nov 8, 2023
6c9a903
Remove argcont field from Annotation
tijmenbaarda Nov 8, 2023
c533e40
Install setuptools on Python>=3.12
tijmenbaarda Nov 8, 2023
369dff9
Use typing: ignore instead of noqa
tijmenbaarda Nov 10, 2023
58f4bb7
Restructure imports
tijmenbaarda Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install setuptools # requirement for iso639-lang on Python>=3.12
- name: Lint with ruff
run: |
pip install ruff
Expand Down
41 changes: 38 additions & 3 deletions lidiabrowser/lidia/admin.py
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.
22 changes: 22 additions & 0 deletions lidiabrowser/lidia/management/commands/initgroups.py
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)
Loading