Merge lp:~shevonar/widelands-website/fix-missing-revisions into lp:widelands-website

Proposed by Shevonar
Status: Merged
Merged at revision: 348
Proposed branch: lp:~shevonar/widelands-website/fix-missing-revisions
Merge into: lp:widelands-website
Diff against target: 63 lines (+11/-8)
2 files modified
templates/wiki/history.html (+10/-7)
wiki/models.py (+1/-1)
To merge this branch: bzr merge lp:~shevonar/widelands-website/fix-missing-revisions
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+168897@code.launchpad.net

Description of the change

This should fix the problems with missing revisions. It is not tested, since I don't have missing revisions on my server. However, without missing revisions it is working properly.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Works straight out of the box. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'templates/wiki/history.html'
2--- templates/wiki/history.html 2012-09-10 10:13:04 +0000
3+++ templates/wiki/history.html 2013-06-12 10:10:38 +0000
4@@ -19,29 +19,31 @@
5 return true;
6 }
7
8+ {% with first=changes|first %}
9 function selectedFrom(from) {
10- for (i = 1; i <= {{ changes|length }}; i++) {
11- $("#id_to_" + i).css("display", i <= from ? "none" : "block");
12+ for (i = 1; i <= {{ first.revision }}; i++) {
13+ $("#id_to_" + i).css("display", i <= from ? "none" : "inline");
14 }
15 }
16
17 function selectedTo(to) {
18- for (i = 1; i <= {{ changes|length }}; i++) {
19- $("#id_from_" + i).css("display", i < to ? "block" : "none");
20+ for (i = 1; i <= {{ first.revision }}; i++) {
21+ $("#id_from_" + i).css("display", i < to ? "inline" : "none");
22 }
23 }
24
25 $(function() {
26 var $to = $('input:radio[name=to]');
27+ var to_revision = {{ first.revision }};
28 if ($to.is(':checked') === false) {
29- $to.filter('[value={{ changes|length }}]').attr('checked', true);
30- selectedTo({{ changes|length }});
31+ $to.filter('[value='+to_revision+']').attr('checked', true);
32+ selectedTo(to_revision);
33 } else {
34 selectedTo($('input:radio[name=to]:checked').val());
35 }
36
37 var $from = $('input:radio[name=from]');
38- var from_revision = {{ changes|length }} - 1;
39+ var from_revision = {{ first.revision }} - 1;
40 if ($from.is(':checked') === false) {
41 $from.filter('[value='+from_revision+']').attr('checked', true);
42 selectedFrom(from_revision);
43@@ -49,6 +51,7 @@
44 selectedFrom($('input:radio[name=from]:checked').val());
45 }
46 });
47+ {% endwith %}
48 </script>
49 {% endif %}
50
51
52=== modified file 'wiki/models.py'
53--- wiki/models.py 2012-09-10 10:13:04 +0000
54+++ wiki/models.py 2013-06-12 10:10:38 +0000
55@@ -296,7 +296,7 @@
56 def compare_to(self, revision_from):
57 other_content = u""
58 if revision_from > 0:
59- other_content = ChangeSet.objects.filter(article=self.article, revision=revision_from)[0].get_content()
60+ other_content = ChangeSet.objects.filter(article=self.article, revision__lte=revision_from).order_by("-revision")[0].get_content()
61 diffs = dmp.diff_main(other_content, self.get_content())
62 dmp.diff_cleanupSemantic(diffs)
63 return dmp.diff_prettyHtml(diffs)

Subscribers

People subscribed via source and target branches