Commit bcecf09e authored by Baptiste Jonglez's avatar Baptiste Jonglez

Add a 'duration' field to reference points

parent f11f7817
......@@ -38,7 +38,8 @@ class PanoramaAdmin(admin.ModelAdmin):
@admin.register(ReferencePoint)
class ReferencePointAdmin(admin.ModelAdmin):
model = ReferencePoint
list_display = ('name', 'latitude', 'longitude', 'height_above_ground', 'altitude', 'kind')
list_filter = ('kind', )
fields = ('name', ('latitude', 'longitude'), ('ground_altitude', 'height_above_ground'), 'kind')
list_display = ('name', 'latitude', 'longitude', 'height_above_ground', 'altitude', 'duration', 'kind')
list_filter = ('kind', 'duration')
fields = ('name', ('latitude', 'longitude'), ('ground_altitude', 'height_above_ground'), 'kind', ('duration', 'duration_updated'))
readonly_fields = ('duration_updated',)
search_fields = ('name', )
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-01 20:50+0000\n"
"POT-Creation-Date: 2018-10-23 21:23+0000\n"
"PO-Revision-Date: 2018-07-01 22:56+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
......@@ -35,117 +35,141 @@ msgstr "Panorama"
msgid "Reference point"
msgstr "Point de référence"
#: panorama/models.py:24
#: panorama/models.py:25
msgid "latitude"
msgstr "latitude"
#: panorama/models.py:24 panorama/models.py:27
#: panorama/models.py:25 panorama/models.py:28
msgid "In degrees"
msgstr "En degrés"
#: panorama/models.py:27
#: panorama/models.py:28
msgid "longitude"
msgstr "longitude"
#: panorama/models.py:30
msgid "altitude"
msgstr "altitude"
#: panorama/models.py:31
msgid "altitude at ground level"
msgstr "altitude au sol"
#: panorama/models.py:30 panorama/models.py:34 panorama/models.py:37
#: panorama/models.py:32 panorama/models.py:35
msgid "In meters"
msgstr "En mètres"
#: panorama/models.py:33
msgid "altitude at ground level"
msgstr "altitude au sol"
#: panorama/models.py:36
#: panorama/models.py:34
msgid "height above ground"
msgstr "hauteur au-dessus du sol"
#: panorama/models.py:117
#: panorama/models.py:120
msgid "name"
msgstr "nom"
#: panorama/models.py:118
#: panorama/models.py:121
msgid "Name of the point"
msgstr "Nom du point"
#: panorama/models.py:124
#: panorama/models.py:127
msgid "waiting"
msgstr "en attente"
#: panorama/models.py:125
#: panorama/models.py:128
msgid "subscriber"
msgstr "abonné·e"
#: panorama/models.py:126
#: panorama/models.py:129
msgid "other"
msgstr "autre"
#: panorama/models.py:129
#: panorama/models.py:132
msgid "kind"
msgstr "type"
#: panorama/models.py:136 panorama/models.py:318
#: panorama/models.py:140
msgid "unknown"
msgstr "inconnue"
#: panorama/models.py:141
msgid "short"
msgstr "faible"
#: panorama/models.py:142
msgid "medium"
msgstr "moyenne"
#: panorama/models.py:143
msgid "long"
msgstr "grande"
#: panorama/models.py:146
msgid "duration"
msgstr "pérennité"
#: panorama/models.py:147
msgid "How long is this point expected to be used"
msgstr "Stabilité de ce point dans le temps"
#: panorama/models.py:152
msgid "last updated"
msgstr "mis à jour"
#: panorama/models.py:168 panorama/models.py:351
msgid "reference point"
msgstr "point de référence"
#: panorama/models.py:137
#: panorama/models.py:169
msgid "reference points"
msgstr "points de référence"
#: panorama/models.py:141
#: panorama/models.py:173
msgid "360° panorama"
msgstr "Panorama de 360°"
#: panorama/models.py:142
#: panorama/models.py:174
msgid "Whether the panorama loops around the edges"
msgstr "Si le panorama boucle sur ses côtés"
#: panorama/models.py:143
#: panorama/models.py:175
msgid "image"
msgstr "image"
#: panorama/models.py:146
#: panorama/models.py:178
msgid "image width"
msgstr "largeur de l'image"
#: panorama/models.py:147
#: panorama/models.py:179
msgid "image height"
msgstr "hauteur de l'image"
#: panorama/models.py:152 panorama/models.py:330
#: panorama/models.py:184 panorama/models.py:363
msgid "references"
msgstr "références"
#: panorama/models.py:165
#: panorama/models.py:197
msgid "Tiles available?"
msgstr "Tuiles disponibles ?"
#: panorama/models.py:304 panorama/models.py:320
#: panorama/models.py:337 panorama/models.py:353
msgid "panorama"
msgstr "panorama"
#: panorama/models.py:305
#: panorama/models.py:338
msgid "panoramas"
msgstr "panoramas"
#: panorama/models.py:329
#: panorama/models.py:362
msgid "reference"
msgstr "référence"
#: panorama/models.py:336
#: panorama/models.py:369
msgid "A panorama can't reference itself."
msgstr "Un panorama ne peut pas se référencer lui-même."
#: panorama/models.py:341
#: panorama/models.py:374
#, python-brace-format
msgid "Position {xy} is outside the bounds of the image ({width}, {height})."
msgstr ""
"La position {xy} est en dehors de l'image de taille ({width}, {height})."
#: panorama/models.py:348
#: panorama/models.py:381
#, python-brace-format
msgid "{refpoint} at {xy} in {pano}"
msgstr "{refpoint} en {xy} sur {pano}"
......@@ -336,3 +360,6 @@ msgstr "Insérer"
#: panorama/templates/panorama/view.html:199
msgid "Cancel"
msgstr "Annuler"
#~ msgid "altitude"
#~ msgstr "altitude"
......@@ -10,6 +10,7 @@ from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator
from django.core.urlresolvers import reverse
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .tasks import generate_tiles
......@@ -112,7 +113,10 @@ class Point(models.Model):
@python_2_unicode_compatible
class ReferencePoint(Point):
"""Reference point, to be used"""
"""Point of Interest (POI): can either be a prospective subscriber, a
current subscriber, or just a reference point such as a big building
or a mountain.
"""
name = models.CharField(verbose_name=_("name"), max_length=255,
help_text=_("Name of the point"))
......@@ -128,9 +132,38 @@ class ReferencePoint(Point):
kind = models.CharField(verbose_name=_('kind'), max_length=255,
choices=KIND_CHOICES, default=KIND_WAITING)
DURATION_UNKNOWN = 'unknown'
DURATION_SHORT = 'short'
DURATION_MEDIUM = 'medium'
DURATION_LONG = 'long'
DURATION_CHOICES = (
(DURATION_UNKNOWN, _('unknown')),
(DURATION_SHORT, _('short')),
(DURATION_MEDIUM, _('medium')),
(DURATION_LONG, _('long')),
)
duration = models.CharField(verbose_name=_('duration'),
help_text=_('How long is this point expected to be used'),
max_length=255,
choices=DURATION_CHOICES,
default=DURATION_UNKNOWN)
duration_updated = models.DateTimeField(default=now,
verbose_name=_("last updated"))
def __str__(self):
return self.name
def save(self, *args, **kwargs):
'''On save, update timestamp if duration has changed'''
try:
obj = ReferencePoint.objects.get(pk=self.pk)
except ReferencePoint.DoesNotExist:
return super(ReferencePoint, self).save(*args, **kwargs)
if obj.duration != self.duration:
self.duration_updated = now()
return super(ReferencePoint, self).save(*args, **kwargs)
class Meta:
verbose_name = _("reference point")
verbose_name_plural = _("reference points")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment