Coding style overhaul for Python files (PEP8 conformant). Removed buggy csstidy pytho...
[redakcja.git] / apps / filebrowser / fb_settings.py
1 # -*- coding: utf-8
2
3 import os
4 from django.conf import settings
5 from django.utils.translation import ugettext_lazy as _
6
7 # settings for django-tinymce
8 try:
9     import tinymce.settings
10     DEFAULT_URL_TINYMCE = tinymce.settings.JS_BASE_URL + '/'
11     DEFAULT_PATH_TINYMCE = tinymce.settings.JS_ROOT + '/'
12 except ImportError:
13     DEFAULT_URL_TINYMCE = settings.ADMIN_MEDIA_PREFIX + "tinymce/jscripts/tiny_mce/"
14     DEFAULT_PATH_TINYMCE = os.path.join(settings.MEDIA_ROOT, 'admin/tinymce/jscripts/tiny_mce/')
15
16 # Set to True in order to see the FileObject when Browsing.
17 DEBUG = getattr(settings, "FILEBROWSER_DEBUG", False)
18
19 # Main Media Settings
20 MEDIA_ROOT = getattr(settings, "FILEBROWSER_MEDIA_ROOT", settings.MEDIA_ROOT)
21 MEDIA_URL = getattr(settings, "FILEBROWSER_MEDIA_URL", settings.MEDIA_URL)
22
23 # Main FileBrowser Directory. This has to be a directory within MEDIA_ROOT.
24 # Leave empty in order to browse all files under MEDIA_ROOT.
25 # DO NOT USE A SLASH AT THE BEGINNING, DO NOT FORGET THE TRAILING SLASH AT THE END.
26 DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')
27
28 # The URL/PATH to your filebrowser media-files.
29 URL_FILEBROWSER_MEDIA = getattr(settings, "FILEBROWSER_URL_FILEBROWSER_MEDIA", "/media/filebrowser/")
30 PATH_FILEBROWSER_MEDIA = getattr(settings, "FILEBROWSER_PATH_FILEBROWSER_MEDIA", os.path.join(settings.MEDIA_ROOT, 'filebrowser/'))
31
32 # The URL/PATH to your TinyMCE Installation.
33 URL_TINYMCE = getattr(settings, "FILEBROWSER_URL_TINYMCE", DEFAULT_URL_TINYMCE)
34 PATH_TINYMCE = getattr(settings, "FILEBROWSER_PATH_TINYMCE", DEFAULT_PATH_TINYMCE)
35
36 # Allowed Extensions for File Upload. Lower case is important.
37 # Please be aware that there are Icons for the default extension settings.
38 # Therefore, if you add a category (e.g. "Misc"), you won't get an icon.
39 EXTENSIONS = getattr(settings, "FILEBROWSER_EXTENSIONS", {
40     'Folder': [''],
41     'Image': ['.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff'],
42     'Video': ['.mov', '.wmv', '.mpeg', '.mpg', '.avi', '.rm'],
43     'Document': ['.pdf', '.doc', '.rtf', '.txt', '.xls', '.csv'],
44     'Sound': ['.mp3', '.mp4', '.wav', '.aiff', '.midi', '.m4p'],
45     'Code': ['.html', '.py', '.js', '.css'],
46 })
47
48 # Define different formats for allowed selections.
49 # This has to be a subset of EXTENSIONS.
50 SELECT_FORMATS = getattr(settings, "FILEBROWSER_SELECT_FORMATS", {
51     'File': ['Folder', 'Document', ],
52     'Image': ['Image'],
53     'Media': ['Video', 'Sound'],
54     'Document': ['Document'],
55     # for TinyMCE we can also define lower-case items
56     'image': ['Image'],
57     'file': ['Folder', 'Image', 'Document', ],
58 })
59
60 # Directory to Save Image Versions (and Thumbnails). Relative to MEDIA_ROOT.
61 # If no directory is given, versions are stored within the Image directory.
62 # VERSION URL: VERSIONS_BASEDIR/original_path/originalfilename_versionsuffix.extension
63 VERSIONS_BASEDIR = getattr(settings, 'FILEBROWSER_VERSIONS_BASEDIR', '')
64 # Versions Format. Available Attributes: verbose_name, width, height, opts
65 VERSIONS = getattr(settings, "FILEBROWSER_VERSIONS", {
66     'fb_thumb': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop upscale'},
67     'thumbnail': {'verbose_name': 'Thumbnail (140px)', 'width': 140, 'height': '', 'opts': ''},
68     'small': {'verbose_name': 'Small (300px)', 'width': 300, 'height': '', 'opts': ''},
69     'medium': {'verbose_name': 'Medium (460px)', 'width': 460, 'height': '', 'opts': ''},
70     'big': {'verbose_name': 'Big (620px)', 'width': 620, 'height': '', 'opts': ''},
71     'cropped': {'verbose_name': 'Cropped (60x60px)', 'width': 60, 'height': 60, 'opts': 'crop'},
72     'croppedthumbnail': {'verbose_name': 'Cropped Thumbnail (140x140px)', 'width': 140, 'height': 140, 'opts': 'crop'},
73 })
74 # Versions available within the Admin-Interface.
75 ADMIN_VERSIONS = getattr(settings, 'FILEBROWSER_ADMIN_VERSIONS', ['thumbnail', 'small', 'medium', 'big'])
76 # Which Version should be used as Admin-thumbnail.
77 ADMIN_THUMBNAIL = getattr(settings, 'FILEBROWSER_ADMIN_THUMBNAIL', 'fb_thumb')
78
79 # EXTRA SETTINGS
80 # True to save the URL including MEDIA_URL to your model fields
81 # or False (default) to save path relative to MEDIA_URL.
82 # Note: Full URL does not necessarily means absolute URL.
83 SAVE_FULL_URL = getattr(settings, "FILEBROWSER_SAVE_FULL_URL", True)
84 # If set to True, the FileBrowser will not try to import a mis-installed PIL.
85 STRICT_PIL = getattr(settings, 'FILEBROWSER_STRICT_PIL', False)
86 # PIL's Error "Suspension not allowed here" work around:
87 # s. http://mail.python.org/pipermail/image-sig/1999-August/000816.html
88 IMAGE_MAXBLOCK = getattr(settings, 'FILEBROWSER_IMAGE_MAXBLOCK', 1024 * 1024)
89 # Exclude files matching any of the following regular expressions
90 # Default is to exclude 'thumbnail' style naming of image-thumbnails.
91 EXTENSION_LIST = []
92 for exts in EXTENSIONS.values():
93     EXTENSION_LIST += exts
94 EXCLUDE = getattr(settings, 'FILEBROWSER_EXCLUDE', (r'_(%(exts)s)_.*_q\d{1,3}\.(%(exts)s)' % {'exts': ('|'.join(EXTENSION_LIST))},))
95 # Max. Upload Size in Bytes.
96 MAX_UPLOAD_SIZE = getattr(settings, "FILEBROWSER_MAX_UPLOAD_SIZE", 10485760)
97 # Convert Filename (replace spaces and convert to lowercase)
98 CONVERT_FILENAME = getattr(settings, "FILEBROWSER_CONVERT_FILENAME", True)
99
100 DEFAULT_ORDER = getattr(settings, "FILEBROWSER_DEFAULT_ORDER", "filename_lower")
101
102 # EXTRA TRANSLATION STRINGS
103 # The following strings are not availabe within views or templates
104 _('Folder')
105 _('Image')
106 _('Video')
107 _('Document')
108 _('Sound')
109 _('Code')