Skip to content

Commit

Permalink
Add plugins to Django admin (#4707)
Browse files Browse the repository at this point in the history
* Add plugins to Django admin

* Enhance plugin admin

* Fix field name mistake
  • Loading branch information
Twixes authored Jun 11, 2021
1 parent aab9f03 commit 3ce6db4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions posthog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
FeatureFlag,
Organization,
Person,
Plugin,
PluginConfig,
Team,
User,
)
Expand All @@ -25,6 +27,28 @@
admin.site.register(DashboardItem)


@admin.register(Plugin)
class PluginAdmin(admin.ModelAdmin):
list_display = (
"id",
"name",
"organization_id",
"is_global",
)
list_filter = ("plugin_type", "is_global")
search_fields = ("name",)
ordering = ("-created_at",)


@admin.register(PluginConfig)
class PluginConfigAdmin(admin.ModelAdmin):
list_display = (
"plugin_id",
"team_id",
)
ordering = ("-created_at",)


@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
readonly_fields = ("timestamp",)
Expand Down
5 changes: 5 additions & 0 deletions posthog/models/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def get_default_config(self) -> Dict[str, Any]:
config[config_entry["key"]] = default
return config

def __str__(self) -> str:
return self.name

__repr__ = sane_repr("id", "name", "organization_id", "is_global")


class PluginConfig(models.Model):
team: models.ForeignKey = models.ForeignKey("Team", on_delete=models.CASCADE, null=True)
Expand Down

0 comments on commit 3ce6db4

Please sign in to comment.