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',
 | 
			
		||||
                       username=self.user.username,
 | 
			
		||||
                       hashid=self.hashid,
 | 
			
		||||
                       v=version.transaction_id)
 | 
			
		||||
                       v=version)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def history_url(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@
 | 
			
		|||
 | 
			
		||||
<ul>
 | 
			
		||||
  {% 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 %}
 | 
			
		||||
</ul>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -213,11 +213,14 @@ def view_item(username, hashid, raw=False):
 | 
			
		|||
    if raw:
 | 
			
		||||
        return Response(item.text, mimetype='text/plain')
 | 
			
		||||
 | 
			
		||||
    if 'v' in request.args and request.args['v'].isdigit():
 | 
			
		||||
        ItemVersion = version_class(Item)
 | 
			
		||||
        version = (session.query(ItemVersion)
 | 
			
		||||
                          .filter_by(transaction_id=int(request.args['v']))
 | 
			
		||||
                          .first())
 | 
			
		||||
    v = request.args.get('v')
 | 
			
		||||
    if v:
 | 
			
		||||
        if not v.isdigit():
 | 
			
		||||
            abort(404)
 | 
			
		||||
        try:
 | 
			
		||||
            version = item.versions[int(v) - 1]
 | 
			
		||||
        except IndexError:
 | 
			
		||||
            abort(404)
 | 
			
		||||
        text = version.text
 | 
			
		||||
    else:
 | 
			
		||||
        version = None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue