From 57060975b0b8f296e32ce1799821049cb0730d78 Mon Sep 17 00:00:00 2001 From: Jon Date: Sun, 16 Feb 2025 05:10:23 +0930 Subject: [PATCH] chore: remove old history model access from original UI and API V1 ref: #601 #605 closes #606 --- CONTRIBUTING.md | 28 +++++ Release-Notes.md | 17 +++ app/app/urls.py | 3 +- app/core/templates/history.html.j2 | 60 ----------- app/core/views/history.py | 165 ----------------------------- app/templates/base.html.j2 | 9 -- 6 files changed, 46 insertions(+), 236 deletions(-) delete mode 100644 app/core/templates/history.html.j2 delete mode 100644 app/core/views/history.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9386ddb7..96a01b6d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,6 +95,34 @@ clear; \ ``` + + + +## Tips / Handy info + +- To obtain a list of models _(in in the same order as the file system)_ using the db shell `python3 manage.py dbshell` run the following sql command: + + ``` sql + + SELECT model FROM django_content_type ORDER BY app_label ASC, model ASC; + + ``` + + + + + + + + + + + + + + + + # Old working docs diff --git a/Release-Notes.md b/Release-Notes.md index 20ce8e45..2bc2a823 100644 --- a/Release-Notes.md +++ b/Release-Notes.md @@ -1,3 +1,20 @@ + +## Version 1.11.0 + +- History views removed from original Centurion interface. +- History views removed from API v1. + + +## Version 1.10.0 + +- Nothing significant to report + + +## Version 1.9.0 + +- Nothing significant to report + + ## Version 1.8.0 - Prometheus exporter added. To enable metrics for the database you will have to update the database backend. see the [docs](https://nofusscomputing.com/projects/centurion_erp/administration/monitoring/#django-exporter-setup) for further information. diff --git a/app/app/urls.py b/app/app/urls.py index 94446dd4..64e4ce5c 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -24,7 +24,7 @@ from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView from .views import home -from core.views import history, related_ticket, ticket_linked_item +from core.views import related_ticket, ticket_linked_item from settings.views import user_settings @@ -47,7 +47,6 @@ urlpatterns = [ path("itim/", include("itim.urls")), path("config_management/", include("config_management.urls")), - path("history//", history.View.as_view(), name='_history'), re_path(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}), diff --git a/app/core/templates/history.html.j2 b/app/core/templates/history.html.j2 deleted file mode 100644 index 39f03c65..00000000 --- a/app/core/templates/history.html.j2 +++ /dev/null @@ -1,60 +0,0 @@ -{% extends 'base.html.j2' %} -{% load json %} - -{% block content %} - - - - - - - - - - - - {% for entry in history %} - - - - - - - - - - - - - - - {% endfor %} -
CreatedActionItemUser
{{ entry.created }} - {% if entry.action == 1 %} - Create - {% elif entry.action == 2 %} - Update - {% elif entry.action == 3 %} - Delete - {% else %} - fuck knows - {% endif %} - - {{ entry.item_class}} - {{ entry.user }}
- -{% endblock %} \ No newline at end of file diff --git a/app/core/views/history.py b/app/core/views/history.py deleted file mode 100644 index 669687df..00000000 --- a/app/core/views/history.py +++ /dev/null @@ -1,165 +0,0 @@ -from django.db.models import Q -from django.http import HttpResponseRedirect -from django.shortcuts import redirect, render -from django.views import generic - -from access.mixin import OrganizationPermission - -from core.models.history import History - - - -class View(OrganizationPermission, generic.View): - - permission_required = [ - 'core.view_history' - ] - - template_name = 'history.html.j2' - - - def get_object(self): - """ Get the history entry model - - function required to check permissions, in particular that the user is in the same organization. - - Raises: - Exception: if the model can't be found. - - Returns: - Model: Returns the model Object - """ - from access.models import Organization, Team - - from itam.models.device import Device, DeviceSoftware, DeviceModel, DeviceType, DeviceOperatingSystem - from itam.models.operating_system import OperatingSystem - from itam.models.software import Software, SoftwareCategory - - from core.models.manufacturer import Manufacturer - - from config_management.models.groups import ConfigGroups - - from settings.models.external_link import ExternalLink - - from project_management.models.projects import Project - - - if not hasattr(self, 'model'): - - match str(self.kwargs['model_name']).lower(): - - case 'cluster': - - from itim.models.clusters import Cluster - - self.model = Cluster - - case 'clustertype': - - from itim.models.clusters import ClusterType - - self.model = ClusterType - - case 'configgroups': - - self.model = ConfigGroups - - case 'device': - - self.model = Device - - case 'devicemodel': - - self.model = DeviceModel - - case 'devicetype': - - self.model = DeviceType - - case 'externallink': - - self.model = ExternalLink - - case 'knowledgebase': - - from assistance.models.knowledge_base import KnowledgeBase - - self.model = KnowledgeBase - - case 'knowledgebasecategory': - - from assistance.models.knowledge_base import KnowledgeBaseCategory - - self.model = KnowledgeBaseCategory - - case 'manufacturer': - - self.model = Manufacturer - - case 'projectstate': - - from project_management.models.project_states import ProjectState - - self.model = ProjectState - - case 'software': - - self.model = Software - - case 'softwarecategory': - - self.model = SoftwareCategory - - case 'operatingsystem': - - self.model = OperatingSystem - - case 'organization': - - self.model = Organization - - case 'port': - - from itim.models.services import Port - - self.model = Port - - case 'team': - - self.model = Team - - case 'service': - - from itim.models.services import Service - - self.model = Service - - case 'project': - - self.model = Project - - case _: - raise Exception('Unable to determine history items model') - - if not hasattr(self, 'obj'): - - self.obj = self.model.objects.get(id=self.kwargs['model_pk']) - - return self.obj - - - def get(self, request, model_name, model_pk): - if not request.user.is_authenticated and settings.LOGIN_REQUIRED: - return redirect(f"{settings.LOGIN_URL}?next={request.path}") - - context = {} - - context['history'] = History.objects.filter( - Q(item_pk = model_pk, item_class = model_name) - | - Q(item_parent_pk = model_pk, item_parent_class = model_name) - ) - - context['content_title'] = 'History' - - return render(request, self.template_name, context) diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index cb6b8b52..ac23bf63 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -102,15 +102,6 @@ section h2 span svg { {% include 'icons/help.svg' %} {% endif %} - {% if model_name and model_pk %} - {% block content_header_icon %} - - - - - - {% endblock content_header_icon %} - {% endif %} {% if user.is_authenticated %} {% if not user_default_organization %}