Skip to content

Commit 089ba8b

Browse files
committed
Fixed history display
1 parent 5c342f8 commit 089ba8b

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Diff for: fill_db_with_fakes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main():
5656
l.vote(random.choice(user_ids), prop_id, vote)
5757

5858
if random.randint(0, 3) == 0:
59-
data['notes'] = 'UPDATED' + ipsum(2)
59+
data['description'] = 'UPDATED ' + ipsum(4)
6060
l.add_proposal(data)
6161

6262

Diff for: logic.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ def add_proposal(data):
193193
return None
194194

195195
q = 'UPDATE proposals SET data=%s, data_history=%s, updated=now() WHERE id=%s'
196-
proposal.data['when'] = proposal.updated.isoformat()
196+
new_data = cleaned_data.copy()
197+
new_data['when'] = datetime.datetime.now().isoformat()
197198
data_history = proposal.data_history
198-
data_history.append(proposal.data)
199+
data_history.insert(0, new_data)
199200
execute(q, (Json(cleaned_data), Json(data_history), data['id']))
200201

201202
return data['id']

Diff for: templates/proposal_render.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="tab-content">
1313
{% for version in proposal.data_history%}
1414
<div class="tab-pane{%if loop.first%} active{%endif%}" id="rev-{{loop.index0}}">
15-
<h1>{{version.title}}</h1>
15+
<h1>{{version.title}} {{loop.index0}}</h1>
1616
<table class="table">
1717
<tbody>
1818
<tr><th>Category</th>
@@ -31,7 +31,7 @@ <h1>{{version.title}}</h1>
3131
<tr><th>Created</th>
3232
<td>{{proposal.added_on|date}}</td></tr>
3333
<tr><th>Last Updated</th>
34-
<td>{{proposal.updated|date}}</td></tr>
34+
<td>{{version.when}}</td></tr>
3535
{%endif%}
3636
</tbody>
3737
</table>

0 commit comments

Comments
 (0)