Skip to content

Commit

Permalink
Split app.views into several files
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Apr 25, 2024
1 parent 5483c96 commit 161c79c
Show file tree
Hide file tree
Showing 15 changed files with 2,361 additions and 2,239 deletions.
1,388 changes: 0 additions & 1,388 deletions mesads/app/views.py

This file was deleted.

35 changes: 35 additions & 0 deletions mesads/app/views/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.urls import reverse
from django.views.generic import RedirectView

from .ads import ( # noqa: F401
ADSDecreeView,
ADSHistoryView,
ADSCreateView,
ADSDeleteView,
ADSView,
)
from .ads_manager import ADSManagerView, ads_manager_decree_view # noqa: F401
from .ads_manager_admin import PrefectureExportView, ADSManagerExportView # noqa: F401
from .ads_manager_request import ( # noqa: F401
ADSManagerRequestView,
ADSManagerAdminView,
)
from .dashboards import DashboardsView, DashboardsDetailView # noqa: F401
from .public import ( # noqa: F401
FAQView,
StatsView,
ReglementationView,
HTTP500View,
HomepageView,
)


class ADSRegisterView(RedirectView):
"""Redirect to the appropriate dashboard depending on the user's role."""

def get_redirect_url(self, *args, **kwargs):
if self.request.user.is_staff:
return reverse("app.dashboards.list")
if len(self.request.user.adsmanageradministrator_set.all()):
return reverse("app.ads-manager-admin.index")
return reverse("app.ads-manager.index")
Loading

0 comments on commit 161c79c

Please sign in to comment.