remove django admin panel (#2731)
# What this PR does Disables the Django admin panel + removes the URLs associated with it **NOTE**: this doesn't affect things like `python manage.py createsuperuser` which are still needed for a few things ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
|
|
@ -1,71 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
from .models import (
|
||||
Alert,
|
||||
AlertGroup,
|
||||
AlertGroupLogRecord,
|
||||
AlertReceiveChannel,
|
||||
ChannelFilter,
|
||||
CustomButton,
|
||||
EscalationChain,
|
||||
EscalationPolicy,
|
||||
Invitation,
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Alert)
|
||||
class AlertAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "group", "title", "created_at")
|
||||
list_filter = ("created_at",)
|
||||
|
||||
|
||||
@admin.register(AlertGroup)
|
||||
class AlertGroupAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "web_title_cache", "channel", "channel_filter", "state", "started_at")
|
||||
list_filter = ("started_at",)
|
||||
|
||||
def get_queryset(self, request):
|
||||
return AlertGroup.objects
|
||||
|
||||
|
||||
@admin.register(AlertGroupLogRecord)
|
||||
class AlertGroupLogRecord(CustomModelAdmin):
|
||||
list_display = ("id", "alert_group", "escalation_policy", "type", "created_at")
|
||||
list_filter = ("created_at", "type")
|
||||
|
||||
|
||||
@admin.register(AlertReceiveChannel)
|
||||
class AlertReceiveChannelAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "integration", "token", "created_at", "deleted_at")
|
||||
list_filter = ("integration",)
|
||||
|
||||
def get_queryset(self, request):
|
||||
return AlertReceiveChannel.objects_with_deleted
|
||||
|
||||
|
||||
@admin.register(ChannelFilter)
|
||||
class ChannelFilterAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "alert_receive_channel", "escalation_chain", "filtering_term", "order")
|
||||
|
||||
|
||||
@admin.register(CustomButton)
|
||||
class CustomButtonModelAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "name", "webhook")
|
||||
|
||||
|
||||
@admin.register(EscalationChain)
|
||||
class EscalationChainAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "organization", "name")
|
||||
|
||||
|
||||
@admin.register(EscalationPolicy)
|
||||
class EscalationPolicyAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "escalation_chain", "step_type_verbal", "order")
|
||||
|
||||
|
||||
@admin.register(Invitation)
|
||||
class InvitationAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "alert_group", "author", "invitee", "is_active", "created_at")
|
||||
list_filter = ("is_active", "created_at")
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
from .models import DynamicSetting, FailedToInvokeCeleryTask, UserNotificationPolicy, UserNotificationPolicyLogRecord
|
||||
|
||||
admin.site.register(DynamicSetting)
|
||||
|
||||
|
||||
@admin.register(UserNotificationPolicy)
|
||||
class UserNotificationPolicyAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "user", "important", "short_verbal")
|
||||
|
||||
|
||||
@admin.register(UserNotificationPolicyLogRecord)
|
||||
class UserNotificationPolicyLogRecordAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "alert_group", "notification_policy", "author", "type", "created_at")
|
||||
list_filter = ("type", "created_at")
|
||||
|
||||
|
||||
@admin.register(FailedToInvokeCeleryTask)
|
||||
class FailedToInvokeCeleryTaskAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "name", "is_sent")
|
||||
list_filter = ("is_sent",)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from apps.schedules.models import OnCallSchedule
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
|
||||
@admin.register(OnCallSchedule)
|
||||
class OnCallScheduleAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "name")
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
from .models import SlackMessage, SlackTeamIdentity, SlackUserIdentity
|
||||
|
||||
|
||||
@admin.register(SlackTeamIdentity)
|
||||
class SlackTeamIdentityAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "slack_id", "cached_name", "datetime")
|
||||
list_filter = ("datetime",)
|
||||
|
||||
|
||||
@admin.register(SlackUserIdentity)
|
||||
class SlackUserIdentityAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "slack_id", "slack_team_identity", "cached_name", "cached_slack_email")
|
||||
|
||||
def get_queryset(self, request):
|
||||
return SlackUserIdentity.all_objects
|
||||
|
||||
|
||||
@admin.register(SlackMessage)
|
||||
class SlackMessageAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "slack_id", "_slack_team_identity", "alert_group", "created_at")
|
||||
list_filter = ("created_at",)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
from .models import Organization, Team, User
|
||||
|
||||
|
||||
@admin.register(User)
|
||||
class UserAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "organization", "username", "email")
|
||||
|
||||
|
||||
@admin.register(Team)
|
||||
class TeamAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "organization", "name")
|
||||
|
||||
|
||||
@admin.register(Organization)
|
||||
class OrganizationAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "org_title", "org_slug", "org_id", "stack_id")
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from common.admin import CustomModelAdmin
|
||||
|
||||
from .models import Webhook
|
||||
|
||||
|
||||
@admin.register(Webhook)
|
||||
class WebhookAdmin(CustomModelAdmin):
|
||||
list_display = ("id", "public_primary_key", "organization", "name", "url")
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
import typing
|
||||
|
||||
from django.contrib import admin
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from django.db.models import ForeignKey, Model
|
||||
|
||||
|
||||
class RawForeignKeysMixin:
|
||||
model: Model
|
||||
|
||||
@property
|
||||
def raw_id_fields(self) -> typing.Tuple[str, ...]:
|
||||
fields = self.model._meta.fields
|
||||
fk_field_names = tuple(str(field.name) for field in fields if isinstance(field, ForeignKey))
|
||||
|
||||
return fk_field_names
|
||||
|
||||
|
||||
class SearchableByIdsMixin:
|
||||
model: Model
|
||||
|
||||
@property
|
||||
def search_fields(self) -> typing.Tuple[str, ...]:
|
||||
search_fields = (
|
||||
"id",
|
||||
"public_primary_key",
|
||||
)
|
||||
|
||||
existing_fields: typing.List[str] = []
|
||||
|
||||
for field in search_fields:
|
||||
try:
|
||||
self.model._meta.get_field(field)
|
||||
except FieldDoesNotExist:
|
||||
continue
|
||||
|
||||
existing_fields.append(field)
|
||||
|
||||
return tuple(existing_fields)
|
||||
|
||||
|
||||
class SelectRelatedMixin:
|
||||
model: Model
|
||||
list_display: typing.Tuple[str, ...]
|
||||
|
||||
@property
|
||||
def list_select_related(self) -> typing.Tuple[str, ...]:
|
||||
fk_field_names = []
|
||||
|
||||
for field_name in self.list_display:
|
||||
try:
|
||||
field = self.model._meta.get_field(field_name)
|
||||
except FieldDoesNotExist:
|
||||
continue
|
||||
|
||||
if isinstance(field, ForeignKey):
|
||||
fk_field_names.append(str(field.name))
|
||||
|
||||
return tuple(fk_field_names)
|
||||
|
||||
|
||||
class CustomModelAdmin(SearchableByIdsMixin, RawForeignKeysMixin, SelectRelatedMixin, admin.ModelAdmin):
|
||||
pass
|
||||
|
|
@ -15,7 +15,6 @@ Including another URLconf
|
|||
"""
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
from .views import HealthCheckView, MaintenanceModeStatusView, ReadinessCheckView, StartupProbeView
|
||||
|
|
@ -31,7 +30,6 @@ paths_to_work_even_when_maintenance_mode_is_active = [
|
|||
|
||||
urlpatterns = [
|
||||
*paths_to_work_even_when_maintenance_mode_is_active,
|
||||
path(settings.ONCALL_DJANGO_ADMIN_PATH, admin.site.urls),
|
||||
path("api/gi/v1/", include("apps.api_for_grafana_incident.urls", namespace="api-gi")),
|
||||
path("api/internal/v1/", include("apps.api.urls", namespace="api-internal")),
|
||||
path("api/internal/v1/", include("social_django.urls", namespace="social")),
|
||||
|
|
@ -75,5 +73,3 @@ if settings.DEBUG:
|
|||
|
||||
if settings.SILK_PROFILER_ENABLED:
|
||||
urlpatterns += [path(settings.SILK_PATH, include("silk.urls", namespace="silk"))]
|
||||
|
||||
admin.site.site_header = settings.ADMIN_SITE_HEADER
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from common.utils import getenv_boolean, getenv_integer
|
|||
|
||||
VERSION = "dev-oss"
|
||||
SEND_ANONYMOUS_USAGE_STATS = getenv_boolean("SEND_ANONYMOUS_USAGE_STATS", default=True)
|
||||
ADMIN_ENABLED = False # disable django admin panel
|
||||
|
||||
# License is OpenSource or Cloud
|
||||
OPEN_SOURCE_LICENSE_NAME = "OpenSource"
|
||||
|
|
@ -527,11 +528,6 @@ if SILK_PROFILER_ENABLED:
|
|||
if "SILKY_PYTHON_PROFILER_RESULT_PATH" in os.environ:
|
||||
SILKY_PYTHON_PROFILER_RESULT_PATH = os.environ.get("SILKY_PYTHON_PROFILER_RESULT_PATH")
|
||||
|
||||
# get ONCALL_DJANGO_ADMIN_PATH from env and add trailing / to it
|
||||
ONCALL_DJANGO_ADMIN_PATH = os.environ.get("ONCALL_DJANGO_ADMIN_PATH", "django-admin") + "/"
|
||||
|
||||
ADMIN_SITE_HEADER = "OnCall Admin Panel"
|
||||
|
||||
# Social auth settings
|
||||
SOCIAL_AUTH_USER_MODEL = "user_management.User"
|
||||
SOCIAL_AUTH_STRATEGY = "apps.social_auth.live_setting_django_strategy.LiveSettingDjangoStrategy"
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 177 KiB |
|
Before Width: | Height: | Size: 289 KiB |
|
Before Width: | Height: | Size: 562 KiB |
|
Before Width: | Height: | Size: 640 KiB |
|
Before Width: | Height: | Size: 541 KiB |
|
Before Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 154 KiB |