diff --git a/python/amqp2dballed b/python/amqp2dballed index 0b31d85c8..28995d933 100755 --- a/python/amqp2dballed +++ b/python/amqp2dballed @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python3.6 -s # GPL. (C) 2023 Paolo Patruno. # This program is free software; you can redistribute it and/or modify @@ -115,11 +115,16 @@ class Threaded_bufr2dballe(threading.Thread): go=True while not self._send_queue.empty() and go: message=self._send_queue.get() + + #if len(message.body) > PACKET_MAX_SIZE: + # self._logging.error("Message too big, skip it; tag %d, size %d" % (message.delivery_tag,len(message.body))) + # self._receive_queue.put_nowait(Message(False,message.delivery_tag)) + #else: size += len(message.body) - if size < PACKET_MAX_SIZE or len(messages)==0: + if size <= PACKET_MAX_SIZE or len(messages)==0: messages.append(message) else: - self._logging.warning("max size for packet, send it: last message size %s bytes" % len(message.body)) + self._logging.warning("max size for packet, requeue last message of size %s bytes" % len(message.body)) # requeue message for late self._send_queue.put(message) go=False diff --git a/python/app_dist/rmap-core_app/setup.py b/python/app_dist/rmap-core_app/setup.py index 943493e12..aeab56a42 100644 --- a/python/app_dist/rmap-core_app/setup.py +++ b/python/app_dist/rmap-core_app/setup.py @@ -83,7 +83,6 @@ def run(self): class build(build_): sub_commands = build_.sub_commands[:] - sub_commands.append(('compilemessages', None)) sub_commands.append(('createmanpages', None)) @@ -119,21 +118,6 @@ def run(self): management.call_command("makemessages",all=True) -class compilemessages(Command): - description = "generate .mo files from .po" - user_options = [] - boolean_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - from django.core import management - management.call_command("compilemessages") - class createmanpages(Command): description = "generate man page with help2man" user_options = [] diff --git a/python/geoimage/locale/it/LC_MESSAGES/django.po b/python/geoimage/locale/it/LC_MESSAGES/django.po index 12231cdae..ef66c3a19 100644 --- a/python/geoimage/locale/it/LC_MESSAGES/django.po +++ b/python/geoimage/locale/it/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-11-28 10:21+0000\n" -"PO-Revision-Date: 2023-11-28 11:22+0100\n" +"POT-Creation-Date: 2023-12-11 12:00+0000\n" +"PO-Revision-Date: 2023-12-11 13:03+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: it\n" @@ -37,35 +37,79 @@ msgstr "Descrizione dell'immagine" msgid "File with image" msgstr "File con immagine" -#: geoimage/templates/geoimage/geoimage_by_ident_id.html:37 +#: geoimage/templates/geoimage/geoimage_by_id.html:37 msgid "Navigate this point by time" msgstr "Navigare questo sito nel tempo" -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:36 +#: geoimage/templates/geoimage/geoimage_by_id.html:42 +msgid "Delete" +msgstr "Rimuovi" + +#: geoimage/templates/geoimage/geoimage_delete.html:27 +msgid "Invalid data; retry" +msgstr "Dati invalidi; riprova" + +#: geoimage/templates/geoimage/geoimage_delete.html:28 +msgid "Return to image" +msgstr "Tona all'immagine" + +#: geoimage/templates/geoimage/geoimage_delete.html:32 +msgid "The image is not your own; cannot remove!" +msgstr "L'immagine non è di tua proprietà; non puoi rimuoverla!" + +#: geoimage/templates/geoimage/geoimage_delete.html:36 +msgid "Error deleting image; retry" +msgstr "Errore cancellando l'immagine; riprova" + +#: geoimage/templates/geoimage/geoimage_delete.html:42 +msgid "Image removed" +msgstr "Immagine rimossa" + +#: geoimage/templates/geoimage/geoimage_delete.html:43 +msgid "Return to image on map" +msgstr "Ritorna alle immagini sulla mappa" + +#: geoimage/templates/geoimage/geoimage_delete.html:59 +msgid "Are you sure to delete image ?" +msgstr "Siete sicuri di cancellare l'immagine?" + +#: geoimage/templates/geoimage/geoimage_delete.html:63 +msgid "Cancel" +msgstr "Annulla" + +#: geoimage/templates/geoimage/geoimage_delete.html:69 +msgid "Remove" +msgstr "Rimuovi" + +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:33 +msgid "Select this image" +msgstr "Seleziona questa immagine" + +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:39 msgid "All images for " msgstr "Tutte le immagini per " -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:51 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:54 msgid "No geoimages." msgstr "No immagini georeferenziate." -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:60 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:63 msgid "previous" msgstr "precedente" -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:67 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:70 msgid "Page" msgstr "Pagina" -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:67 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:70 msgid "of" msgstr "di" -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:74 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:77 msgid "next" msgstr "successiva" -#: geoimage/templates/geoimage/geoimages_by_coordinate.html:75 +#: geoimage/templates/geoimage/geoimages_by_coordinate.html:78 msgid "last »" msgstr "ultima»" @@ -81,18 +125,18 @@ msgstr "Annulla il filtro" msgid "Submit" msgstr "Invia" -#: geoimage/views.py:20 +#: geoimage/views.py:21 msgid "Starting date" msgstr "Data iniziale" -#: geoimage/views.py:20 +#: geoimage/views.py:21 msgid "Elaborate starting from this date" msgstr "L'elaborazione inizia da questa data" -#: geoimage/views.py:22 +#: geoimage/views.py:23 msgid "Ending date" msgstr "Data di termine" -#: geoimage/views.py:22 +#: geoimage/views.py:23 msgid "Elaborate ending to this date" msgstr "L'elaborazione termina a questa data" diff --git a/python/geoimage/models.py b/python/geoimage/models.py index 7e18840a3..f146de875 100644 --- a/python/geoimage/models.py +++ b/python/geoimage/models.py @@ -84,13 +84,12 @@ def popupContent(self): return \ '\

\ - \ + \ \ \ {}\

\

{} {}

'.format( - self.user, self.id, self.image_thumbnail.url, self.comment, diff --git a/python/geoimage/templates/geoimage/geoimage_by_ident_id.html b/python/geoimage/templates/geoimage/geoimage_by_id.html similarity index 85% rename from python/geoimage/templates/geoimage/geoimage_by_ident_id.html rename to python/geoimage/templates/geoimage/geoimage_by_id.html index 7a88ea32f..1b570926d 100644 --- a/python/geoimage/templates/geoimage/geoimage_by_ident_id.html +++ b/python/geoimage/templates/geoimage/geoimage_by_id.html @@ -33,9 +33,16 @@
{{grimage.date}}
-
+
{%trans "Navigate this point by time" %} -
+
+ {% if request.user.is_authenticated %} + {% if request.user.username == grimage.user.username %} +
+ {%trans "Delete" %} +
+ {% endif %} + {% endif %}
{{grimage.comment}}
diff --git a/python/geoimage/templates/geoimage/geoimage_delete.html b/python/geoimage/templates/geoimage/geoimage_delete.html new file mode 100644 index 000000000..85ba4eb43 --- /dev/null +++ b/python/geoimage/templates/geoimage/geoimage_delete.html @@ -0,0 +1,78 @@ +{% load i18n %} + +{% load staticfiles %} + + + + + + + + + + + + + + + + +{% if invalid %} + +

{% trans 'Return to image' %}

+{% endif %} + +{% if notauthorized %} + +{% endif %} + +{% if error %} + +{% endif %} + + +{% if deleted %} + +

{% trans 'Image removed' %}

+

{% trans 'Return to image on map' %}

+ +{% else %} + +
+
+
+ +
+
+ {{grimage.comment}} +
+
+ +
+
+

{% trans 'Are you sure to delete image ?' %}

+
+ + + +
+
{% csrf_token %} + {{ delgeoimageform.as_p }} + +
+
+ +
+
+{% endif %} + + + diff --git a/python/geoimage/templates/geoimage/geoimages_by_coordinate.html b/python/geoimage/templates/geoimage/geoimages_by_coordinate.html index 0213650ad..7aa325d85 100644 --- a/python/geoimage/templates/geoimage/geoimages_by_coordinate.html +++ b/python/geoimage/templates/geoimage/geoimages_by_coordinate.html @@ -28,7 +28,10 @@
- + + + {% trans 'Select this image' %} +
diff --git a/python/geoimage/urls.py b/python/geoimage/urls.py index 3238bb04d..b23ecaa79 100644 --- a/python/geoimage/urls.py +++ b/python/geoimage/urls.py @@ -1,5 +1,5 @@ from django.conf.urls import url -from .views import geoimagesOnMap,geoimageByIdentId,geoimagesByCoordinate +from .views import geoimagesOnMap,geoimageById,geoimagesByCoordinate,geoimageDelete urlpatterns = [ url(r'^geoimagesonmap$', @@ -8,8 +8,11 @@ url(r'^geoimagesonmap/(?P[-_\w]+)/$', geoimagesOnMap,name="geoimages-on-map-by-ident"), - url(r'^geoimagebyidentid/(?P[-_\w]+)/(?P[-_\w]+)/$', - geoimageByIdentId,name="geoimage-by-ident-id"), + url(r'^geoimagebyid/(?P[-_\w]+)/$', + geoimageById,name="geoimage-by-id"), + + url(r'^geoimagedelete/(?P[-_\w]+)/$', + geoimageDelete,name="geoimage-delete"), url(r'^geoimagesbycoordinate/(?P[-_\w.]+)/(?P[-_\w.]+)/$', geoimagesByCoordinate,name="geoimages-by-coordinate"), diff --git a/python/geoimage/views.py b/python/geoimage/views.py index a7a45f947..c475b65c5 100644 --- a/python/geoimage/views.py +++ b/python/geoimage/views.py @@ -7,6 +7,7 @@ from django.forms.widgets import SelectDateWidget from django.utils.translation import ugettext_lazy from django.core.paginator import Paginator +from django.http import HttpResponse class ExtremeForm(forms.Form): @@ -43,9 +44,9 @@ def geoimagesOnMap(request,ident=None): form = ExtremeForm() # An unbound form if ident is None: - grimages=GeorefencedImage.objects.filter(date__gte=datetime_start,date__lte=datetime_end).order_by("date") + grimages=GeorefencedImage.objects.filter(active=True,date__gte=datetime_start,date__lte=datetime_end).order_by("date") else: - grimages=GeorefencedImage.objects.filter(date__gte=datetime_start,date__lte=datetime_end,user__username=ident).order_by("date") + grimages=GeorefencedImage.objects.filter(active=True,date__gte=datetime_start,date__lte=datetime_end,user__username=ident).order_by("date") return render(request, 'geoimage/geoimages_on_map.html',{'form': form,"grimages":grimages,"ident":ident}) @@ -55,13 +56,63 @@ def geoimagesByCoordinate(request,lon,lat): # json come from an unordered dict! # so this do not work #geom={'type': 'Point', 'coordinates': [float(lon),float(lat)]} coordinate="[{},{}]".format(float(lon),float(lat)) - grimages=GeorefencedImage.objects.filter(geom__contains=coordinate).order_by("date") + grimages=GeorefencedImage.objects.filter(active=True,geom__contains=coordinate).order_by("date") paginator = Paginator(grimages, 1) # Show 1 image per page. page_number = request.GET.get('page',-1) # start with last page page_obj = paginator.get_page(page_number) return render(request, 'geoimage/geoimages_by_coordinate.html',{"page_obj":page_obj}) -def geoimageByIdentId(request,ident,id): - grimage=GeorefencedImage.objects.get(user__username=ident,id=id) - return render(request, 'geoimage/geoimage_by_ident_id.html',{"grimage":grimage}) +def geoimageById(request,id): + grimage=GeorefencedImage.objects.get(id=id) + return render(request, 'geoimage/geoimage_by_id.html',{"grimage":grimage}) +class DelGeoimageForm(forms.Form): + pass + + +def geoimageDelete(request,id): + + if request.method == 'POST': # If the form has been submitted... + + delgeoimageform = DelGeoimageForm(request.POST) # A form bound to the POST data + if delgeoimageform.is_valid(): # All validation rules pass + + try: + if request.user.is_authenticated: + grimage = GeorefencedImage.objects.get(user__username=request.user.get_username(),id=id) + grimage.delete() + else: + grimage = GeorefencedImage.objects.get(id=id) + return render(request, 'geoimage/geoimage_delete.html',{"grimage":grimage,'delgeoimageform':delgeoimageform,"notauthorized":True}) + + except Exception as e: + print(e) + + grimage = GeorefencedImage.objects.get(id=id) + return render(request, 'geoimage/geoimage_delete.html',{"grimage":grimage,'delgeoimageform':delgeoimageform,"error":True}) + + return render(request, 'geoimage/geoimage_delete.html',{'delgeoimageform':delgeoimageform,"deleted":True}) + else: + delgeoimageform = DelGeoimageForm() + grimage = GeorefencedImage.objects.get(id=id) + return render(request, 'geoimage/geoimage_delete.html',{"grimage":grimage,'delgeoimageform':delgeoimageform,"invalid":True}) + + else: + delgeoimageform = DelGeoimageForm() # An unbound form + try: + + if request.user.is_authenticated: + notauthorized=False + else: + notauthorized=True + + grimage = GeorefencedImage.objects.get(id=id) + return render(request, 'geoimage/geoimage_delete.html',{"grimage":grimage,'delgeoimageform':delgeoimageform,"notauthorized":notauthorized}) + + + except Exception as e: + print(e) + + response=HttpResponse("GeorefencedImage matching query does not exist") + response.status_code=403 + return response diff --git a/python/insertdata/templates/insertdata/form.html b/python/insertdata/templates/insertdata/form.html index f6a76c66f..32f71ced1 100644 --- a/python/insertdata/templates/insertdata/form.html +++ b/python/insertdata/templates/insertdata/form.html @@ -21,7 +21,7 @@