add has_no_effect check to changes and replace undo button icon

This commit is contained in:
Laura Klünder 2017-06-25 16:12:57 +02:00
parent 1d479c4eba
commit 79220c39f9
4 changed files with 12 additions and 2 deletions

View file

@ -172,6 +172,11 @@ form button.invisiblesubmit {
margin-top: -6px;
margin-bottom: -2px;
margin-right: -5px;
margin-left: 5px;
}
.change-group .glyphicon-share-alt {
transform: scale(-1, 1);
-webkit-transform: scale(-1, 1);
}
.change-group tr td:last-child>i {
margin-right: -2px;

View file

@ -29,6 +29,8 @@
<td class="text-muted">
{% if change.apply_problem %}
<i class="glyphicon glyphicon-alert text-danger" data-toggle="tooltip" data-placement="left" title="{{ change.apply_problem }}"></i>
{% elif change.has_no_effect %}
<i class="glyphicon glyphicon-ok text-success" data-toggle="tooltip" data-placement="left" title="{% trans 'This change has no effect. You can delete it.' %}"></i>
{% endif %}
{% if change.author and change.author != changeset.author %}
<i class="glyphicon glyphicon-user text-muted" data-toggle="tooltip" data-placement="left" title="{{ change.author.username }}"></i>
@ -38,7 +40,7 @@
{% endif %}
{% if change.can_restore %}
<a class="btn btn-xs btn-default" data-toggle="tooltip" data-placement="left" title="{% trans 'Undo this change' %}">
<i class="glyphicon glyphicon-trash"></i>
<i class="glyphicon glyphicon-share-alt"></i>
</a>
{% endif %}
</td>

View file

@ -129,6 +129,7 @@ def group_changes(changeset, can_edit=False, show_history=False):
else:
change_data.update({
'apply_problem': change.check_apply_problem(),
'has_no_effect': change.check_has_no_effect(),
'can_restore': change.can_restore,
})
changes.append(change_data)

View file

@ -49,7 +49,9 @@ class GeometryField(models.TextField):
return clean_geometry(shape(json.loads(value)))
def get_prep_value(self, value):
if self.geomtype == 'polygon' and not isinstance(value, Polygon):
if value == '':
return None
elif self.geomtype == 'polygon' and not isinstance(value, Polygon):
raise TypeError(_('Expected Polygon instance, got %s instead.') % repr(value))
elif self.geomtype == 'linestring' and not isinstance(value, LineString):
raise TypeError(_('Expected LineString instance, got %s instead.') % repr(value))