From a5593d66ea541dfbcd2597f81dcbc51965c51cfc Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 11 Jul 2018 23:38:14 +0200 Subject: Manage alerts --- archaeological_operations/views.py | 6 +-- archaeological_operations/wizards.py | 5 +++ ishtar_common/static/js/ishtar.js | 32 ++++++++++++++ ishtar_common/templates/base.html | 1 + ishtar_common/templates/blocks/DataTables.html | 20 +++++++-- .../ishtar/blocks/base_shortcut_menu.html | 4 +- ishtar_common/templates/ishtar/wizard/search.html | 8 ++++ ishtar_common/urls.py | 6 ++- ishtar_common/utils.py | 3 +- ishtar_common/views.py | 50 ++++++++++++++++++++++ ishtar_common/views_item.py | 17 ++++++-- ishtar_common/wizards.py | 22 ++++++++-- scss/custom.scss | 4 ++ 13 files changed, 161 insertions(+), 17 deletions(-) diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 0721bb707..10e60c2bb 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -22,7 +22,7 @@ import json from django.conf import settings from django.core.urlresolvers import reverse from django.db.models import Q -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import render, redirect from django.utils.translation import ugettext_lazy as _, pgettext_lazy @@ -45,7 +45,7 @@ from archaeological_operations.wizards import has_associated_file, \ OperationClosingWizard, OperationDeletionWizard, SiteSearch, \ OperationAdministrativeActWizard, OperationEditAdministrativeActWizard, \ AdministrativeActDeletionWizard, SiteWizard, SiteModificationWizard, \ - SiteDeletionWizard + SiteDeletionWizard, OperationSearch from ishtar_common.forms import ClosingDateFormSelection, FinalForm, \ FinalDeleteForm from ishtar_common.models import get_current_profile, IshtarSiteProfile @@ -175,7 +175,7 @@ def dashboard_operation(request, *args, **kwargs): return render(request, 'ishtar/dashboards/dashboard_operation.html', dct) -operation_search_wizard = SearchWizard.as_view( +operation_search_wizard = OperationSearch.as_view( [('general-operation_search', OperationFormSelection)], label=_(u"Operation search"), url_name='operation_search',) diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index a8f8ef80b..ba9709807 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -37,6 +37,10 @@ from ishtar_common.wizards import Wizard, ClosingWizard, DeletionWizard, \ logger = logging.getLogger(__name__) +class OperationSearch(SearchWizard): + model = models.Operation + + class OperationWizard(Wizard): model = models.Operation object_parcel_type = 'operation' @@ -419,6 +423,7 @@ class SiteLabel(object): class SiteSearch(SiteLabel, SearchWizard): SITE_KEY = "search" + model = models.ArchaeologicalSite class SiteWizard(SiteLabel, Wizard): diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index a71450fab..60840bcf8 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -38,7 +38,10 @@ function manage_async_link(event){ function get_next_table_id(){} function get_previous_table_id(){} +var datatable_submit_search = function() {}; + var shortcut_url = ''; +var alert_url = ''; var datatables_i18n; var current_modal; @@ -222,6 +225,7 @@ function load_shortcut_menu(opened){ cache: false, success:function(html){ init_shortcut_menu(html); + load_alerts(); if(opened){ $("#dropdown-toggle-shortcut-menu").click(); } @@ -232,6 +236,34 @@ function load_shortcut_menu(opened){ }); } +var load_alerts = function(){ + if (!alert_url) return; + $('.modal-progress').modal('show'); + $.ajax({ + url: alert_url, + cache: false, + success:function(json){ + $('.modal-progress').modal('hide'); + var html = ""; + for (idx in json["alerts"]){ + var b = json["alerts"][idx]; + var url = "/bookmark/" + b["query_id"] + "/" ; + html += ''; + html += b["label"]; + html += ' '; + html += b["number"]; + html += ''; + html += ' '; + } + $("#alert-list").html(html); + }, + error:function(XMLHttpRequest, textStatus, errorThrows){ + close_wait(); + }, + dataType: 'json' + }); +} + function dynamic_load(url, target){ $.ajax({ url: url, diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index 40e30706c..72c6a9b65 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -30,6 +30,7 @@ {{EXTRA_JS|safe}} +{% endif %} {% comment %}