0001-snapshots-add-navigation-links-50010.patch
tests/test_snapshots.py | ||
---|---|---|
339 | 339 |
resp = resp.click(href='%s/view/' % snapshot.id) |
340 | 340 |
assert 'This form is readonly' in resp.text |
341 | 341 |
assert '<p>%s</p>' % localstrftime(snapshot.timestamp) in resp.text |
342 | ||
343 |
assert 'Lt' not in resp.text |
|
344 |
assert 'LT' not in resp.text |
|
345 |
assert '<a href="../../%s/view/">></a>' % (snapshot.id - 1) in resp.text |
|
346 |
assert '<a href="../../%s/view/">≫</a>' % (snapshot.id - 6) in resp.text |
|
347 | ||
348 |
resp = resp.click(href='../../%s/view/' % (snapshot.id - 1)) |
|
349 |
assert '<a href="../../%s/view/">≪</a>' % snapshot.id in resp.text |
|
350 |
assert '<a href="../../%s/view/"><</a>' % snapshot.id in resp.text |
|
351 |
assert '<a href="../../%s/view/">></a>' % (snapshot.id - 2) in resp.text |
|
352 |
assert '<a href="../../%s/view/">≫</a>' % (snapshot.id - 6) in resp.text |
|
353 | ||
354 |
resp = resp.click(href='../../%s/view/' % (snapshot.id - 6)) |
|
355 |
assert '<a href="../../%s/view/">≪</a>' % snapshot.id in resp.text |
|
356 |
assert '<a href="../../%s/view/"><</a>' % (snapshot.id - 5) in resp.text |
|
357 |
assert 'GT' not in resp.text |
|
358 |
assert 'Gt' not in resp.text |
|
359 | ||
360 |
resp = resp.click(href='../../%s/view/' % snapshot.id) |
|
342 | 361 |
resp = resp.click('Description') |
343 | 362 |
assert resp.form['description'].value == 'this is a description (5)' |
344 | 363 |
assert [x[0].name for x in resp.form.fields.values() if x[0].tag == 'button'] == ['cancel'] |
wcs/admin/utils.py | ||
---|---|---|
62 | 62 |
parts.append(misc.localstrftime(snapshot.timestamp)) |
63 | 63 |
r += htmltext('<br />').join(parts) |
64 | 64 |
r += htmltext('</p>') |
65 |
if snapshot.previous or snapshot.next: |
|
66 |
r += htmltext('<p>') |
|
67 |
if snapshot.id != snapshot.first: |
|
68 |
r += htmltext(' <a href="../../%s/view/">≪</a>') % (snapshot.first) |
|
69 |
if snapshot.previous: |
|
70 |
r += htmltext(' <a href="../../%s/view/"><</a>') % (snapshot.previous) |
|
71 |
if snapshot.next: |
|
72 |
r += htmltext(' <a href="../../%s/view/">></a>') % (snapshot.next) |
|
73 |
if snapshot.id != snapshot.last: |
|
74 |
r += htmltext(' <a href="../../%s/view/">≫</a>') % (snapshot.last) |
|
75 |
r += htmltext('</p>') |
|
65 | 76 |
return r.getvalue() |
wcs/snapshots.py | ||
---|---|---|
102 | 102 |
self._user = UnknownUser() |
103 | 103 |
return self._user |
104 | 104 | |
105 |
def load_history(self): |
|
106 |
if not self.instance: |
|
107 |
self._history = [] |
|
108 |
return |
|
109 |
history = get_publisher().snapshot_class.select_object_history(self.instance) |
|
110 |
self._history = [s.id for s in history] |
|
111 | ||
112 |
@property |
|
113 |
def previous(self): |
|
114 |
if not hasattr(self, '_history'): |
|
115 |
self.load_history() |
|
116 | ||
117 |
try: |
|
118 |
idx = self._history.index(self.id) |
|
119 |
except ValueError: |
|
120 |
return None |
|
121 |
if idx == 0: |
|
122 |
return None |
|
123 |
return self._history[idx - 1] |
|
124 | ||
125 |
@property |
|
126 |
def next(self): |
|
127 |
if not hasattr(self, '_history'): |
|
128 |
self.load_history() |
|
129 | ||
130 |
try: |
|
131 |
idx = self._history.index(self.id) |
|
132 |
except ValueError: |
|
133 |
return None |
|
134 |
try: |
|
135 |
return self._history[idx + 1] |
|
136 |
except IndexError: |
|
137 |
return None |
|
138 | ||
139 |
@property |
|
140 |
def first(self): |
|
141 |
if not hasattr(self, '_history'): |
|
142 |
self.load_history() |
|
143 | ||
144 |
return self._history[0] |
|
145 | ||
146 |
@property |
|
147 |
def last(self): |
|
148 |
if not hasattr(self, '_history'): |
|
149 |
self.load_history() |
|
150 | ||
151 |
return self._history[-1] |
|
152 | ||
105 | 153 |
def restore(self, as_new=True): |
106 | 154 |
instance = self.instance |
107 | 155 |
if as_new: |
108 |
- |