-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
302 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.conf import settings | ||
from django.urls import reverse | ||
|
||
|
||
def get_admin_url(instance) -> str: | ||
""" | ||
任意のモデルインスタンスの管理ページURLを生成する。 | ||
""" | ||
model_name = instance._meta.model_name | ||
app_label = instance._meta.app_label | ||
admin_url = reverse(f"admin:{app_label}_{model_name}_change", args=[instance.pk]) | ||
|
||
# フルURLにするために現在のサイトドメインを取得 | ||
full_admin_url = f"{settings.ADMIN_DOMAIN_URL}{admin_url}" | ||
|
||
return full_admin_url | ||
|
||
|
||
def get_admin_history_url(instance) -> str: | ||
""" | ||
任意のモデルインスタンスの管理ページURLを生成する。 | ||
""" | ||
model_name = instance._meta.model_name | ||
app_label = instance._meta.app_label | ||
admin_url = reverse(f"admin:{app_label}_{model_name}_history", args=[instance.pk]) | ||
|
||
# フルURLにするために現在のサイトドメインを取得 | ||
admin_history_url = f"{settings.ADMIN_DOMAIN_URL}{admin_url}" | ||
|
||
return admin_history_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
class CustomAdmin(AppConfig): | ||
name = "ip" | ||
verbose_name = "IP" | ||
|
||
def ready(self): | ||
from . import signals # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from django.db.models.signals import post_save, pre_delete | ||
from django.dispatch import receiver | ||
|
||
from dsbd.notify import notify_delete_db, notify_insert_db, notify_update_db | ||
from ip.models import IP, IPJPNICUser, JPNICUser | ||
|
||
|
||
@receiver(post_save, sender=JPNICUser) | ||
def post_jpnic_user(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=JPNICUser) | ||
def delete_jpnic_user(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(post_save, sender=IP) | ||
def post_ip(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=IP) | ||
def delete_ip(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(post_save, sender=IPJPNICUser) | ||
def post_ip_jpnic_user(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=IPJPNICUser) | ||
def delete_ip_jpnic_user(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
class CustomAdmin(AppConfig): | ||
name = "noc" | ||
verbose_name = "NOC" | ||
|
||
def ready(self): | ||
from . import signals # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.db.models.signals import post_save, pre_delete | ||
from django.dispatch import receiver | ||
|
||
from dsbd.notify import notify_delete_db, notify_insert_db, notify_update_db | ||
from noc.models import NOC | ||
|
||
|
||
@receiver(post_save, sender=NOC) | ||
def post_noc(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=NOC) | ||
def delete_noc(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
class Notice(AppConfig): | ||
name = "notice" | ||
verbose_name = "通知" | ||
|
||
def ready(self): | ||
from . import signals # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.db.models.signals import post_save, pre_delete | ||
from django.dispatch import receiver | ||
|
||
from dsbd.notify import notify_delete_db, notify_insert_db, notify_update_db | ||
from notice.models import Notice | ||
|
||
|
||
@receiver(post_save, sender=Notice) | ||
def post_notice(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=Notice) | ||
def delete_notice(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.db.models.signals import post_save, pre_delete | ||
from django.dispatch import receiver | ||
|
||
from dsbd.notify import notify_delete_db, notify_insert_db, notify_update_db | ||
from router.models import TunnelIP, TunnelRouter | ||
|
||
|
||
@receiver(post_save, sender=TunnelRouter) | ||
def post_tunnel_router(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=TunnelRouter) | ||
def delete_tunnel_router(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(post_save, sender=TunnelIP) | ||
def post_tunnel_ip(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=TunnelIP) | ||
def delete_tunnel_ip(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.db.models.signals import post_save, pre_delete | ||
from django.dispatch import receiver | ||
|
||
from dsbd.notify import notify_delete_db, notify_insert_db, notify_update_db | ||
from service.models import Connection, Service | ||
|
||
|
||
@receiver(post_save, sender=Service) | ||
def post_service(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=Service) | ||
def delete_service(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(post_save, sender=Connection) | ||
def post_connection(sender, instance, created, **kwargs): | ||
if created: | ||
notify_insert_db(model_name=sender.__name__, instance=instance) | ||
return | ||
notify_update_db(model_name=sender.__name__, instance=instance) | ||
|
||
|
||
@receiver(pre_delete, sender=Connection) | ||
def delete_connection(sender, instance, **kwargs): | ||
notify_delete_db(model_name=sender.__name__, instance=instance) |
Oops, something went wrong.