Skip to content

Commit

Permalink
fix(admin): add separate group type mapping admin (#26471)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Nov 27, 2024
1 parent c4d23ac commit 3ef40c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions posthog/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
DataWarehouseTableAdmin,
ProjectAdmin,
HogFunctionAdmin,
GroupTypeMappingAdmin,
)
from posthog.models import (
Organization,
Expand All @@ -43,6 +44,7 @@
Survey,
DataWarehouseTable,
HogFunction,
GroupTypeMapping,
)

admin.site.register(Organization, OrganizationAdmin)
Expand All @@ -53,6 +55,7 @@
admin.site.register(Dashboard, DashboardAdmin)
admin.site.register(DashboardTemplate, DashboardTemplateAdmin)
admin.site.register(Insight, InsightAdmin)
admin.site.register(GroupTypeMapping, GroupTypeMappingAdmin)

admin.site.register(Experiment, ExperimentAdmin)
admin.site.register(FeatureFlag, FeatureFlagAdmin)
Expand Down
1 change: 1 addition & 0 deletions posthog/admin/admins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .data_warehouse_table_admin import DataWarehouseTableAdmin
from .experiment_admin import ExperimentAdmin
from .feature_flag_admin import FeatureFlagAdmin
from .group_type_mapping_admin import GroupTypeMappingAdmin
from .insight_admin import InsightAdmin
from .instance_setting_admin import InstanceSettingAdmin
from .organization_admin import OrganizationAdmin
Expand Down
25 changes: 25 additions & 0 deletions posthog/admin/admins/group_type_mapping_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.contrib import admin
from django.utils.html import format_html

from posthog.models.group_type_mapping import GroupTypeMapping


class GroupTypeMappingAdmin(admin.ModelAdmin):
list_display = (
"group_type_index",
"group_type",
"name_singular",
"name_plural",
"team_link",
)
list_select_related = ("team", "team__organization")
search_fields = ("name_singular", "team__name", "team__organization__name")
readonly_fields = ("team", "project", "group_type", "group_type_index")

@admin.display(description="Team")
def team_link(self, group_type_mapping: GroupTypeMapping):
return format_html(
'<a href="/admin/posthog/team/{}/change/">{}</a>',
group_type_mapping.team.pk,
group_type_mapping.team.name,
)
1 change: 1 addition & 0 deletions posthog/admin/inlines/group_type_mapping_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class GroupTypeMappingInline(admin.TabularInline):
classes = ("collapse",)
max_num = 5
min_num = 5
show_change_link = True

0 comments on commit 3ef40c6

Please sign in to comment.