Skip to content

Commit

Permalink
Improve display in popup
Browse files Browse the repository at this point in the history
  • Loading branch information
ehe committed Nov 10, 2021
1 parent 65464cc commit 846525d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion georiviere/description/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ class Meta:
verbose_name_plural = _("Statuses")

def __str__(self):
return ', '.join([value.label for value in self.status_types.all()])
if self.status_types.count():
return ', '.join([value.label for value in self.status_types.all()])
else:
return "{}".format(self.pk)

def clean(self):
if hasattr(self, 'topology') and self.topology is not None:
Expand Down
8 changes: 8 additions & 0 deletions georiviere/river/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ class Topology(models.Model):
end_position = models.FloatField(verbose_name=_("End position"), db_index=True, default=1)
qualified = models.BooleanField(verbose_name=_("Qualified"), null=False, default=False)

def __str__(self):
if hasattr(self, 'status'):
return "Status {}".format(self.status)
elif hasattr(self, 'morphology'):
return "Morpho {}".format(self.morphology)
else:
return _("Topology")

def save(self, *args, **kwargs):
super().save(*args, **kwargs)
geom_topology = self._meta.model.objects.filter(pk=self.pk) \
Expand Down
2 changes: 1 addition & 1 deletion georiviere/river/static/river/js/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ L.Control.PointTopology = L.Control.extend({
includes: L.Mixin.ActivableControl,

statics: {
TITLE: 'Cut',
TITLE: 'Cut topology',
},

options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div hidden="true" id="form_topology">
<form method="POST" action="{% url 'river:cut_topology' %}">
{% csrf_token %}
<p>{{ object.topology }}</p>
<input type="submit" class="btn btn-danger" value="{% trans "Cut topology" %}"></input>
<input type="hidden" id="topology" name="topology" value="{{object.topology.id}}">
<input type="hidden" id="lat" name="lat">
Expand Down

0 comments on commit 846525d

Please sign in to comment.