Skip to content

Commit

Permalink
added delete geoimage functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Dec 11, 2023
1 parent cf7045e commit 16118e1
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 48 deletions.
11 changes: 8 additions & 3 deletions python/amqp2dballed
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions python/app_dist/rmap-core_app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down Expand Up @@ -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 = []
Expand Down
72 changes: 58 additions & 14 deletions python/geoimage/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 &raquo;"
msgstr "ultima&raquo;"

Expand All @@ -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"
3 changes: 1 addition & 2 deletions python/geoimage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ def popupContent(self):
return \
'\
<p>\
<a href="#" onClick="window.open(\'/geoimage/geoimagebyidentid/{}/{}/\',\'geoimage\', \'width=1024, height=900\').focus(); return false;" >\
<a href="#" onClick="window.open(\'/geoimage/geoimagebyid/{}/\',\'geoimage\', \'width=1024, height=900\').focus(); return false;" >\
<img src="/{}" style="float:right;">\
</a>\
{}\
</p>\
<p><a href="/geoimage/geoimagesonmap/{}">{}</a> {}</p>'.format(
self.user,
self.id,
self.image_thumbnail.url,
self.comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
<div class="col-xs-4">
{{grimage.date}}
</div>
<div class="col-xs-4">
<div class="col-xs-2">
<a href="{% url 'geoimages-by-coordinate' grimage.lon grimage.lat %}">{%trans "Navigate this point by time" %}</a>
</div>
</div>
{% if request.user.is_authenticated %}
{% if request.user.username == grimage.user.username %}
<div class="col-xs-2">
<a href="{% url 'geoimage-delete' grimage.id %}">{%trans "Delete" %}</a>
</div>
{% endif %}
{% endif %}
<div class="col-xs-12">
{{grimage.comment}}
</div>
Expand Down
78 changes: 78 additions & 0 deletions python/geoimage/templates/geoimage/geoimage_delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{% load i18n %}
<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
<style>
img {
float: right;
border: 3px solid black;
margin: 0px 0px 10px 10px;
}
</style>
<meta name="viewport" content="width=device-width">
<script src="{% static "rmap/libs/jquery/2.1.1/jquery.min.js" %}" type="text/javascript"></script>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="{% static "rmap/libs/bootstrap/3.3.6/css/bootstrap.min.css" %}" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" >
<link rel="stylesheet" type="text/css" href="{% static "rmap/libs/bootstrap/3.3.6/css/docs.min.css" %}" >

<!-- Custom styles for this template -->
<script src="{% static "rmap/libs/bootstrap/3.3.6/js/bootstrap.min.js" %}" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body>

{% if invalid %}
<div class="alert alert-warning" role="alert">{% trans 'Invalid data; retry' %}</div>
<h3 id="striped-rows"><a href={% url 'geoimage-by-id' grimage.id %}>{% trans 'Return to image' %}</a> </h3>
{% endif %}

{% if notauthorized %}
<div class="alert alert-warning" role="alert">{% trans 'The image is not your own; cannot remove!' %}</div>
{% endif %}

{% if error %}
<div class="alert alert-danger" role="alert">{% trans 'Error deleting image; retry' %}</div>
{% endif %}


{% if deleted %}

<h3 id="striped-rows">{% trans 'Image removed' %}</h3>
<h3 id="striped-rows"><a href={% url 'geoimages-on-map' %}>{% trans 'Return to image on map' %}</a> </h3>

{% else %}

<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<img src="/{{ grimage.image.url }}" class="img-rounded img-responsive">
</div>
<div class="col-xs-12">
{{grimage.comment}}
</div>
</div>

<div class="row">
<div class="col-xs-6">
<h3>{% trans 'Are you sure to delete image ?' %}</h3>
</div>

<div class="col-xs-3">
<h3 id="striped-rows"><a href={% url 'geoimages-on-map' %}>{% trans 'Cancel' %}</a> </h3>
</div>

<div class="col-xs-3">
<form enctype="multipart/form-data" method="POST">{% csrf_token %}
{{ delgeoimageform.as_p }}
<input type="submit" value={%trans "Remove" %} class="btn">
</form>
</div>

</div>
</div>
{% endif %}

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

<div class="row">
<div class="col-xs-12">
<img src="/{{ grimage.image.url }}" class="img-rounded img-responsive">
<a href="{% url 'geoimage-by-id' grimage.id %}">
<img src="/{{ grimage.image.url }}" class="img-rounded img-responsive">
{% trans 'Select this image' %}
</a>
</div>
</div>
<div class="row">
Expand Down
9 changes: 6 additions & 3 deletions python/geoimage/urls.py
Original file line number Diff line number Diff line change
@@ -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$',
Expand All @@ -8,8 +8,11 @@
url(r'^geoimagesonmap/(?P<ident>[-_\w]+)/$',
geoimagesOnMap,name="geoimages-on-map-by-ident"),

url(r'^geoimagebyidentid/(?P<ident>[-_\w]+)/(?P<id>[-_\w]+)/$',
geoimageByIdentId,name="geoimage-by-ident-id"),
url(r'^geoimagebyid/(?P<id>[-_\w]+)/$',
geoimageById,name="geoimage-by-id"),

url(r'^geoimagedelete/(?P<id>[-_\w]+)/$',
geoimageDelete,name="geoimage-delete"),

url(r'^geoimagesbycoordinate/(?P<lon>[-_\w.]+)/(?P<lat>[-_\w.]+)/$',
geoimagesByCoordinate,name="geoimages-by-coordinate"),
Expand Down
Loading

0 comments on commit 16118e1

Please sign in to comment.