show edit button in changeset view

This commit is contained in:
Laura Klünder 2017-06-18 23:11:48 +02:00
parent ded19de8e9
commit ba3826fcf4
3 changed files with 25 additions and 0 deletions

View file

@ -137,6 +137,11 @@ form button.invisiblesubmit {
.change-group tr th small { .change-group tr th small {
font-weight:normal; font-weight:normal;
} }
.change-group tr th .btn.pull-right {
margin-right: -5px;
margin-top: -2px;
margin-bottom: -3px;
}
.change-group tr td:first-child { .change-group tr td:first-child {
width:23px; width:23px;
padding-right:0; padding-right:0;

View file

@ -16,6 +16,11 @@
<thead> <thead>
<tr> <tr>
<th colspan="3"> <th colspan="3">
{% if group.edit_url %}
<a class="btn btn-default btn-xs pull-right" href="{{ group.edit_url }}">
{% trans 'Edit' %}
</a>
{% endif %}
{% if group.obj_title %} {% if group.obj_title %}
{{ group.obj_title }} <small>({{ group.obj }})</small> {{ group.obj_title }} <small>({{ group.obj }})</small>
{% else %} {% else %}

View file

@ -377,11 +377,26 @@ def changeset_detail(request, pk):
obj_desc = _('%(model)s #%(id)s') % {'model': obj.__class__._meta.verbose_name, 'id': pk} obj_desc = _('%(model)s #%(id)s') % {'model': obj.__class__._meta.verbose_name, 'id': pk}
if is_created_pk(pk): if is_created_pk(pk):
obj_desc = _('%s (created)') % obj_desc obj_desc = _('%s (created)') % obj_desc
obj_still_exists = int(pk[1:]) in changeset.created_objects[obj.__class__]
else:
obj_still_exists = pk not in changeset.deleted_existing[obj.__class__]
edit_url = None
if obj_still_exists and changeset == request.changeset:
reverse_kwargs = {'pk': obj.pk}
if hasattr(obj, 'level'):
reverse_kwargs['level'] = obj.level_id
elif hasattr(obj, 'space'):
reverse_kwargs['space'] = obj.space_id
edit_url = reverse('editor.'+obj.__class__._meta.default_related_name+'.edit', kwargs=reverse_kwargs)
grouped_changes.append({ grouped_changes.append({
'model': obj.__class__, 'model': obj.__class__,
'model_title': obj.__class__._meta.verbose_name,
'obj': obj_desc, 'obj': obj_desc,
'obj_title': obj.title if obj.titles else None, 'obj_title': obj.title if obj.titles else None,
'changes': changes, 'changes': changes,
'edit_url': edit_url,
}) })
last_obj = obj last_obj = obj