Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Start on the display page

Tom Bowyer6e1db042ca52
diff --git a/wger/exercises/templates/history/list3.html b/wger/exercises/templates/history/list3.html
index e9809033f..1c5c45794 100644
--- a/wger/exercises/templates/history/list3.html
+++ b/wger/exercises/templates/history/list3.html
@@ -1,4 +1,4 @@
-{% extends "base.html" %}
+{% extends "base_wide.html" %}
{% load i18n %}
{% load static %}
{% load wger_extras %}
@@ -21,51 +21,55 @@
Main Content
-->
{% block content %}
-<div class="accordion" id="accordionExample">
- {% for entry in history %}
- <div class="card">
- <div class="card-header" id="heading{{ entry.record.history_id }}">
- <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse"
- data-target="#collapse{{ entry.record.history_id }}" aria-expanded="true"
- aria-controls="collapse{{ entry.record.history_id }}">
- History entry for {{ entry.record.instance.name }}
- <small>{{ entry.record.history_date }}</small>
- </button>
- </div>
- <div id="collapse{{ entry.record.history_id }}" class="collapse"
- aria-labelledby="heading{{ entry.record.history_id }}" data-parent="#accordionExample">
- <div class="card-body">
- {% if entry.record.history_type == '~' %}
- <table class="table">
- <thead>
- <tr>
- <td>Field</td>
- <td>Old</td>
- <td>New</td>
- </tr>
- </thead>
- <tbody>
- {% if entry.delta %}
- {% for change in entry.delta.changes %}
- <tr>
- <td>{{ change.field }}</td>
- <td>{{ change.old }}</td>
- <td>{{ change.new }}</td>
- </tr>
- {% endfor %}
- {% endif %}
- </tbody>
- </table>
- {% elif entry.record.history_type == '-' %}
- <p>Entry deleted</p>
- {% elif entry.record.history_type == '+' %}
- <p>Entry created</p>
- {% endif %}
- </div>
- </div>
- </div>
- {% endfor %}
-</div>
+ <table class="table">
+ <thead>
+ <tr>
+ <th scope="col">{% translate 'User' %}</th>
+ <th scope="col">{% translate 'Object' %}</th>
+ <th scope="col">{% translate 'Time' %}</th>
+ <th scope="col">{% translate 'Changes' %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for event in history %}
+ <tr>
+ <td>{{ event.stream.actor }}</td>
+ <td>
+ {% if event.stream.action_object.get_absolute_url %}
+ <a href="{{ event.action_object.get_absolute_url }}">{{ event.stream.action_object }}</a>
+ {% else %}
+ {{ event.stream.action_object }}
+ {% endif %}
+ </td>
+ <td>{{ event.stream.timesince }}</td>
+ <td>
+ <div class="card-body">
+ <table class="table">
+ <thead>
+ <tr>
+ <td>Field</td>
+ <td>Old</td>
+ <td>New</td>
+ </tr>
+ </thead>
+ <tbody>
+ {% if event.history.delta %}
+ {% for change in event.history.delta.changes %}
+ <tr>
+ <td>{{ change.field }}</td>
+ <td>{{ change.old }}</td>
+ <td>{{ change.new }}</td>
+ </tr>
+ {% endfor %}
+ {% endif %}
+ </tbody>
+ </table>
+ </div>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
{% endblock %}
diff --git a/wger/exercises/views/history.py b/wger/exercises/views/history.py
index 83edc930f..a1a94369d 100644
--- a/wger/exercises/views/history.py
+++ b/wger/exercises/views/history.py
@@ -39,7 +39,7 @@ def overview(request):
Generic view to list the history of the exercises
"""
context = {
- 'stream': Action.objects.get(),
+ 'stream': Action.objects.all(),
# We can't pass the enum to the template, so we have to do this
# https://stackoverflow.com/questions/35953132/
@@ -57,8 +57,7 @@ def overview2(request):
out = []
for entry in Exercise.history.all():
if entry.prev_record:
- out.append(
- {'record': entry, 'delta': entry.diff_against(entry.prev_record)})
+ out.append({'record': entry, 'delta': entry.diff_against(entry.prev_record)})
return render(request, 'history/list2.html', {'history': out})
@@ -78,11 +77,20 @@ def control(request):
for entry in stream:
# Fetch history
hist_id = entry.data['data']['history_id']
- hist = Exercise.history.filter(history_id=hist_id)
- out.append({
- 'history': hist,
- 'stream': entry
- })
+ hist = Exercise.history.filter(history_id=hist_id).first()
+
+ if hist.prev_record:
+ out.append({
+ 'history': {'record': hist, 'delta': hist.diff_against(hist.prev_record)},
+ 'stream': entry
+ })
+ else:
+ out.append({
+ 'history': {'record': hist, 'delta': None},
+ 'stream': entry
+ })
+
+ print(out)
return render(request, 'history/list3.html', {
'history': out,