Home Information - Your home, your data, organized.
Python
Initial HI Grid implementation and leading to editing mode. WIP.
Anthony Cassandra125407ef5486
diff --git a/src/hi/apps/common/antinode.py b/src/hi/apps/common/antinode.pyindex 897971d2..5d169a5a 100644--- a/src/hi/apps/common/antinode.py+++ b/src/hi/apps/common/antinode.py@@ -54,68 +54,68 @@ def redirect_response( url ):return http_response( { 'location': url } )-def response_as_dict( mainContent=None,- replaceMap=None,- insertMap=None,- appendMap=None,- modalContent=None,- pushUrl = None,- resetScrollbar = False ):+def response_as_dict( main_content = None,+ replace_map = None,+ insert_map = None,+ append_map = None,+ modal_content = None,+ push_url = None,+ reset_scrollbar = False ):"""In concert with the Javascript handling of synchronous replies,this will allow returning multiple pieces of content in one replyfor the cases where the request has altered more than one area- of the page. The 'mainContent' will be rendered in whatever- the 'data-async' value that was specified, while the 'replaceMap' should+ of the page. The 'main_content' will be rendered in whatever+ the 'data-async' value that was specified, while the 'replace_map' shouldbe a map from an html tag id to the html content to populate.- The 'replaceMap' is a full replacement of the previous content,+ The 'replace_map' is a full replacement of the previous content,so usually should have the same html tag id as what it replaces.- The 'insertMap' is used when you only want to replace the contents+ The 'insert_map' is used when you only want to replace the contentsof the given node and not the node itself.- The 'appendMap' is for content you want appended to the given id+ The 'append_map' is for content you want appended to the given idlist of child content."""response_dict = {}- if mainContent and isinstance( mainContent, HttpResponse ):- mainContent = mainContent.content.decode('utf-8' )+ if main_content and isinstance( main_content, HttpResponse ):+ main_content = main_content.content.decode('utf-8' )- if mainContent is not None:- response_dict['html'] = str(mainContent)- if replaceMap is not None:- response_dict['replace'] = replaceMap- if insertMap is not None:- response_dict['insert'] = insertMap- if appendMap is not None:- response_dict['append'] = appendMap- if modalContent is not None:- response_dict['modal'] = modalContent- if pushUrl is not None:- response_dict['pushUrl'] = pushUrl- if resetScrollbar:+ if main_content is not None:+ response_dict['html'] = str(main_content)+ if replace_map is not None:+ response_dict['replace'] = replace_map+ if insert_map is not None:+ response_dict['insert'] = insert_map+ if append_map is not None:+ response_dict['append'] = append_map+ if modal_content is not None:+ response_dict['modal'] = modal_content+ if push_url is not None:+ response_dict['pushUrl'] = push_url+ if reset_scrollbar:response_dict['resetScrollbar'] = 'true'return response_dict-def response( mainContent = None,- replaceMap = None,- insertMap = None,- appendMap = None,- modalContent = None,- pushUrl = None,- resetScrollbar = False,+def response( main_content = None,+ replace_map = None,+ insert_map = None,+ append_map = None,+ modal_content = None,+ push_url = None,+ reset_scrollbar = False,status = 200 ):- response_dict = response_as_dict( mainContent = mainContent,- replaceMap = replaceMap,- insertMap = insertMap,- appendMap = appendMap,- modalContent = modalContent,- pushUrl = pushUrl,- resetScrollbar = resetScrollbar,+ response_dict = response_as_dict( main_content = main_content,+ replace_map = replace_map,+ insert_map = insert_map,+ append_map = append_map,+ modal_content = modal_content,+ push_url = push_url,+ reset_scrollbar = reset_scrollbar,)return http_response( response_dict, status=status )diff --git a/src/hi/apps/config/templates/config/panes/home.html b/src/hi/apps/config/templates/config/panes/home.htmlindex f62d1f9f..b9c1043f 100644--- a/src/hi/apps/config/templates/config/panes/home.html+++ b/src/hi/apps/config/templates/config/panes/home.html@@ -18,7 +18,7 @@TBD for Settings</div><div class="tab-pane fade" id="hi-integrations" role="tabpanel" aria-labelledby="hi-integrations-tab">- <div id="hi-config-integration-tab">+ <div id="{{ DIVID.INTEGRATION_TAB }}">{% include "core/panes/config_tab.html" with integration_list=integration_list %}</div></div>diff --git a/src/hi/apps/config/views.py b/src/hi/apps/config/views.pyindex 7e12996e..00aa3414 100644--- a/src/hi/apps/config/views.py+++ b/src/hi/apps/config/views.py@@ -1,14 +1,17 @@-from django.shortcuts import render-from django.views.generic import View-+from hi.hi_grid_view import HiGridViewfrom hi.integrations.core.views import IntegrationViewMixin-class ConfigHomePaneView( View, IntegrationViewMixin ):+class ConfigHomePaneView( HiGridView, IntegrationViewMixin ):def get(self, request, *args, **kwargs):context = {}context.update( self.get_integration_config_tab_context() )- return render( request, 'config/panes/home.html', context )+ return self.hi_grid_response(+ request = request,+ context = context,+ main_template_name = 'config/panes/home.html',+ push_url_name = 'config_home_pane',+ )diff --git a/src/hi/apps/edit/__init__.py b/src/hi/apps/edit/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/src/hi/apps/edit/apps.py b/src/hi/apps/edit/apps.pynew file mode 100644index 00000000..2bff20b9--- /dev/null+++ b/src/hi/apps/edit/apps.py@@ -0,0 +1,6 @@+from django.apps import AppConfig+++class EditConfig(AppConfig):+ default_auto_field = "django.db.models.BigAutoField"+ name = "hi.apps.edit"diff --git a/src/hi/apps/edit/migrations/__init__.py b/src/hi/apps/edit/migrations/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/src/hi/apps/edit/templates/edit/panes/bottom.html b/src/hi/apps/edit/templates/edit/panes/bottom.htmlnew file mode 100644index 00000000..7514ec81--- /dev/null+++ b/src/hi/apps/edit/templates/edit/panes/bottom.html@@ -0,0 +1 @@+<h5>Edit Bottom</h5>diff --git a/src/hi/apps/edit/templates/edit/panes/main.html b/src/hi/apps/edit/templates/edit/panes/main.htmlnew file mode 100644index 00000000..410c7989--- /dev/null+++ b/src/hi/apps/edit/templates/edit/panes/main.html@@ -0,0 +1 @@+<h5>Edit Main</h5>diff --git a/src/hi/apps/edit/templates/edit/panes/side.html b/src/hi/apps/edit/templates/edit/panes/side.htmlnew file mode 100644index 00000000..b405d5e2--- /dev/null+++ b/src/hi/apps/edit/templates/edit/panes/side.html@@ -0,0 +1 @@+<h5>Edit Side</h5>diff --git a/src/hi/apps/edit/templates/edit/panes/top.html b/src/hi/apps/edit/templates/edit/panes/top.htmlnew file mode 100644index 00000000..49e8982b--- /dev/null+++ b/src/hi/apps/edit/templates/edit/panes/top.html@@ -0,0 +1,10 @@+<div class="row bg-white p-1">++ <div class="col-1">+ <a href="{% url 'edit_start' %}"+ class="btn btn-tertiary btn-control" role="button"+ data-async="true" >+ EXIT+ </a>+ </div>+</div>diff --git a/src/hi/apps/edit/urls.py b/src/hi/apps/edit/urls.pynew file mode 100644index 00000000..a3758b78--- /dev/null+++ b/src/hi/apps/edit/urls.py@@ -0,0 +1,11 @@+from django.urls import re_path++from . import views+++urlpatterns = [++ re_path( r'^$',+ views.EditStartView.as_view(),+ name='edit_start' ),+]diff --git a/src/hi/apps/edit/views.py b/src/hi/apps/edit/views.pynew file mode 100644index 00000000..f6fe3661--- /dev/null+++ b/src/hi/apps/edit/views.py@@ -0,0 +1,34 @@+from django.shortcuts import render+from django.template.loader import get_template+from django.views.generic import View++import hi.apps.common.antinode as antinode++from hi.constants import DIVID+++class EditStartView( View ):++ def get(self, request, *args, **kwargs):++ div_id_to_template_name = {+ DIVID['TOP'] : 'edit/panes/top.html',+ DIVID['BOTTOM'] : 'edit/panes/bottom.html',+ DIVID['MAIN'] : 'edit/panes/main.html',+ DIVID['SIDE'] : 'edit/panes/side.html',+ }++ context = {+ }++ insert_map = dict()+ for div_id, template_name in div_id_to_template_name.items():+ template = get_template( template_name )+ content = template.render( context, request = request )+ insert_map[div_id] = content,+ continue++ return antinode.response(+ insert_map = insert_map,+ )+diff --git a/src/hi/apps/location/templates/location/location_view_buttons.html b/src/hi/apps/location/templates/location/location_view_buttons.htmlindex 21d9a600..f824a573 100644--- a/src/hi/apps/location/templates/location/location_view_buttons.html+++ b/src/hi/apps/location/templates/location/location_view_buttons.html@@ -2,7 +2,7 @@<div class="col-1"><a href="{% url 'location_view' id=location_view.id %}"class="btn btn-primary btn-control" role="button"- data-async="#hi-main-content" >+ data-async="#{{ DIVID.MAIN }}" >{{ location_view.name }}</a></div>diff --git a/src/hi/apps/location/urls.py b/src/hi/apps/location/urls.pyindex d2c0b759..47923e8e 100644--- a/src/hi/apps/location/urls.py+++ b/src/hi/apps/location/urls.py@@ -9,4 +9,8 @@ urlpatterns = [views.LocationViewView.as_view(),name='location_view'),+ re_path( r'^view$',+ views.LocationViewDefaultView.as_view(),+ name='location_view_default'),+]diff --git a/src/hi/apps/location/views.py b/src/hi/apps/location/views.pyindex 9212fa96..bff220b5 100644--- a/src/hi/apps/location/views.py+++ b/src/hi/apps/location/views.py@@ -1,16 +1,63 @@-from django.shortcuts import render+import logging++from django.http import HttpResponseRedirect+from django.urls import reversefrom django.views.generic import View-from .models import LocationView+from hi.hi_grid_view import HiGridView++from .models import Location, LocationView++logger = logging.getLogger(__name__)+++class LocationViewDefaultView( View ):++ def get(self, request, *args, **kwargs):++ location_view = self._get_default_location_view( request )+ redirect_url = reverse(+ 'location_view',+ kwargs = { 'id': location_view.id }+ )+ return HttpResponseRedirect( redirect_url )++ def _get_default_location_view( self, request ):+ if request.view_parameters.location_view:+ return request.view_parameters.location_view+ location = Location.objects.order_by( 'order_id' ).first()+ if not location:+ raise NotImplementedError('Handling no defined locations not yet implemengted')++ location_view = location.views.order_by( 'order_id' ).first()+ if not location_view:+ raise NotImplementedError('Handling no defined views not yet implemengted')-class LocationViewView( View ):+ request.view_parameters.location_view_id = location_view.id+ request.view_parameters.to_session( request )+ return location_view+++class LocationViewView( HiGridView ):def get(self, request, *args, **kwargs):location_view_id = kwargs.get('id')- current_location_view = LocationView.objects.select_related( 'location' ).get( id = location_view_id )+ try:+ current_location_view = LocationView.objects.select_related(+ 'location' ).get( id = location_view_id )+ except LocationView.DoesNotExist:+ logger.warning( f'Location view "{location_view_id}" does not exist.' )+ raise NotImplementedError('Handling bad location view not yet implemengted')+context = {'current_location_view': current_location_view,}- return render( request, 'location/location_view.html', context )+ return self.hi_grid_response(+ request = request,+ context = context,+ main_template_name = 'location/location_view.html',+ push_url_name = 'location_view',+ push_url_kwargs = kwargs,+ )diff --git a/src/hi/constants.py b/src/hi/constants.pynew file mode 100644index 00000000..99ff2ca5--- /dev/null+++ b/src/hi/constants.py@@ -0,0 +1,9 @@++# HTML div ids that are commonly referenced+DIVID = {+ 'TOP': 'hi-top-content',+ 'BOTTOM': 'hi-bottom-content',+ 'MAIN': 'hi-main-content',+ 'SIDE': 'hi-side-content',+ 'INTEGRATION_TAB': 'hi-config-integration-tab',+}diff --git a/src/hi/context_processors.py b/src/hi/context_processors.pynew file mode 100644index 00000000..e435910a--- /dev/null+++ b/src/hi/context_processors.py@@ -0,0 +1,5 @@+from .constants import DIVID+++def constants_context(request):+ return { 'DIVID': DIVID }diff --git a/src/hi/enums.py b/src/hi/enums.pynew file mode 100644index 00000000..1d63834a--- /dev/null+++ b/src/hi/enums.py@@ -0,0 +1,8 @@+from hi.apps.common.enums import LabeledEnum+++class ViewMode(LabeledEnum):++ INFORMATION = ('Information', '' )+ CONTROL = ('Control', '' )+ EDIT = ('Edit', '' )diff --git a/src/hi/hi_grid_view.py b/src/hi/hi_grid_view.pynew file mode 100644index 00000000..5849b847--- /dev/null+++ b/src/hi/hi_grid_view.py@@ -0,0 +1,102 @@+import logging+from typing import Dict++from django.http import HttpRequest+from django.shortcuts import render+from django.template import Context+from django.template.loader import get_template+from django.urls import NoReverseMatch+from django.urls import reverse+from django.views.generic import View++import hi.apps.common.antinode as antinode+from hi.apps.common.utils import is_ajax++from hi.constants import DIVID++logger = logging.getLogger(__name__)+++class HiGridView(View):++ """+ - Helpers for views that use the main "HI Grid View" layout.+ - The HI Grid view layout has the top and bottom fixed rows (usually buttons)+ and main panel and a side panel.+ - Helps to populate areas asynchronously, but can handle sychconous requests too.+ - Good for views that populate all or just some of the tiled areas of the HIU Grid.+ - Main HI Grid layout defined in the template: pages/hi_grid.html+ """++ HI_GRID_TEMPLATE_NAME = 'pages/home.html'+ TOP_TEMPLATE_NAME = 'panes/top_buttons.html'+ BOTTOM_TEMPLATE_NAME = 'panes/bottom_buttons.html'+ MAIN_TEMPLATE_NAME = 'panes/main_default.html'+ SIDE_TEMPLATE_NAME = 'panes/side_panel.html'++ def hi_grid_response( self,+ request : HttpRequest,+ context : Context,+ top_template_name : str = None,+ bottom_template_name : str = None,+ main_template_name : str = None,+ side_template_name : str = None,+ push_url_name : str = None,+ push_url_kwargs : Dict[ str, str ] = None ):+ if not context:+ context = dict()++ if not is_ajax( request ):+ # For full syncronous render, we need all content, so we fill+ # in defaults for any missing.+ if not top_template_name:+ top_template_name = self.TOP_TEMPLATE_NAME+ if not bottom_template_name:+ bottom_template_name = self.BOTTOM_TEMPLATE_NAME+ if not main_template_name:+ main_template_name = self.MAIN_TEMPLATE_NAME+ if not side_template_name:+ side_template_name = self.SIDE_TEMPLATE_NAME+ context.update({+ 'top_template_name': top_template_name,+ 'bottom_template_name': bottom_template_name,+ 'main_template_name': main_template_name,+ 'side_template_name': side_template_name,+ })++ # This list of views is needed for top buttons+ if ( request.view_parameters.location_view+ and 'location_view_list' not in context ):+ location = request.view_parameters.location_view.location+ location_view_list = list( location.views.order_by( 'order_id' ))+ context['location_view_list'] = location_view_list++ return render( request, self.HI_GRID_TEMPLATE_NAME, context )++ div_id_to_template_name = {+ DIVID['TOP'] : top_template_name,+ DIVID['BOTTOM'] : bottom_template_name,+ DIVID['MAIN'] : main_template_name,+ DIVID['SIDE'] : side_template_name,+ }+ insert_map = dict()+ for div_id, template_name in div_id_to_template_name.items():+ if not template_name:+ continue+ template = get_template( template_name )+ content = template.render( context, request = request )+ insert_map[div_id] = content,+ continue++ push_url = None+ if push_url_name:+ try:+ push_url = reverse( push_url_name, kwargs = push_url_kwargs )+ except NoReverseMatch:+ logger.warning( f'No reverse url for {push_url_name}' )+ pass++ return antinode.response(+ insert_map = insert_map,+ push_url = push_url,+ )diff --git a/src/hi/integrations/core/templates/core/panes/config_tab.html b/src/hi/integrations/core/templates/core/panes/config_tab.htmlindex 1b467aeb..b6fd7296 100644--- a/src/hi/integrations/core/templates/core/panes/config_tab.html+++ b/src/hi/integrations/core/templates/core/panes/config_tab.html@@ -25,14 +25,14 @@<div class="col-2">{% if integration.is_enabled %}<form action="{% url 'integration_config' name=integration.integration_type.name action='disable' %}"- method="POST" role="form" data-async="#hi-config-integration-tab">+ method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">{% csrf_token %}<button type="submit" class="btn btn-danger btn-control" role="button"">DISABLE</button></form>{% else %}<form action="{% url 'integration_config' name=integration.integration_type.name action='enable' %}"- method="POST" role="form" data-async="#hi-config-integration-tab">+ method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">{% csrf_token %}<button type="submit" class="btn btn-success btn-control" role="button" >ENABLE</button></form>@@ -42,7 +42,7 @@{% if integration.is_enabled %}<a href="{% url 'integration_manage' name=integration.integration_type.name %}"class="btn btn-info btn-control" role="button"- data-async="#hi-config-integration-tab" >+ data-async="#{{ DIVID.INTEGRATION_TAB }}" >MANAGE</a></form>diff --git a/src/hi/middleware.py b/src/hi/middleware.pynew file mode 100644index 00000000..d07995d0--- /dev/null+++ b/src/hi/middleware.py@@ -0,0 +1,22 @@+from constance import config+import logging++from .view_parameters import ViewParameters++logger = logging.getLogger(__name__)+++class ViewMiddleware:++ def __init__(self, get_response):+ self.get_response = get_response+ return++ def __call__(self, request):+ self._set_view_parameters( request )+ return self.get_response( request )++ def _set_view_parameters( self, request ):+ request.view_parameters = ViewParameters.from_session( request )+ return+diff --git a/src/hi/settings/base.py b/src/hi/settings/base.pyindex 1f4c28bd..ab0b1ffd 100644--- a/src/hi/settings/base.py+++ b/src/hi/settings/base.py@@ -142,6 +142,7 @@ INSTALLED_APPS = ['hi.apps.collection','hi.apps.sense','hi.apps.control',+ 'hi.apps.edit','hi.integrations.core','hi.integrations.zoneminder','hi.integrations.hass',@@ -156,6 +157,7 @@ MIDDLEWARE = ['django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',+ 'hi.middleware.ViewMiddleware',]ROOT_URLCONF = 'hi.urls'@@ -171,6 +173,7 @@ TEMPLATES = ['django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',+ 'hi.context_processors.constants_context',],},},diff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.cssindex 1cb5d6eb..3cbac081 100644--- a/src/hi/static/css/main.css+++ b/src/hi/static/css/main.css@@ -128,11 +128,11 @@ a.underline:visited {background-color: var(--muted-color) !important;}-.hi-top-buttons {+.hi-top-content {height: var(--top-buttons-height);border-bottom: 1px solid var(--line-color);}-.hi-bottom-buttons {+.hi-bottom-content {height: var(--bottom-buttons-height);border-top: 1px solid var(--line-color);}diff --git a/src/hi/templates/pages/home.html b/src/hi/templates/pages/home.htmlindex a6e9ec4a..fd445dfb 100644--- a/src/hi/templates/pages/home.html+++ b/src/hi/templates/pages/home.html@@ -2,24 +2,24 @@{% block content %}-<div class="fixed-top">- {% include "panes/top_buttons.html" %}+<div id="{{ DIVID.TOP }}" class="fixed-top">+ {% include top_template_name %}</div>-<div class="fixed-bottom">- {% include "panes/bottom_buttons.html" %}+<div id="{{ DIVID.BOTTOM }}" class="fixed-bottom">+ {% include bottom_template_name %}</div><div class="container-fluid hi-screen"><div class="row"><div class="col-9 scrollable-column ">- <div id="hi-main-content">- {% include "location/location_view.html" %}+ <div id="{{ DIVID.MAIN }}">+ {% include main_template_name %}</div></div><div class="col-3 fixed-column">- <div id="hi-side-content">- {% include "panes/side_panel.html" %}+ <div id="{{ DIVID.SIDE }}">+ {% include side_template_name %}</div></div></div>diff --git a/src/hi/templates/pages/main_default.html b/src/hi/templates/pages/main_default.htmlnew file mode 100644index 00000000..4521ba10--- /dev/null+++ b/src/hi/templates/pages/main_default.html@@ -0,0 +1 @@+<h5>Home Information</h5>diff --git a/src/hi/templates/panes/bottom_buttons.html b/src/hi/templates/panes/bottom_buttons.htmlindex ebe5b7c8..90bbbba4 100644--- a/src/hi/templates/panes/bottom_buttons.html+++ b/src/hi/templates/panes/bottom_buttons.html@@ -1,4 +1,4 @@-<div class="hi-bottom-buttons row bg-white p-1">+<div class="row bg-white p-1"><div class="col-1"><div class="btn btn-secondary btn-control" role="button">BUTTON 1diff --git a/src/hi/templates/panes/side_panel.html b/src/hi/templates/panes/side_panel.htmlindex 9a279ecf..a5493170 100644--- a/src/hi/templates/panes/side_panel.html+++ b/src/hi/templates/panes/side_panel.html@@ -1,11 +1,19 @@<div class="border-left" >SIDE PANEL-<div class="">- <a href="{% url 'config_home_pane' %}"- class="btn btn-tertiary btn-control" role="button"- data-async="#hi-main-content" >- ADMIN- </a>-</div>-++ <div class="">+ <a href="{% url 'config_home_pane' %}"+ class="btn btn-tertiary btn-control" role="button"+ data-async="true" >+ ADMIN+ </a>+ </div>+ <div class="">+ <a href="{% url 'edit_start' %}"+ class="btn btn-tertiary btn-control" role="button"+ data-async="true" >+ EDIT+ </a>+ </div>+</div>diff --git a/src/hi/templates/panes/top_buttons.html b/src/hi/templates/panes/top_buttons.htmlindex 1873876f..f5608b6f 100644--- a/src/hi/templates/panes/top_buttons.html+++ b/src/hi/templates/panes/top_buttons.html@@ -1,3 +1,3 @@-<div class="hi-top-buttons row bg-white p-1">+<div class="row bg-white p-1">{% include "location/location_view_buttons.html" %}</div>diff --git a/src/hi/urls.py b/src/hi/urls.pyindex 62398b14..6b58eb2f 100644--- a/src/hi/urls.py+++ b/src/hi/urls.py@@ -27,6 +27,7 @@ urlpatterns = [re_path( r'^index.html$', views.HomeView.as_view(), name='home_index' ),re_path( r'^config/', include('hi.apps.config.urls' )),+ re_path( r'^edit/', include('hi.apps.edit.urls' )),re_path( r'^integration/', include('hi.integrations.core.urls' )),re_path( r'^location/', include('hi.apps.location.urls' )),diff --git a/src/hi/view_parameters.py b/src/hi/view_parameters.pynew file mode 100644index 00000000..0d0bbb69--- /dev/null+++ b/src/hi/view_parameters.py@@ -0,0 +1,54 @@+from dataclasses import dataclass++from hi.apps.location.models import LocationView++from .enums import ViewMode+++@dataclass+class ViewParameters:++ location_view_id : int = None+ view_mode : ViewMode = None++ def __post_init__(self):+ self._location_view = None # Lazy loaded+ return++ @property+ def location_view(self):+ if self._location_view:+ return self._location_view+ if self.location_view_id is None:+ return None+ try:+ self._location_view = LocationView.objects.get( id = self.location_view_id )+ return self._location_view+ except LocationView.DoesNotExist:+ return None++ def to_session( self, request ):+ if not hasattr( request, 'session' ):+ return+ request.session['location_view_id'] = self.location_view_id+ request.session['view_mode'] = str(self.view_mode)+ return++ @staticmethod+ def from_session( request ):+ if not request:+ return ViewParameters()+ if not hasattr( request, 'session' ):+ return ViewParameters()+ try:+ location_view_id = int( request.session.get( 'location_view_id' ))+ except ( TypeError, ValueError ):+ location_view_id = None++ view_mode = ViewMode.from_name_safe( name = request.session.get( 'view_mode' ))++ return ViewParameters(+ location_view_id = location_view_id,+ view_mode = view_mode,+ )+diff --git a/src/hi/views.py b/src/hi/views.pyindex a3dad398..6ae3f217 100644--- a/src/hi/views.py+++ b/src/hi/views.py@@ -1,8 +1,8 @@+from django.http import HttpResponseRedirectfrom django.shortcuts import render+from django.urls import reversefrom django.views.generic import View-from hi.apps.location.models import Location-def home_javascript_files( request, filename ):return render(request, filename, {}, content_type = "text/javascript")@@ -12,12 +12,5 @@ class HomeView( View ):def get(self, request, *args, **kwargs):- location = Location.objects.order_by( 'order_id' ).first()- location_view_list = list( location.views.order_by( 'order_id' ))- current_location_view = location_view_list[0]-- context = {- 'current_location_view': current_location_view,- 'location_view_list': location_view_list,- }- return render( request, 'pages/home.html', context )+ redirect_url = reverse( 'location_view_default' )+ return HttpResponseRedirect( redirect_url )