46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from django.conf import settings
|
|
from django.urls import reverse_lazy
|
|
|
|
from core.models.auth import IPLimit
|
|
from core.views.backend.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
|
|
|
|
class RateLimitListView(BackendListView):
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/firewall/index.html"
|
|
model = IPLimit
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context["title"] = "Firewall Settings"
|
|
return context
|
|
|
|
class RateLimitEditView(BackendUpdateView):
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/firewall/update.html"
|
|
model = IPLimit
|
|
success_url = reverse_lazy("ratelimits")
|
|
fields = ["ip", "end", "reason"]
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context["title"] = "Edit Rule"
|
|
return context
|
|
|
|
class RateLimitDeleteView(BackendDeleteView):
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/firewall/delete.html"
|
|
model = IPLimit
|
|
success_url = reverse_lazy("ratelimits")
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context["title"] = "Delete Rule"
|
|
return context
|
|
|
|
class RateLimitCreateView(BackendCreateView):
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/firewall/create.html"
|
|
model = IPLimit
|
|
success_url = reverse_lazy("ratelimits")
|
|
fields = ["ip", "end", "reason"]
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context["title"] = "Create Rule"
|
|
return context
|