Fix for URL generation in model classes.

This commit is contained in:
Edward Betts 2018-06-04 07:43:40 +01:00
parent 2f5c4d7e79
commit c7ef45d126

View file

@ -155,34 +155,34 @@ class Item(TimeStampedModel):
@property
def url(self):
return url_for('.view_item',
return url_for('view.view_item',
username=self.user.username,
hashid=self.hashid)
def version_url(self, version):
return url_for('.view_item',
return url_for('view.view_item',
username=self.user.username,
hashid=self.hashid,
v=version)
@property
def history_url(self):
return url_for('.history', username=self.user.username, hashid=self.hashid)
return url_for('view.history', username=self.user.username, hashid=self.hashid)
@property
def external_url(self):
return url_for('.view_item',
return url_for('view.view_item',
username=self.user.username,
hashid=self.hashid,
_external=True)
@property
def edit_url(self):
return url_for('.edit_item', username=self.user.username, hashid=self.hashid)
return url_for('view.edit_item', username=self.user.username, hashid=self.hashid)
@property
def set_title_url(self):
return url_for('.set_title', username=self.user.username, hashid=self.hashid)
return url_for('view.set_title', username=self.user.username, hashid=self.hashid)
def title(self, titles=None):
if not titles:
@ -211,8 +211,9 @@ span: {},start=0,length={}'''.format(self.external_url, title_source_doc.externa
session.commit()
@classmethod
def from_external(cls, url):
home = url_for('.home', _external=True)
def from_external(cls, url, home=None):
if home is None:
home = url_for('view.home', _external=True)
if url.startswith(home):
username, _, hashid = url[len(home):].partition('/')
else: