fix up version numbers
This commit is contained in:
		
							parent
							
								
									45b10ca526
								
							
						
					
					
						commit
						ee2d302396
					
				| 
						 | 
					@ -162,7 +162,7 @@ class Item(TimeStampedModel):
 | 
				
			||||||
        return url_for('.view_item',
 | 
					        return url_for('.view_item',
 | 
				
			||||||
                       username=self.user.username,
 | 
					                       username=self.user.username,
 | 
				
			||||||
                       hashid=self.hashid,
 | 
					                       hashid=self.hashid,
 | 
				
			||||||
                       v=version.transaction_id)
 | 
					                       v=version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def history_url(self):
 | 
					    def history_url(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<ul>
 | 
					<ul>
 | 
				
			||||||
  {% for v in doc.versions %}
 | 
					  {% for v in doc.versions %}
 | 
				
			||||||
    <li><a href="{{ doc.version_url(v) }}">{{ v.modified.strftime('%H:%M:%S, %d %B %Y') }}</a></li>
 | 
					    <li><a href="{{ doc.version_url(loop.index) }}">{{ v.modified.strftime('%H:%M:%S, %d %B %Y') }}</a></li>
 | 
				
			||||||
  {% endfor %}
 | 
					  {% endfor %}
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -213,11 +213,14 @@ def view_item(username, hashid, raw=False):
 | 
				
			||||||
    if raw:
 | 
					    if raw:
 | 
				
			||||||
        return Response(item.text, mimetype='text/plain')
 | 
					        return Response(item.text, mimetype='text/plain')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if 'v' in request.args and request.args['v'].isdigit():
 | 
					    v = request.args.get('v')
 | 
				
			||||||
        ItemVersion = version_class(Item)
 | 
					    if v:
 | 
				
			||||||
        version = (session.query(ItemVersion)
 | 
					        if not v.isdigit():
 | 
				
			||||||
                          .filter_by(transaction_id=int(request.args['v']))
 | 
					            abort(404)
 | 
				
			||||||
                          .first())
 | 
					        try:
 | 
				
			||||||
 | 
					            version = item.versions[int(v) - 1]
 | 
				
			||||||
 | 
					        except IndexError:
 | 
				
			||||||
 | 
					            abort(404)
 | 
				
			||||||
        text = version.text
 | 
					        text = version.text
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        version = None
 | 
					        version = None
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue