Skip to content
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

Closed
wants to merge 6 commits into from
Closed

URLs that stay the same when a file is replaced. Fixes #478 #591

wants to merge 6 commits into from

Conversation

jvamvas
Copy link
Contributor

@jvamvas jvamvas commented Sep 18, 2015

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:

screen shot 2015-09-18 at 17 04 17

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.

if self.file and self.is_public:
try:
url = urlresolvers.reverse('canonical', kwargs={
'uploaded_at': self.uploaded_at.strftime('%s'),
Copy link
Contributor Author

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 jvamvas changed the title URLs that don't change when the file is replaced. Fixes #478 URLs that stay the same when a file is replaced. Fixes #478 Sep 18, 2015
@yakky
Copy link
Member

yakky commented Sep 25, 2015

@jvamvas really nice
👍 from me

from filer import views

urlpatterns = [
url(r'canonical/(?P<uploaded_at>[0-9]+)/(?P<file_id>[0-9]+)/$', views.canonical, name='canonical'),
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with 19b7815.

@yakky
Copy link
Member

yakky commented Sep 28, 2015

@stefanfoulis @mkoistinen is this good for you?
If so I'll resolve the conflicts and merge it myself

@stefanfoulis
Copy link
Contributor

@yakky 👍 from me :-)

@yakky yakky mentioned this pull request Oct 9, 2015
@yakky yakky closed this in #596 Oct 10, 2015
yakky added a commit that referenced this pull request Oct 10, 2015
@yakky
Copy link
Member

yakky commented Oct 10, 2015

@jvamvas merged. Thanks a lot for your great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants