summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-11-14 18:58:48 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:19 +0100
commit4746cd2938df3cf87ae338d22eb4f67f35bac960 (patch)
tree1b823f5e78e7214f84da3892e0729c0c2706ad6d /ishtar_common
parent2fd7a306df69b723036a94346baa7ea17c9b7364 (diff)
downloadIshtar-4746cd2938df3cf87ae338d22eb4f67f35bac960.tar.bz2
Ishtar-4746cd2938df3cf87ae338d22eb4f67f35bac960.zip
Remove dead code about dashboards
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/templates/ishtar/dashboards/dashboard_main.html52
-rw-r--r--ishtar_common/templates/ishtar/dashboards/dashboard_main_detail.html250
-rw-r--r--ishtar_common/templates/ishtar/dashboards/dashboard_main_detail_users.html32
-rw-r--r--ishtar_common/tests.py38
-rw-r--r--ishtar_common/urls.py6
-rw-r--r--ishtar_common/views.py120
6 files changed, 0 insertions, 498 deletions
diff --git a/ishtar_common/templates/ishtar/dashboards/dashboard_main.html b/ishtar_common/templates/ishtar/dashboards/dashboard_main.html
deleted file mode 100644
index 692e435a3..000000000
--- a/ishtar_common/templates/ishtar/dashboards/dashboard_main.html
+++ /dev/null
@@ -1,52 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-{% block extra_head %}
-{{form.media}}
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/jquery.jqplot.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.canvasTextRenderer.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.highlighter.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.pieRenderer.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.dateAxisRenderer.min.js?ver={{VERSION}}"></script>
-<script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.cursor.min.js?ver={{VERSION}}"></script>
-<link rel="stylesheet" href="{{STATIC_URL}}js/jqplot/jquery.jqplot.min.css?ver={{VERSION}}" />
-{% endblock %}
-{% block content %}
-<script type="text/javascript">
-$(function() {
- $('#dashboard .nav-link').click(function () {
- var url = $(this).attr('data-url');
- dynamic_load(url, "#dashboard .card-body");
- $('#dashboard li').removeClass('active');
- $('#dashboard li').removeClass('show');
- $(this).parent().tab('show');
- })
- $('#dashboard li:first-child a').click();
-});
-
-</script>
-<div id='dashboard' class="card">
- <div class="card-header">
- <ul class="nav nav-tabs card-header-tabs">
- {% for label, app in app_list %}
- <li class="nav-item" id="{{app}}-tab">
- <a class="nav-link" href="#{{app}}-pane"
- data-url="{% url 'dashboard-main-detail' app %}">{{label}}</a>
- </li>{% endfor %}
- <li class="nav-item" id="users-tab">
- <a class="nav-link" href="#users-pane"
- data-url="{% url 'dashboard-main-detail' 'users' %}">{% trans "Users" %}</a>
- </li>
- </ul>
- </div>
- <div class="card-body tab-content">
- {% for label, app in app_list %}
- <div class="tab-pane{% if forloop.counter0 == 0%} active{% endif %}" id="{{app}}-pane"
- role="tabpanel" aria-labelledby="{{app}}-tab"></div>{% endfor %}
- <div class="tab-pane" id="users-pane" role="tabpanel"
- aria-labelledby="users-tab"></div>
- </div>
-</div>
-
-{% endblock %}
diff --git a/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail.html b/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail.html
deleted file mode 100644
index 75a7aa542..000000000
--- a/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail.html
+++ /dev/null
@@ -1,250 +0,0 @@
-{% load i18n date_formating humanize table_form %}
-<div id="{{unique_id}}-tab">
- <h4>{% trans "Numbers" %}</h4>
- {% if form %}
- <div class='form'>
- <form method='post' action="{% url 'dashboard-main-detail' item_name %}" id='{{unique_id}}_form'>
- {% csrf_token %}
- {% bs_form form %}
- <div class="text-center">
- <button type='button' id="search_{{unique_id}}"
- class="btn btn-primary">
- {% trans "Change" %}</button>
- </div>
- </form>
- </div>
- {% endif %}
- <p><strong>{% trans "Total:" %}</strong> {{dashboard.total_number|intcomma}}</p>
- <div>
- <div id="chart_{{unique_id}}"
- style="height:400px; width:700px; margin-right:auto; margin-left:auto"></div>
- <p class='alert alert-info'>
- {% trans 'Draw rectangle on the graph to zoom. Double-click to reinitialize.' %}
- </p>
- <div class='form chart-img-form'>
- <div class="text-center">
- <button id="chart_img_display_{{unique_id}}"
- type='button' class='btn btn-secondary'>
- {% trans "Display as an image" %}
- </button>
- </div>
- <div id="chart_img_{{unique_id}}" class='chart-img'>
- <div class="card">
- <div id="img_{{unique_id}}"
- class="card-img-top text-center"></div>
- <div class="card-body">
- <div class='alert alert-info'>
- {% trans 'Right-click on this image to save it.' %}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <hr>
- <table class="table table-striped">
- {% for idx, lbl, values in dashboard.values %}
- <tr>
- <th>{{lbl}}</th>
- {% for value in values reversed %}{% if forloop.parentloop.counter0 %}<td>{% else %}<th>{%endif%}{{value|date_formating }}{% if forloop.parentloop.counter0 %}</td>{% else %}</th>{%endif%}{% endfor%}
- </tr>
- {% endfor%}
- </table>
- <hr>
- {% if dashboard.periods %}
- <h4>{% trans "By years" %}</h4>
- <dl class="row">
- <dt class="col-sm-3">
- {% trans "Average:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.average}}
- </dd>
-
- <dt class="col-sm-3">
- {% trans "Variance:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.variance}}
- </dd>
-
- <dt class="col-sm-3">
- {% trans "Standard deviation:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.standard_deviation}}
- </dd>
- <dt class="col-sm-3">
- {% trans "Median:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.median}}
- </dd>
- <dt class="col-sm-3">
- {% trans "Mode:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.mode}}
- </dd>
- </dl>
- <hr>
- {% endif %}
- {% if dashboard.operation_average %}
- <h4>{% trans "By operations" %}</h4>
- <dl class="row">
- <dt class="col-sm-3">
- {% trans "Average:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.operation_average}}
- </dd>
-
- <dt class="col-sm-3">
- {% trans "Variance:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.operation_variance}}
- </dd>
-
- <dt class="col-sm-3">
- {% trans "Standard deviation:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.operation_standard_deviation}}
- </dd>
- <dt class="col-sm-3">
- {% trans "Median:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.operation_median}}
- </dd>
- <dt class="col-sm-3">
- {% trans "Mode:" %}
- </dt>
- <dd class="col-sm-9">
- {{dashboard.operation_mode}}
- </dd>
- </dl>
- <hr>
- {% endif %}
- <h4>{% trans "Created last" %}</h4>
- <table class="table table-striped">
- <tr><th>{{lbl}}</th><th>{% trans "Created" %}</th><th></th></tr>
- {% for item in dashboard.lasts %}<tr>
- <td class='ref'>{{item}}</td>
- <td>{{item.history_date}}</td>
- <td>{% if item.get_show_url %}<a href="#" onclick='load_window("{{item.get_show_url}}")'>
- <i class="fa fa-info-circle" aria-hidden="true"></i>
- </a>{%endif%}</td>
- </tr>{% endfor %}
- </table>
- <hr>
- <h4>{% trans "Recent changes" %}</h4>
- <table class="table table-striped">
- <tr><th>{{lbl}}</th><th>{% trans "Modified" %}</th><th></th></tr>
- {% for item in dashboard.recents %}<tr>
- <td class='ref'>{{item}}</td>
- <td>{{item.history_date}}</td>
- <td>{% if item.get_show_url %}<a href="#" onclick='load_window("{{item.get_show_url}}")'>
- <i class="fa fa-info-circle" aria-hidden="true"></i>
- </a>{%endif%}</td>
- </tr>{% endfor %}
- </table>
-</div>
-<script language="javascript" type="text/javascript">
-$(document).ready(function(){
-
-{% for idx, lbl, values in dashboard.values %} {% if forloop.counter0 > 0 %} var values_{{forloop.counter0}}_{{unique_id}} = []; {% for idx, lbl, values in dashboard.values %} {% for value in values %} {% if forloop.parentloop.counter0 == 0 %} values_{{forloop.parentloop.parentloop.counter0}}_{{unique_id}}.push([{{VALUE_QUOTE|safe}}{{value}}{{VALUE_QUOTE|safe}}, 0]); {% elif forloop.parentloop.parentloop.counter0 == forloop.parentloop.counter0 %} values_{{forloop.parentloop.parentloop.counter0}}_{{unique_id}}[{{forloop.counter0}}][1] = {{value}}; {% endif %} {% endfor%} {% endfor%} {% endif %} {% endfor %}
-
-{% comment %}
-# less compact version
-{% for idx, lbl, values in dashboard.values %}
- {% if forloop.counter0 > 0 %}
- {% for idx, lbl, values in dashboard.values %}
- {% for value in values %}
- {% if forloop.parentloop.counter0 == 0 %}
- values_{{forloop.parentloop.counter0}}_{{unique_id}}.push([{{VALUE_QUOTE|safe}}{{value}}{{VALUE_QUOTE|safe}}, 0]);
- {% elif forloop.parentloop.counter0 == forloop.counter0 %}
- values_{{forloop.counter0}}_{{unique_id}}[{{forloop.counter0}}][1] = {{value}};
- {% endif %}
- {% endfor%}
- {% endfor%}
- {% endif %}
-{% endfor %}
-{% endcomment %}
-
-
-if (typeof values_1_{{unique_id}} === 'undefined'
- || values_1_{{unique_id}}.length == 0){
-
- $('#chart_img_{{unique_id}}').hide();
- $('#chart_{{unique_id}}').html(
- "<p class='alert alert-warning'>{% trans 'No data for these criteria.' %}</p>"
- );
- $('#chart_{{unique_id}}').css('height', 'auto');
-
-} else {
-var showmarker = false;
-if (values_1_{{unique_id}}.length < 25){
- var showmarker = true;
-}
-
-var plot_{{unique_id}} = $.jqplot('chart_{{unique_id}}',
- [{% for idx, lbl, values in dashboard.values %}{% if forloop.counter0 > 0 %} {% if forloop.counter0 > 1 %}, {% endif%} values_{{forloop.counter0}}_{{unique_id}} {% endif %} {% endfor%}], {
- axes:{ {%ifequal slicing 'year'%}
- xaxis:{
- label:'{% trans "Year" %}',
- tickOptions: {
- formatString: "%d"
- }
- },{%endifequal%}{%ifequal slicing 'month'%}
- xaxis:{
- label:'{% trans "Month" %}',
- renderer:$.jqplot.DateAxisRenderer,
- tickRenderer:$.jqplot.CanvasAxisTickRenderer,
- tickOptions:{
- formatString:'%b %Y',
- angle:-25
- }
- },{%endifequal%}
- yaxis:{
- label:'{% trans "Number"%}',
- min:0
- }
- },
- highlighter: {
- show: true,
- sizeAdjust: 7.5
- },
- series:[{% for label in dashboard.serie_labels %}
- {%if forloop.counter0%}, {% endif %}{label:"{{label}}", showmarker:showmarker}{% endfor %}
- ],
- cursor:{
- show: true,
- zoom:true,
- showTooltip:false
- },
- legend: { show:true, location: 'nw' }
- });
-
- $('#chart_img_display_{{unique_id}}').click(function(){
- $('#chart_img_{{unique_id}}').hide();
- $('#img_{{unique_id}}').html(
- $('<img/>').attr(
- 'src', $('#chart_{{unique_id}}').jqplotToImageStr({})
- )
- );
- $('#chart_img_{{unique_id}}').show('slow');
- });
-}
-
-$('#search_{{unique_id}}').click(function (){
- $.post("{% url 'dashboard-main-detail' item_name %}",
- $("#{{unique_id}}_form").serialize(),
- function(data){
- $("#{{unique_id}}-tab").parent().html(data);
- });
- return false;
-});
-});
-</script>
diff --git a/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail_users.html b/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail_users.html
deleted file mode 100644
index f6ead643a..000000000
--- a/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail_users.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{% load i18n %}
-<div class='dashboard centered'>
- <div id="user_chart" style="height:300px; width:700px;margin-left: auto;margin-right: auto;"></div>
- <table class='table table-striped'>
- <tr><th>{% trans "User type" %}</th><th>{% trans "Number" %}</th></tr>
- {% for user_type in ishtar_users.types %}
- <tr>
- <td class='string'>{{user_type.person__person_types__label}}{#TODO: Display all#}</td>
- <td>{{user_type.number}}</td>
- </tr>
- {% endfor %}
- </table>
-</div>
-<script language="javascript" type="text/javascript">
-$(document).ready(function(){
- var values_users = [];
- {% for user_type in ishtar_users.types %}
- values_users.push(['{{user_type.person__person_types__label}}', {{user_type.number}}]); {% endfor%}
-
- var plot_users = jQuery.jqplot ('user_chart', [values_users],
- {
- seriesDefaults: {
- renderer: jQuery.jqplot.PieRenderer,
- rendererOptions: {
- showDataLabels: true
- }
- },
- legend: { show:true, location: 'e' }
- }
- );
-});
-</script> \ No newline at end of file
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index c5d9f5c67..f624314e0 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -3607,44 +3607,6 @@ class AccountWizardTest(WizardTest, TestCase):
self.assertEqual(models.IshtarUser.objects.count(), self.account_number + 1)
-class DashboardTest(TestCase):
- def setUp(self):
- self.username, self.password, self.user = create_superuser()
- profile, created = models.IshtarSiteProfile.objects.get_or_create(
- slug="default", active=True
- )
- profile.files = True
- profile.context_record = True
- profile.find = True
- profile.warehouse = True
- profile.save()
-
- def test_dashboard(self):
- c = Client()
- c.login(username=self.username, password=self.password)
-
- url = "dashboard-main-detail"
-
- response = c.get(reverse(url, kwargs={"item_name": "zorglub"}))
- self.assertEqual(response.status_code, 404)
-
- for item in [
- "users",
- "files",
- "treatmentfiles",
- "treatments",
- "operations",
- "contextrecords",
- "finds",
- ]:
- response = c.get(reverse(url, kwargs={"item_name": item}))
- self.assertEqual(
- response.status_code,
- 200,
- "Reaching dashboard for item: {} return an error.".format(url),
- )
-
-
class CleanMedia(TestCase):
def test_rename(self):
test_names = [
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index b7e5f46d1..8a0886551 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -297,12 +297,6 @@ actions = r"|".join(actions)
# other views
urlpatterns += [
# General
- url(r"dashboard-main/$", views.dashboard_main, name="dashboard-main"),
- url(
- r"dashboard-main/(?P<item_name>[a-z-]+)/$",
- views.dashboard_main_detail,
- name="dashboard-main-detail",
- ),
url(
r"update-current-item/$", views.update_current_item, name="update-current-item"
),
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 4cdbcf8c9..9e4177f45 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -55,14 +55,8 @@ from markdown import markdown
from . import models
from archaeological_context_records.models import ContextRecord
-from archaeological_files.forms import DashboardForm as DashboardFormFile
from archaeological_files.models import File
-from archaeological_finds.forms import (
- DashboardTreatmentForm,
- DashboardTreatmentFileForm,
-)
from archaeological_finds.models import Find, Treatment, TreatmentFile
-from archaeological_operations.forms import DashboardForm as DashboardFormOpe
from archaeological_operations.models import Operation, ArchaeologicalSite
from archaeological_warehouse.models import Warehouse
from ishtar_common import forms_common as forms
@@ -991,120 +985,6 @@ def action(request, action_slug, obj_id=None, *args, **kwargs):
return render(request, "index.html", dct)
-def dashboard_main(request, dct, obj_id=None, *args, **kwargs):
- """
- Main dashboard
- """
- app_list = []
- profile = models.get_current_profile()
- if profile.files:
- app_list.append((_("Archaeological files"), "files"))
- app_list.append((_("Operations"), "operations"))
- if profile.context_record:
- app_list.append((_("Context records"), "contextrecords"))
- if profile.find:
- app_list.append((_("Finds"), "finds"))
- if profile.warehouse:
- app_list.append((_("Treatment requests"), "treatmentfiles"))
- app_list.append((_("Treatments"), "treatments"))
- dct = {"app_list": app_list}
- return render(request, "ishtar/dashboards/dashboard_main.html", dct)
-
-
-DASHBOARD_FORMS = {
- "files": DashboardFormFile,
- "operations": DashboardFormOpe,
- "treatments": DashboardTreatmentForm,
- "treatmentfiles": DashboardTreatmentFileForm,
-}
-
-
-def dashboard_main_detail(request, item_name):
- """
- Specific tab of the main dashboard
- """
- if item_name == "users":
- dct = {"ishtar_users": models.UserDashboard()}
- return render(
- request, "ishtar/dashboards/dashboard_main_detail_users.html", dct
- )
- form = None
- slicing, date_source, fltr, show_detail = "year", None, {}, False
- profile = models.get_current_profile()
- has_form = (
- (item_name == "files" and profile.files)
- or item_name == "operations"
- or (item_name in ("treatmentfiles", "treatments") and profile.warehouse)
- )
- if has_form:
- slicing = "month"
- if item_name in DASHBOARD_FORMS:
- if request.method == "POST":
- form = DASHBOARD_FORMS[item_name](request.POST)
- if form.is_valid():
- slicing = form.cleaned_data["slicing"]
- fltr = form.get_filter()
- if hasattr(form, "get_date_source"):
- date_source = form.get_date_source()
- if hasattr(form, "get_show_detail"):
- show_detail = form.get_show_detail()
- else:
- form = DASHBOARD_FORMS[item_name]()
- lbl, dashboard = None, None
- dashboard_kwargs = {}
- if has_form:
- dashboard_kwargs = {"slice": slicing, "fltr": fltr, "show_detail": show_detail}
- # date_source is only relevant when the form has set one
- if date_source:
- dashboard_kwargs["date_source"] = date_source
- if item_name == "files" and profile.files:
- lbl, dashboard = (
- _("Archaeological files"),
- models.Dashboard(File, **dashboard_kwargs),
- )
- elif item_name == "operations":
- from archaeological_operations.models import Operation
-
- lbl, dashboard = (
- _("Operations"),
- models.Dashboard(Operation, **dashboard_kwargs),
- )
- elif item_name == "contextrecords" and profile.context_record:
- lbl, dashboard = (
- _("Context records"),
- models.Dashboard(ContextRecord, slice=slicing, fltr=fltr),
- )
- elif item_name == "finds" and profile.find:
- lbl, dashboard = (_("Finds"), models.Dashboard(Find, slice=slicing, fltr=fltr))
- elif item_name == "treatmentfiles" and profile.warehouse:
- lbl, dashboard = (
- _("Treatment requests"),
- models.Dashboard(TreatmentFile, **dashboard_kwargs),
- )
- elif item_name == "treatments" and profile.warehouse:
- if "date_source" not in dashboard_kwargs:
- dashboard_kwargs["date_source"] = "start"
- lbl, dashboard = (
- _("Treatments"),
- models.Dashboard(Treatment, **dashboard_kwargs),
- )
- if not lbl:
- raise Http404
- dct = {
- "lbl": lbl,
- "dashboard": dashboard,
- "item_name": item_name.replace("-", "_"),
- "VALUE_QUOTE": "" if slicing == "year" else "'",
- "form": form,
- "slicing": slicing,
- }
- n = datetime.datetime.now()
- dct["unique_id"] = (
- dct["item_name"] + "_" + "%d_%d_%d" % (n.minute, n.second, n.microsecond)
- )
- return render(request, "ishtar/dashboards/dashboard_main_detail.html", dct)
-
-
def reset_wizards(request):
# dynamically execute each reset_wizards of each ishtar app
for app in settings.INSTALLED_APPS: