-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ! name and description to DeduplicationSet
del ! error from DeduplicationSet chg ! admin panel
- Loading branch information
1 parent
abf647b
commit 9496b7f
Showing
10 changed files
with
175 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
from .deduplicationset import DeduplicationSetAdmin # noqa | ||
from .duplicate import DuplicateAdmin # noqa | ||
from .hdetoken import HDETokenAdmin # noqa | ||
from .image import ImageAdmin # noqa |
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,45 @@ | ||
from django.contrib.admin import ModelAdmin, register | ||
|
||
from adminfilters.dates import DateRangeFilter | ||
from adminfilters.filters import ChoicesFieldComboFilter, DjangoLookupFilter | ||
from adminfilters.mixin import AdminFiltersMixin | ||
|
||
from hope_dedup_engine.apps.api.models import DeduplicationSet | ||
|
||
|
||
@register(DeduplicationSet) | ||
class DeduplicationSetAdmin(AdminFiltersMixin, ModelAdmin): | ||
list_display = ( | ||
"id", | ||
"short_name", | ||
"reference_pk", | ||
"state", | ||
"created_at", | ||
"updated_at", | ||
"deleted", | ||
) | ||
readonly_fields = ( | ||
"id", | ||
"state", | ||
"external_system", | ||
"created_at", | ||
"created_by", | ||
"updated_at", | ||
"updated_by", | ||
"deleted", | ||
) | ||
search_fields = ("name",) | ||
list_filter = ( | ||
("state", ChoicesFieldComboFilter), | ||
("created_at", DateRangeFilter), | ||
("updated_at", DateRangeFilter), | ||
DjangoLookupFilter, | ||
) | ||
|
||
def short_name(self, obj): | ||
if obj.name: | ||
return (obj.name[:50] + "...") if len(obj.name) > 50 else obj.name | ||
return "-" | ||
|
||
def has_add_permission(self, request): | ||
return False |
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,35 @@ | ||
from django.contrib.admin import ModelAdmin, register | ||
|
||
from adminfilters.filters import ( | ||
DjangoLookupFilter, | ||
NumberFilter, | ||
RelatedFieldComboFilter, | ||
) | ||
from adminfilters.mixin import AdminFiltersMixin | ||
|
||
from hope_dedup_engine.apps.api.models import Duplicate | ||
|
||
|
||
@register(Duplicate) | ||
class DuplicateAdmin(AdminFiltersMixin, ModelAdmin): | ||
list_display = ( | ||
"id", | ||
"deduplication_set", | ||
"score", | ||
"first_reference_pk", | ||
"second_reference_pk", | ||
) | ||
list_filter = ( | ||
("deduplication_set", RelatedFieldComboFilter), | ||
("score", NumberFilter), | ||
DjangoLookupFilter, | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False |
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,8 @@ | ||
from django.contrib.admin import ModelAdmin, register | ||
|
||
from hope_dedup_engine.apps.api.models import HDEToken | ||
|
||
|
||
@register(HDEToken) | ||
class HDETokenAdmin(ModelAdmin): | ||
pass |
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,32 @@ | ||
from django.contrib.admin import ModelAdmin, register | ||
|
||
from adminfilters.dates import DateRangeFilter | ||
from adminfilters.filters import DjangoLookupFilter, RelatedFieldComboFilter | ||
from adminfilters.mixin import AdminFiltersMixin | ||
|
||
from hope_dedup_engine.apps.api.models import Image | ||
|
||
|
||
@register(Image) | ||
class ImageAdmin(AdminFiltersMixin, ModelAdmin): | ||
list_display = ( | ||
"id", | ||
"filename", | ||
"deduplication_set", | ||
"created_at", | ||
) | ||
|
||
list_filter = ( | ||
("deduplication_set", RelatedFieldComboFilter), | ||
("created_at", DateRangeFilter), | ||
DjangoLookupFilter, | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_delete_permission(self, request, obj=None): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False |
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
29 changes: 29 additions & 0 deletions
29
src/hope_dedup_engine/apps/api/migrations/0003_remove_deduplicationset_error_and_more.py
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,29 @@ | ||
# Generated by Django 5.0.7 on 2024-09-20 08:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("api", "0002_remove_duplicate_first_filename_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="deduplicationset", | ||
name="error", | ||
), | ||
migrations.AddField( | ||
model_name="deduplicationset", | ||
name="description", | ||
field=models.TextField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name="deduplicationset", | ||
name="name", | ||
field=models.CharField( | ||
blank=True, db_index=True, max_length=128, null=True, unique=True | ||
), | ||
), | ||
] |
17 changes: 0 additions & 17 deletions
17
src/hope_dedup_engine/apps/api/migrations/0003_remove_deduplicationset_name.py
This file was deleted.
Oops, something went wrong.
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