diff --git a/peeringmanager/admin.py b/peeringmanager/admin.py index 7fe972d..b01d026 100644 --- a/peeringmanager/admin.py +++ b/peeringmanager/admin.py @@ -10,7 +10,5 @@ class RouterAdmin(admin.ModelAdmin): @admin.register(Peering) class PeeringAdmin(admin.ModelAdmin): - list_display = ['asn', 'router', 'vpn_type', 'endpoint', 'endpoint_internal_v4', - 'endpoint_internal_v6', 'router_endpoint_internal_v6', 'mbgp_enabled'] - - list_filter = ['router', 'vpn_type'] + list_display = ['asn', 'router', 'active', 'mbgp_enabled', 'endpoint', 'last_up'] + list_filter = ['active', 'mbgp_enabled', 'router'] diff --git a/peeringmanager/models.py b/peeringmanager/models.py index b1fcf48..dccbbdd 100644 --- a/peeringmanager/models.py +++ b/peeringmanager/models.py @@ -39,6 +39,9 @@ class Peering(models.Model): ('wireguard', _('Wireguard')), ) + active = models.BooleanField(default=True, verbose_name=_('Active')) + last_up = models.DateTimeField(auto_now_add=True, verbose_name=_('Last seen up')) + owner = models.ForeignKey(get_user_model(), verbose_name=_('Owner'), on_delete=models.SET_NULL, null=True, blank=True) diff --git a/peeringmanager/views.py b/peeringmanager/views.py index f455df7..c912fc3 100644 --- a/peeringmanager/views.py +++ b/peeringmanager/views.py @@ -4,6 +4,7 @@ from django.views.generic.detail import DetailView from django.views.generic import TemplateView from django.utils.decorators import method_decorator +from django.utils import timezone from django.contrib.auth.decorators import login_required from django.core.exceptions import ValidationError from autopeer.mixins import AuthenticatedRedirectMixin @@ -111,6 +112,8 @@ def get_form_kwargs(self): return kwargs def form_valid(self, form): + form.instance.active = True + form.instance.last_up = timezone.now() form.instance.owner = self.request.user if not form.instance.wg_privkey or not form.instance.wg_pubkey: