New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLs that stay the same when a file is replaced. Fixes #478 #591
Conversation
if self.file and self.is_public: | ||
try: | ||
url = urlresolvers.reverse('canonical', kwargs={ | ||
'uploaded_at': self.uploaded_at.strftime('%s'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the File.uploaded_at
field, which is non-editable, to make the public file's canonical URL a little bit harder to guess.
@jvamvas really nice |
from filer import views | ||
|
||
urlpatterns = [ | ||
url(r'canonical/(?P<uploaded_at>[0-9]+)/(?P<file_id>[0-9]+)/$', views.canonical, name='canonical'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making the canonical
part of the path configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with 19b7815.
@stefanfoulis @mkoistinen is this good for you? |
@yakky 👍 from me :-) |
@jvamvas merged. Thanks a lot for your great work |
Sometimes users share the direct URL of public files. But whenever they update the file in the "advanced" panel on the file's admin page, the direct URL changes as well.
Perhaps django-filer could include a canonical URL that redirects to the latest version of a public file and that can be shared safely:
If they wish to use canonical URLs, users need to include filer's URLConf in their project's
urls.py
. If they don't configure their project that way, or if they create a non-public file, the filer admin does not display a canonical URL.