Verified Commit d48175b5 authored by Philipp Sebastian Sommer's avatar Philipp Sebastian Sommer
Browse files

add admin for topicrelation

parent 9d438d77
Pipeline #135474 passed with stage
in 6 minutes and 6 seconds
......@@ -36,6 +36,61 @@ class TopicMembershipInline(admin.TabularInline):
model = models.TopicMembership
class LeftTopicRelationInline(admin.TabularInline):
"""An inline for topic relations."""
model = models.TopicRelation
fk_name = "left"
class RightTopicRelationInline(admin.TabularInline):
"""An inline for topic relations."""
model = models.TopicRelation
fk_name = "right"
@admin.register(models.TopicRelation)
class TopicRelationAdmin(
ManagerAdminMixin, GuardedModelAdmin, CompareVersionAdmin
):
"""An admin for the :model:`topics.TopicRelation` model."""
list_display = ["__str__", "left", "relation_type", "right"]
list_editable = ["relation_type"]
search_fields = [
"left_name",
"left_id_name",
"left_leader__first_name",
"left_leader__last_name",
"left_leader__email__email",
"left_lead_organization__name",
"left_lead_organization__institution__abbreviation",
"left_lead_organization__department__abbreviation",
"left_lead_organization__unit__abbreviation",
"left_lead_organization__institution__city__name",
"left_lead_organization__institution__city__country__name",
"left_lead_organization__institution__city__country__code",
"relation_type__icontains",
"right_name",
"right_id_name",
"right_leader__first_name",
"right_leader__last_name",
"right_leader__email__email",
"right_lead_organization__name",
"right_lead_organization__institution__abbreviation",
"right_lead_organization__department__abbreviation",
"right_lead_organization__unit__abbreviation",
"right_lead_organization__institution__city__name",
"right_lead_organization__institution__city__country__name",
"right_lead_organization__institution__city__country__code",
]
@admin.register(models.Topic)
class TopicAdmin(ManagerAdminMixin, GuardedModelAdmin, CompareVersionAdmin):
"""Administration class for the :model:`topics.Topic` model."""
......@@ -57,7 +112,11 @@ class TopicAdmin(ManagerAdminMixin, GuardedModelAdmin, CompareVersionAdmin):
list_filter = ["activities", "start_date", "end_date"]
form = forms.TopicAdminForm
inlines = [TopicMembershipInline]
inlines = [
TopicMembershipInline,
LeftTopicRelationInline,
RightTopicRelationInline,
]
search_fields = [
"name",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment