Commit 45d578f0 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Only register important models for the admin

parent 5dce6d52
from django.contrib import admin
from django.apps import apps
from . import models
b = apps.get_app_config('backend')
# register all models of the app
for _, model in b.models.items():
admin.site.register(model)
# from django.apps import apps
# b = apps.get_app_config('backend')
#
# # register all models of the app
# for _, model in b.models.items():
# admin.site.register(model)
admin.site.register(models.User)
admin.site.register(models.Site)
admin.site.register(models.Service)
......@@ -195,6 +195,14 @@ class SSHPublicKey(models.Model):
return self.name
@receiver(post_save, sender=SSHPublicKey)
def delete_old_ssh_key(
sender, instance=None, created=False, **kwargs):
if instance.deleted and len(instance.deployments.all()) == 0:
instance.delete()
class Deployment(models.Model):
user = models.ForeignKey(
User,
......
Markdown is supported
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