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

Portuguese Translations, relative url and custom_admin_media_prefix tag changes #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions filebrowser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

# filebrowser imports
from filebrowser.settings import *
from filebrowser.functions import get_file_type, url_join, is_selectable, get_version_path
from filebrowser.functions import get_file_type, url_join, is_selectable, \
get_version_path, path_strip
from django.utils.encoding import force_unicode

# PIL import
Expand All @@ -30,8 +31,8 @@ class FileObject(object):
"""

def __init__(self, path):
self.path = path
self.url_rel = path.replace("\\","/")
self.path = path_strip(path, DIRECTORY)
self.url_rel = self.path.replace("\\","/")
self.head = os.path.split(path)[0]
self.filename = os.path.split(path)[1]
self.filename_lower = self.filename.lower() # important for sorting
Expand Down Expand Up @@ -85,7 +86,7 @@ def _path_full(self):
"""
return os.path.join(MEDIA_ROOT, self.path)
path_full = property(_path_full)

def _path_relative(self):
return self.path
path_relative = property(_path_relative)
Expand Down Expand Up @@ -115,7 +116,11 @@ def _url_save(self):
URL used for the filebrowsefield.
"""
if SAVE_FULL_URL:
return self.url_full
if SAVE_DOMAIN_URL:
from django.contrib.sites.models import Site
return 'http://%s%s' % (Site.objects.get_current().domain, self.url_full)
else:
return self.url_full
else:
return self.url_rel
url_save = property(_url_save)
Expand Down
8 changes: 8 additions & 0 deletions filebrowser/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,12 @@ def convert_filename(value):
else:
return value

def path_strip(path, root):
if not path or not root:
return path
path = os.path.normcase(path)
root = os.path.normcase(root)
if path.startswith(root):
return path[len(root):]
return path

Binary file added filebrowser/locale/pt/LC_MESSAGES/django.mo
Binary file not shown.
Loading