Class based views
* refactors method based views for parcel fetching, home and logout to class based
This commit is contained in:
		
							parent
							
								
									60b6968436
								
							
						
					
					
						commit
						345b266422
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1,5 @@
 | 
			
		||||
# Project exclude paths
 | 
			
		||||
/venv/
 | 
			
		||||
/.idea/
 | 
			
		||||
/.coverage
 | 
			
		||||
/htmlcov/
 | 
			
		||||
 | 
			
		||||
@ -19,17 +19,17 @@ from django.urls import path, include
 | 
			
		||||
 | 
			
		||||
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
 | 
			
		||||
from konova.sso.sso import KonovaSSOClient
 | 
			
		||||
from konova.views.logout import logout_view
 | 
			
		||||
from konova.views.geometry import get_geom_parcels, get_geom_parcels_content
 | 
			
		||||
from konova.views.home import home_view
 | 
			
		||||
from konova.views.logout import LogoutView
 | 
			
		||||
from konova.views.geometry import GeomParcelsView, GeomParcelsContentView
 | 
			
		||||
from konova.views.home import HomeView
 | 
			
		||||
from konova.views.map_proxy import ClientProxyParcelSearch, ClientProxyParcelWFS
 | 
			
		||||
 | 
			
		||||
sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
    path('admin/', admin.site.urls),
 | 
			
		||||
    path('login/', include(sso_client.get_urls())),
 | 
			
		||||
    path('logout/', logout_view, name="logout"),
 | 
			
		||||
    path('', home_view, name="home"),
 | 
			
		||||
    path('logout/', LogoutView.as_view(), name="logout"),
 | 
			
		||||
    path('', HomeView.as_view(), name="home"),
 | 
			
		||||
    path('intervention/', include("intervention.urls")),
 | 
			
		||||
    path('compensation/', include("compensation.urls")),
 | 
			
		||||
    path('ema/', include("ema.urls")),
 | 
			
		||||
@ -38,8 +38,8 @@ urlpatterns = [
 | 
			
		||||
    path('cl/', include("codelist.urls")),
 | 
			
		||||
    path('analysis/', include("analysis.urls")),
 | 
			
		||||
    path('api/', include("api.urls")),
 | 
			
		||||
    path('geom/<id>/parcels/', get_geom_parcels, name="geometry-parcels"),
 | 
			
		||||
    path('geom/<id>/parcels/<int:page>', get_geom_parcels_content, name="geometry-parcels-content"),
 | 
			
		||||
    path('geom/<id>/parcels/', GeomParcelsView.as_view(), name="geometry-parcels"),
 | 
			
		||||
    path('geom/<id>/parcels/<int:page>', GeomParcelsContentView.as_view(), name="geometry-parcels-content"),
 | 
			
		||||
    path('client/proxy', ClientProxyParcelSearch.as_view(), name="client-proxy-search"),
 | 
			
		||||
    path('client/proxy/wfs', ClientProxyParcelWFS.as_view(), name="client-proxy-wfs"),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
@ -5,16 +5,20 @@ Contact: ksp-servicestelle@sgdnord.rlp.de
 | 
			
		||||
Created on: 19.08.22
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
from django.contrib.auth.mixins import LoginRequiredMixin
 | 
			
		||||
from django.contrib.gis.geos import MultiPolygon
 | 
			
		||||
from django.http import HttpResponse, HttpRequest
 | 
			
		||||
from django.shortcuts import get_object_or_404
 | 
			
		||||
from django.template.loader import render_to_string
 | 
			
		||||
from django.views import View
 | 
			
		||||
 | 
			
		||||
from konova.models import Geometry, Municipal
 | 
			
		||||
from konova.models import Geometry
 | 
			
		||||
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_geom_parcels(request: HttpRequest, id: str):
 | 
			
		||||
class GeomParcelsView(LoginRequiredMixin, View):
 | 
			
		||||
 | 
			
		||||
    def get(self, request: HttpRequest, id: str):
 | 
			
		||||
        """ Getter for HTMX
 | 
			
		||||
 | 
			
		||||
        Returns all parcels of the requested geometry rendered into a simple HTML table
 | 
			
		||||
@ -66,7 +70,9 @@ def get_geom_parcels(request: HttpRequest, id: str):
 | 
			
		||||
            return HttpResponse(None, status=404)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_geom_parcels_content(request: HttpRequest, id: str, page: int):
 | 
			
		||||
class GeomParcelsContentView(LoginRequiredMixin, View):
 | 
			
		||||
 | 
			
		||||
    def get(self, request: HttpRequest, id: str, page: int):
 | 
			
		||||
        """ Getter for infinite scroll of HTMX
 | 
			
		||||
 | 
			
		||||
        Returns parcels of a specific page/slice of the found parcel set.
 | 
			
		||||
 | 
			
		||||
@ -5,12 +5,13 @@ Contact: ksp-servicestelle@sgdnord.rlp.de
 | 
			
		||||
Created on: 19.08.22
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
from django.contrib.auth.decorators import login_required
 | 
			
		||||
from django.contrib.auth.mixins import LoginRequiredMixin
 | 
			
		||||
from django.db.models import Q
 | 
			
		||||
from django.http import HttpRequest
 | 
			
		||||
from django.shortcuts import render
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
from django.utils.decorators import method_decorator
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.views import View
 | 
			
		||||
 | 
			
		||||
from compensation.models import EcoAccount, Compensation
 | 
			
		||||
from intervention.models import Intervention
 | 
			
		||||
@ -20,9 +21,10 @@ from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
 | 
			
		||||
from news.models import ServerMessage
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@login_required
 | 
			
		||||
@any_group_check
 | 
			
		||||
def home_view(request: HttpRequest):
 | 
			
		||||
class HomeView(LoginRequiredMixin, View):
 | 
			
		||||
 | 
			
		||||
    @method_decorator(any_group_check)
 | 
			
		||||
    def get(self, request: HttpRequest):
 | 
			
		||||
        """
 | 
			
		||||
        Renders the landing page
 | 
			
		||||
 | 
			
		||||
@ -33,7 +35,6 @@ def home_view(request: HttpRequest):
 | 
			
		||||
            A redirect
 | 
			
		||||
        """
 | 
			
		||||
        template = "konova/home.html"
 | 
			
		||||
    now = timezone.now()
 | 
			
		||||
        user = request.user
 | 
			
		||||
        user_teams = user.shared_teams
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8,11 +8,13 @@ Created on: 19.08.22
 | 
			
		||||
from django.contrib.auth import logout
 | 
			
		||||
from django.http import HttpRequest
 | 
			
		||||
from django.shortcuts import redirect
 | 
			
		||||
from django.views import View
 | 
			
		||||
 | 
			
		||||
from konova.sub_settings.sso_settings import SSO_SERVER_BASE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def logout_view(request: HttpRequest):
 | 
			
		||||
class LogoutView(View):
 | 
			
		||||
    def get(self, request: HttpRequest):
 | 
			
		||||
        """
 | 
			
		||||
        Logout route for ending the session manually.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user