Skip to content

Home Information - Your home, your data, organized.

Python

Refactor entity views: info, details, status, state history.

Anthony Cassandra96078352eb55
diff --git a/src/hi/apps/collection/collection_manager.py b/src/hi/apps/collection/collection_manager.py
index bbc3120a..c2f637b7 100644
--- a/src/hi/apps/collection/collection_manager.py
+++ b/src/hi/apps/collection/collection_manager.py
@@ -11,7 +11,6 @@ from hi.apps.entity.models import Entity
from hi.apps.location.models import Location, LocationView
from hi.apps.location.svg_item_factory import SvgItemFactory
-from .enums import CollectionType, CollectionViewType
from .models import (
Collection,
CollectionEntity,
@@ -65,18 +64,18 @@ class CollectionManager(Singleton):
entity_manager = EntityManager()
- entity_info_data_list = list()
+ entity_status_data_list = list()
for collection_entity in collection.entities.all().order_by('order_id'):
- entity_info_data = entity_manager.get_entity_info_data(
+ entity_status_data = entity_manager.get_entity_status_data(
entity = collection_entity.entity,
is_editing = is_editing,
)
- entity_info_data_list.append( entity_info_data )
+ entity_status_data_list.append( entity_status_data )
continue
return CollectionData(
collection = collection,
- entity_info_data_list = entity_info_data_list,
+ entity_status_data_list = entity_status_data_list,
)
def create_collection_entity( self,
diff --git a/src/hi/apps/collection/edit/views.py b/src/hi/apps/collection/edit/views.py
index 7f3d88f1..0a1727ff 100644
--- a/src/hi/apps/collection/edit/views.py
+++ b/src/hi/apps/collection/edit/views.py
@@ -262,9 +262,7 @@ class CollectionEntityToggleView( View, CollectionViewMixin, EntityViewMixin ):
collection = collection,
is_editing = request.is_editing,
)
- context = {
- 'collection_data': collection_data,
- }
+ context = collection_data.to_template_context()
template = get_template( 'collection/panes/collection_view.html' )
collection_content = template.render( context, request = request )
diff --git a/src/hi/apps/collection/enums.py b/src/hi/apps/collection/enums.py
index cf10f0c0..5974242d 100644
--- a/src/hi/apps/collection/enums.py
+++ b/src/hi/apps/collection/enums.py
@@ -29,3 +29,9 @@ class CollectionViewType(LabeledEnum):
GRID = ( 'Grid', '' )
LIST = ( 'List', '' )
+ def is_grid(self):
+ return self == CollectionViewType.GRID
+
+ def is_list(self):
+ return self == CollectionViewType.LIST
+
diff --git a/src/hi/apps/collection/templates/collection/panes/collection_view.html b/src/hi/apps/collection/templates/collection/panes/collection_view.html
index f9b9a779..80a53d2f 100644
--- a/src/hi/apps/collection/templates/collection/panes/collection_view.html
+++ b/src/hi/apps/collection/templates/collection/panes/collection_view.html
@@ -1,43 +1,32 @@
<div id="hi-collection-view-main" class="hi-collection-view draggable-container">
- <h5><sub>COLLECTION:</sub> {{ collection_data.collection.name }}</h5>
+ <h5><sub>COLLECTION:</sub> {{ collection.name }}</h5>
+ {% if collection.collection_view_type.is_grid %}
<div class="row">
- {% for entity_info_data in collection_data.entity_info_data_list %}
- {% with entity=entity_info_data.entity %}
- <div id="{{ entity.html_id }}"
+ {% for entity_status_data in entity_status_data_list %}
+ <div id="{{ entity_status_data.entity.html_id }}"
class="col-4 {% if request.is_editing %}draggable{% endif %}"
- {% if request.is_editing %}draggable="true"{% endif %}
- >
- <div>
- {% if request.is_editing %}
- <a href="{% url 'entity_details' entity_id=entity.id %}"
- data-async="true">
- {{ entity.name }}
- </a>
- {% else %}
- <a href="{% url 'entity_info' entity_id=entity.id %}"
- data-async="true">
- {{ entity.name }}
- </a>
- {% endif %}
- </div>
- <div>
- Controls
- </div>
- <div>
- <h5>Sensor Responses</h5>
- <ul>
- {% for sensor, sensor_response in entity_info_data.sensor_response_map.items %}
- <li>Sensor: {{ sensor.name }}, Response: {{ sensor_response.value }}</li>
- {% empty %}
- <div><em>No sensors</em></div>
- {% endfor %}
- </ul>
- </div>
+ {% if request.is_editing %}draggable="true"{% endif %} >
+ {% include "entity/panes/entity_status_card.html" with entity_status_data=entity_status_data %}
</div>
- {% endwith %}
{% empty %}
<div><em>No entities in collection.</em></div>
- {% endfor %}
+ {% endfor %}
</div>
+
+ {% else %}
+
+ {% for entity_status_data in entity_status_data_list %}
+ <div id="{{ entity_status_data.entity.html_id }}"
+ class="{% if request.is_editing %}draggable{% endif %}"
+ {% if request.is_editing %}draggable="true"{% endif %} >
+ {% include "entity/panes/entity_status_row.html" with entity_status_data=entity_status_data %}
+ </div>
+ {% empty %}
+ <div><em>No entities in collection.</em></div>
+ {% endfor %}
+
+ {% endif %}
+
</div>
+
diff --git a/src/hi/apps/collection/transient_models.py b/src/hi/apps/collection/transient_models.py
index f9bccf96..924e690c 100644
--- a/src/hi/apps/collection/transient_models.py
+++ b/src/hi/apps/collection/transient_models.py
@@ -4,7 +4,7 @@ from typing import List
from hi.apps.collection.edit.forms import CollectionForm, CollectionPositionForm
from hi.apps.entity.enums import EntityType
from hi.apps.entity.models import Entity
-from hi.apps.entity.transient_models import EntityInfoData
+from hi.apps.entity.transient_models import EntityStatusData
from .models import Collection
@@ -12,8 +12,14 @@ from .models import Collection
@dataclass
class CollectionData:
- collection : Collection
- entity_info_data_list : List[ EntityInfoData ]
+ collection : Collection
+ entity_status_data_list : List[ EntityStatusData ]
+
+ def to_template_context(self):
+ return {
+ 'collection': self.collection,
+ 'entity_status_data_list': self.entity_status_data_list,
+ }
@dataclass
diff --git a/src/hi/apps/collection/views.py b/src/hi/apps/collection/views.py
index 54ee1fe2..3af67e3c 100644
--- a/src/hi/apps/collection/views.py
+++ b/src/hi/apps/collection/views.py
@@ -65,11 +65,9 @@ class CollectionViewView( HiGridView, CollectionViewMixin ):
collection = collection,
is_editing = request.is_editing,
)
- return {
- 'is_async_request': is_ajax( request ),
- 'collection': collection,
- 'collection_data': collection_data,
- }
+ context = collection_data.to_template_context()
+ context['is_async_request'] = is_ajax( request )
+ return context
class CollectionDetailsView( HiSideView, CollectionViewMixin ):
diff --git a/src/hi/apps/entity/entity_manager.py b/src/hi/apps/entity/entity_manager.py
index dd8d1cb9..331bf572 100644
--- a/src/hi/apps/entity/entity_manager.py
+++ b/src/hi/apps/entity/entity_manager.py
@@ -23,8 +23,9 @@ from .models import (
)
from .transient_models import (
EntityDetailsData,
- EntityInfoData,
EntityEditData,
+ EntityStateHistoryData,
+ EntityStatusData,
EntityViewGroup,
EntityViewItem,
)
@@ -32,18 +33,17 @@ from .transient_models import (
class EntityManager(Singleton):
- ENTITY_INFO_SENSOR_HISTORY_ITEM_MAX = 5
+ ENTITY_STATE_HISTORY_ITEM_MAX = 5
def __init_singleton__(self):
return
- def get_entity_info_data( self,
- entity : Entity,
- is_editing : bool ) -> EntityDetailsData:
- entity_edit_data = EntityEditData( entity = entity )
+ def get_entity_status_data( self,
+ entity : Entity,
+ is_editing : bool ) -> EntityStatusData:
sensor_history_list_map = SensorHistoryManager().get_latest_entity_sensor_history(
entity = entity,
- max_items = self.ENTITY_INFO_SENSOR_HISTORY_ITEM_MAX,
+ max_items = self.ENTITY_STATE_HISTORY_ITEM_MAX,
)
latest_sensor_response_map = dict()
for sensor, sensor_history_list in sensor_history_list_map.items():
@@ -54,13 +54,30 @@ class EntityManager(Singleton):
latest_sensor_response_map[sensor] = sensor_response
continue
- principal_entity_list = self.get_principal_entity_list( entity = entity )
+ return EntityStatusData(
+ entity = entity,
+ latest_sensor_response_map = latest_sensor_response_map,
+ )
- return EntityInfoData(
- entity_edit_data = entity_edit_data,
+ def get_entity_state_history_data( self,
+ entity : Entity,
+ is_editing : bool ) -> EntityStateHistoryData:
+ sensor_history_list_map = SensorHistoryManager().get_latest_entity_sensor_history(
+ entity = entity,
+ max_items = self.ENTITY_STATE_HISTORY_ITEM_MAX,
+ )
+ latest_sensor_response_map = dict()
+ for sensor, sensor_history_list in sensor_history_list_map.items():
+ if sensor_history_list:
+ sensor_response = SensorResponse.from_sensor_history( sensor_history = sensor_history_list[0] )
+ else:
+ sensor_response = None
+ latest_sensor_response_map[sensor] = sensor_response
+ continue
+
+ return EntityStateHistoryData(
+ entity = entity,
sensor_history_list_map = sensor_history_list_map,
- latest_sensor_response_map = latest_sensor_response_map,
- principal_entity_list = principal_entity_list,
)
def get_entity_details_data( self,
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_details.html b/src/hi/apps/entity/templates/entity/edit/panes/entity_details.html
similarity index 80%
rename from src/hi/apps/entity/templates/entity/panes/entity_details.html
rename to src/hi/apps/entity/templates/entity/edit/panes/entity_details.html
index 0ffc4f86..bfc46668 100644
--- a/src/hi/apps/entity/templates/entity/panes/entity_details.html
+++ b/src/hi/apps/entity/templates/entity/edit/panes/entity_details.html
@@ -42,24 +42,30 @@
</div>
{% endif %}
-<h5>Views</h5>
-<div id="hi-edit-entity-views">
- {% include "entity/panes/entity_views.html" %}
+<h5>Delegates</h5>
+<div id="hi-edit-entity-delegates">
+ <div>TBD - DELEGATES</div>
</div>
-<h5>Sensors</h5>
-<div id="hi-edit-entity-sensors">
- {% include "entity/panes/entity_sensors.html" %}
-</div>
+<h5>States/Sensors/Controllers</h5>
+{% for entity_state in entity.states.all %}
+<div class="h6">{{ entity_state.name }}</div>
+<ul>
+ {% for sensor in entity_state.sensors.all %}
+ <li>{{ sensor.name }} [sensor]</li>
+ {% endfor %}
+ {% for controller in entity_state.controllers.all %}
+ <li>{{ controller.name }} [controller]</li>
+ {% endfor %}
+</ul>
-<h5>Controllers</h5>
-<div id="hi-edit-entity-controllers">
- {% include "entity/panes/entity_controllers.html" %}
-</div>
+{% empty %}
+<em>No states</em>
+{% endfor %}
-<h5>Delegates</h5>
-<div id="hi-edit-entity-delegates">
- <div>TBD - DELEGATES</div>
+<h5>Views</h5>
+<div id="hi-edit-entity-views">
+ {% include "entity/panes/entity_views.html" %}
</div>
{% if entity.can_user_delete %}
diff --git a/src/hi/apps/entity/templates/entity/modals/entity_info.html b/src/hi/apps/entity/templates/entity/modals/entity_info.html
deleted file mode 100644
index ba6817cb..00000000
--- a/src/hi/apps/entity/templates/entity/modals/entity_info.html
+++ /dev/null
@@ -1,45 +0,0 @@
-{% extends "modals/action_done.html" %}
-{% load common_template_helpers %}
-
-{% block title_text %}
-{{ entity.name }}
-{% endblock %}
-
-{% block body %}
-
-<h5>Latest Sensor Responses</h5>
-<ul>
- {% for sensor, sensor_response in latest_sensor_response_map.items %}
- <li>Sensor: {{ sensor.name }}
- {% include_with_fallback sensor_response.sensor.entity_state.entity_state_type.value_template_name "entity/panes/sensor_value_default.html" %}
- </li>
- {% empty %}
- <div><em>No sensors</em></div>
- {% endfor %}
-</ul>
-
-<h5>Sensor History</h5>
-<ul>
- {% for sensor, sensor_history_list in sensor_history_list_map.items %}
- <li>Sensor: {{ sensor.name }}
- {% include "sense/panes/sensor_history_list.html" with sensor_history_list=sensor_history_list show_all_link=True %}
- </li>
- {% empty %}
- <div><em>No sensors</em></div>
- {% endfor %}
-</ul>
-
-<h5>Principal Entities</h5>
-<ul>
- {% for principal_entity in principal_entity_list %}
- <li>{{ principal_entity.name }}</li>
- {% empty %}
- <em>No principals</em>
- {% endfor %}
-</ul>
-
-<div>
- {% include "entity/edit/panes/entity_edit.html" %}
-</div>
-
-{% endblock %}
diff --git a/src/hi/apps/entity/templates/entity/modals/entity_state_history.html b/src/hi/apps/entity/templates/entity/modals/entity_state_history.html
new file mode 100644
index 00000000..d29f713b
--- /dev/null
+++ b/src/hi/apps/entity/templates/entity/modals/entity_state_history.html
@@ -0,0 +1,21 @@
+{% extends "modals/action_done.html" %}
+{% load common_template_helpers %}
+
+{% block title_text %}
+{{ entity.name }}
+{% endblock %}
+
+{% block body %}
+
+<h5>Sensor History</h5>
+<ul>
+ {% for sensor, sensor_history_list in sensor_history_list_map.items %}
+ <li>Sensor: {{ sensor.name }}
+ {% include "sense/panes/sensor_history_list.html" with sensor_history_list=sensor_history_list show_all_link=True %}
+ </li>
+ {% empty %}
+ <div><em>No sensors</em></div>
+ {% endfor %}
+</ul>
+
+{% endblock %}
diff --git a/src/hi/apps/entity/templates/entity/modals/entity_status.html b/src/hi/apps/entity/templates/entity/modals/entity_status.html
new file mode 100644
index 00000000..b22cc2fb
--- /dev/null
+++ b/src/hi/apps/entity/templates/entity/modals/entity_status.html
@@ -0,0 +1,37 @@
+{% extends "modals/action_done.html" %}
+{% load common_template_helpers %}
+
+{% block title_text %}
+{{ entity.name }}
+{% endblock %}
+
+{% block body %}
+
+<ul>
+ {% for sensor, sensor_response in latest_sensor_response_map.items %}
+ <li>Sensor: {{ sensor.name }}
+ {% include_with_fallback sensor_response.sensor.entity_state.entity_state_type.value_template_name "entity/panes/sensor_value_default.html" %}
+ </li>
+ {% empty %}
+ <div><em>No sensors</em></div>
+ {% endfor %}
+</ul>
+
+<div class="d-flex justify-content-between">
+ <div>
+ <a class="btn btn-info"
+ href="{% url 'entity_edit' entity_id=entity.id %}"
+ data-async="modal">
+ Edit
+ </a>
+ </div>
+ <div>
+ <a class="btn btn-info"
+ href="{% url 'entity_state_history' entity_id=entity.id %}"
+ data-async="modal">
+ History
+ </a>
+ </div>
+</div>
+
+{% endblock %}
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_controllers.html b/src/hi/apps/entity/templates/entity/panes/entity_controllers.html
deleted file mode 100644
index 02b8f9cc..00000000
--- a/src/hi/apps/entity/templates/entity/panes/entity_controllers.html
+++ /dev/null
@@ -1 +0,0 @@
-TBD - CONTROLLERS
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_sensors.html b/src/hi/apps/entity/templates/entity/panes/entity_sensors.html
deleted file mode 100644
index fb6dc86e..00000000
--- a/src/hi/apps/entity/templates/entity/panes/entity_sensors.html
+++ /dev/null
@@ -1 +0,0 @@
-TBD - SENSORS
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_status_card.html b/src/hi/apps/entity/templates/entity/panes/entity_status_card.html
new file mode 100644
index 00000000..d5310ebf
--- /dev/null
+++ b/src/hi/apps/entity/templates/entity/panes/entity_status_card.html
@@ -0,0 +1,26 @@
+{% load common_template_helpers %}
+<div>
+ {% with entity=entity_status_data.entity %}
+ <div>
+ {% if request.is_editing %}
+ <a href="{% url 'entity_details' entity_id=entity.id %}"
+ data-async="true">
+ {{ entity.name }}
+ </a>
+ {% else %}
+ <a href="{% url 'entity_status' entity_id=entity.id %}"
+ data-async="true">
+ {{ entity.name }}
+ </a>
+ {% endif %}
+ </div>
+ {% endwith %}
+
+ {% for sensor, sensor_response in entity_status_data.latest_sensor_response_map.items %}
+ <li>Sensor: {{ sensor.name }}
+ {% include_with_fallback sensor_response.sensor.entity_state.entity_state_type.value_template_name "entity/panes/sensor_value_default.html" %}
+ </li>
+ {% empty %}
+ <div><em>No sensors</em></div>
+ {% endfor %}
+</div>
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_status_row.html b/src/hi/apps/entity/templates/entity/panes/entity_status_row.html
new file mode 100644
index 00000000..d5310ebf
--- /dev/null
+++ b/src/hi/apps/entity/templates/entity/panes/entity_status_row.html
@@ -0,0 +1,26 @@
+{% load common_template_helpers %}
+<div>
+ {% with entity=entity_status_data.entity %}
+ <div>
+ {% if request.is_editing %}
+ <a href="{% url 'entity_details' entity_id=entity.id %}"
+ data-async="true">
+ {{ entity.name }}
+ </a>
+ {% else %}
+ <a href="{% url 'entity_status' entity_id=entity.id %}"
+ data-async="true">
+ {{ entity.name }}
+ </a>
+ {% endif %}
+ </div>
+ {% endwith %}
+
+ {% for sensor, sensor_response in entity_status_data.latest_sensor_response_map.items %}
+ <li>Sensor: {{ sensor.name }}
+ {% include_with_fallback sensor_response.sensor.entity_state.entity_state_type.value_template_name "entity/panes/sensor_value_default.html" %}
+ </li>
+ {% empty %}
+ <div><em>No sensors</em></div>
+ {% endfor %}
+</div>
diff --git a/src/hi/apps/entity/transient_models.py b/src/hi/apps/entity/transient_models.py
index b5fa33f2..217fa0b1 100644
--- a/src/hi/apps/entity/transient_models.py
+++ b/src/hi/apps/entity/transient_models.py
@@ -23,7 +23,7 @@ class EntityViewItem:
@dataclass
class EntityViewGroup:
- """ All entities of a given type and flagged as in the view or not. """
+ """All entities of a given type and flagged as in the view or not."""
entity_type : EntityType
item_list : List[EntityViewItem] = field( default_factory = list )
@@ -31,7 +31,7 @@ class EntityViewGroup:
@dataclass
class EntityEditData:
- """ All the data needed to render the Entity edit pane (subset of all entity details). """
+ """ Data needed for editing the entity object and its attributes."""
entity : Entity
entity_form : EntityForm = None
@@ -67,32 +67,37 @@ class EntityEditData:
@dataclass
-class EntityInfoData:
- """ All the data needed to render the Entity info modal. """
-
- entity_edit_data : EntityEditData
- sensor_history_list_map : Dict[ Sensor, List[ SensorHistory ] ]
+class EntityStatusData:
+ entity : Entity
latest_sensor_response_map : Dict[ Sensor, SensorResponse ]
- principal_entity_list : List[ Entity ]
- @property
- def entity(self):
- return self.entity_edit_data.entity
+ def to_template_context(self):
+ context = {
+ 'entity': self.entity,
+ 'latest_sensor_response_map': self.latest_sensor_response_map,
+ }
+ return context
+
+
+@dataclass
+class EntityStateHistoryData:
+ entity : Entity
+ sensor_history_list_map : Dict[ Sensor, List[ SensorHistory ] ]
def to_template_context(self):
context = {
'entity': self.entity,
'sensor_history_list_map': self.sensor_history_list_map,
- 'latest_sensor_response_map': self.latest_sensor_response_map,
- 'principal_entity_list': self.principal_entity_list,
}
- context.update( self.entity_edit_data.to_template_context() )
return context
@dataclass
class EntityDetailsData:
- """ All the data needed to render the Entity details pane. """
+ """
+ All the data needed about an entity to display in side bar during edit
+ mode.
+ """
entity_edit_data : EntityEditData
entity_position_form : EntityPositionForm = None
diff --git a/src/hi/apps/entity/urls.py b/src/hi/apps/entity/urls.py
index e11b5742..9357e289 100644
--- a/src/hi/apps/entity/urls.py
+++ b/src/hi/apps/entity/urls.py
@@ -5,18 +5,22 @@ from . import views
urlpatterns = [
- re_path( r'^info/(?P<entity_id>\d+)$',
- views.EntityInfoView.as_view(),
- name='entity_info' ),
+ re_path( r'^entity/edit/(?P<entity_id>\d+)$',
+ views.EntityEditView.as_view(),
+ name='entity_edit'),
+
+ re_path( r'^status/(?P<entity_id>\d+)$',
+ views.EntityStatusView.as_view(),
+ name='entity_status' ),
+
+ re_path( r'^state/history/(?P<entity_id>\d+)$',
+ views.EntityStateHistoryView.as_view(),
+ name='entity_state_history' ),
re_path( r'^details/(?P<entity_id>\d+)$',
views.EntityDetailsView.as_view(),
name='entity_details' ),
- re_path( r'^entity/edit/(?P<entity_id>\d+)$',
- views.EntityEditView.as_view(),
- name='entity_edit'),
-
re_path( r'^entity/attribute/upload/(?P<entity_id>\d+)$',
views.EntityAttributeUploadView.as_view(),
name='entity_attribute_upload'),
diff --git a/src/hi/apps/entity/views.py b/src/hi/apps/entity/views.py
index cf0566ab..c3225e79 100644
--- a/src/hi/apps/entity/views.py
+++ b/src/hi/apps/entity/views.py
@@ -16,47 +16,16 @@ from .view_mixin import EntityViewMixin
logger = logging.getLogger(__name__)
-class EntityInfoView( HiModalView, EntityViewMixin ):
-
- def get_template_name( self ) -> str:
- return 'entity/modals/entity_info.html'
+class EntityEditView( View, EntityViewMixin ):
def get( self, request, *args, **kwargs ):
entity = self.get_entity( request, *args, **kwargs )
-
- entity_info_data = EntityManager().get_entity_info_data(
- entity = entity,
- is_editing = request.is_editing,
+ entity_edit_data = EntityEditData( entity = entity )
+ return self.entity_edit_response(
+ request = request,
+ entity_edit_data = entity_edit_data,
)
- context = entity_info_data.to_template_context()
- return self.modal_response( request, context )
-
-
-class EntityDetailsView( HiSideView, EntityViewMixin ):
-
- def get_template_name( self ) -> str:
- return 'entity/panes/entity_details.html'
-
- def should_push_url( self ):
- return True
- def get_template_context( self, request, *args, **kwargs ):
- entity = self.get_entity( request, *args, **kwargs )
-
- current_location_view = None
- if request.view_parameters.view_type.is_location_view:
- current_location_view = LocationManager().get_default_location_view( request = request )
-
- entity_details_data = EntityManager().get_entity_details_data(
- entity = entity,
- location_view = current_location_view,
- is_editing = request.is_editing,
- )
- return entity_details_data.to_template_context()
-
-
-class EntityEditView( View, EntityViewMixin ):
-
def post( self, request, *args, **kwargs ):
entity = self.get_entity( request, *args, **kwargs )
@@ -120,6 +89,63 @@ class EntityAttributeUploadView( View, EntityViewMixin ):
entity_edit_data = entity_edit_data,
status_code = status_code,
)
+
+
+class EntityStatusView( HiModalView, EntityViewMixin ):
+
+ def get_template_name( self ) -> str:
+ return 'entity/modals/entity_status.html'
+
+ def get( self, request, *args, **kwargs ):
+ entity = self.get_entity( request, *args, **kwargs )
+
+ entity_status_data = EntityManager().get_entity_status_data(
+ entity = entity,
+ is_editing = request.is_editing,
+ )
+ context = entity_status_data.to_template_context()
+ return self.modal_response( request, context )
+
+
+class EntityStateHistoryView( HiModalView, EntityViewMixin ):
+
+ def get_template_name( self ) -> str:
+ return 'entity/modals/entity_state_history.html'
+
+ def get( self, request, *args, **kwargs ):
+ entity = self.get_entity( request, *args, **kwargs )
+
+ entity_state_history_data = EntityManager().get_entity_state_history_data(
+ entity = entity,
+ is_editing = request.is_editing,
+ )
+ context = entity_state_history_data.to_template_context()
+ return self.modal_response( request, context )
+
+
+class EntityDetailsView( HiSideView, EntityViewMixin ):
+
+ def get_template_name( self ) -> str:
+ return 'entity/edit/panes/entity_details.html'
+
+ def should_push_url( self ):
+ return True
+
+ def get_template_context( self, request, *args, **kwargs ):
+ entity = self.get_entity( request, *args, **kwargs )
+
+ current_location_view = None
+ if request.view_parameters.view_type.is_location_view:
+ current_location_view = LocationManager().get_default_location_view( request = request )
+
+ entity_details_data = EntityManager().get_entity_details_data(
+ entity = entity,
+ location_view = current_location_view,
+ is_editing = request.is_editing,
+ )
+ return entity_details_data.to_template_context()
+
+
diff --git a/src/hi/apps/location/views.py b/src/hi/apps/location/views.py
index ff0ebd7b..a8f84d6a 100644
--- a/src/hi/apps/location/views.py
+++ b/src/hi/apps/location/views.py
@@ -119,7 +119,7 @@ class LocationItemInfoView( View ):
raise BadRequest( request, message = 'Bad item id.' )
if item_type == ItemType.ENTITY:
- redirect_url = reverse( 'entity_info', kwargs = { 'entity_id': item_id } )
+ redirect_url = reverse( 'entity_status', kwargs = { 'entity_id': item_id } )
return HttpResponseRedirect( redirect_url )
if item_type == ItemType.COLLECTION: