Skip to content

Commit f923b73

Browse files
committed
Listing page for DREF national societi actions
1 parent 7b5983c commit f923b73

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

dref/admin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ def has_delete_permission(self, *args, **kwargs):
3030

3131
@admin.register(NationalSocietyAction)
3232
class NationalSocietyActionAdmin(ReadOnlyMixin, admin.ModelAdmin):
33-
search_fields = ["title"]
33+
34+
def descr(self, obj):
35+
return obj.description.replace("-", "")[:190]
36+
37+
def related_dref(self, obj):
38+
return "/".join([dref.title for dref in obj.dref_set.all()])
39+
40+
search_fields = ["title", "description"]
41+
list_display = ["id", "title", "descr", "related_dref"]
42+
list_filter = ["title"]
3443

3544

3645
@admin.register(RiskSecurity)

dref/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class Meta:
4949
verbose_name = _("national society action")
5050
verbose_name_plural = _("national society actions")
5151

52+
def __str__(self) -> str:
53+
desc = self.description_en.replace("-", "").strip()[:60] + "..."
54+
return "%d (%s) %s" % (self.id, self.title, desc)
55+
5256
@staticmethod
5357
def get_image_map(title, request):
5458
title_static_map = {

0 commit comments

Comments
 (0)