diff options
-rw-r--r-- | askbot/conf/license.py | 1 | ||||
-rw-r--r-- | askbot/conf/login_providers.py | 1 | ||||
-rw-r--r-- | askbot/conf/skin_general_settings.py | 3 | ||||
-rw-r--r-- | askbot/conf/user_settings.py | 1 | ||||
-rw-r--r-- | askbot/deps/livesettings/values.py | 5 | ||||
-rw-r--r-- | askbot/doc/source/changelog.rst | 1 | ||||
-rw-r--r-- | askbot/doc/source/contributors.rst | 2 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 4 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py.mustache | 5 | ||||
-rw-r--r-- | askbot/setup_templates/urls.py | 5 | ||||
-rw-r--r-- | askbot/skins/utils.py | 4 | ||||
-rw-r--r-- | askbot/startup_procedures.py | 17 | ||||
-rw-r--r-- | askbot/tests/skin_tests.py | 7 | ||||
-rw-r--r-- | askbot/urls.py | 6 | ||||
-rw-r--r-- | askbot/views/writers.py | 4 |
15 files changed, 33 insertions, 33 deletions
diff --git a/askbot/conf/license.py b/askbot/conf/license.py index dfb18530..faf50697 100644 --- a/askbot/conf/license.py +++ b/askbot/conf/license.py @@ -76,7 +76,6 @@ settings.register( LICENSE_SETTINGS, 'LICENSE_LOGO_URL', description = _('License logo image'), - upload_url = '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/cc-by-sa.png', url_resolver = skin_utils.get_media_url ) diff --git a/askbot/conf/login_providers.py b/askbot/conf/login_providers.py index 49f568bd..3fab7d6a 100644 --- a/askbot/conf/login_providers.py +++ b/askbot/conf/login_providers.py @@ -56,7 +56,6 @@ settings.register( livesettings.ImageValue( LOGIN_PROVIDERS, 'WORDPRESS_SITE_ICON', - upload_url='/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default='/images/logo.gif', description=_('Upload your icon'), url_resolver=skin_utils.get_media_url diff --git a/askbot/conf/skin_general_settings.py b/askbot/conf/skin_general_settings.py index f43f45d8..ccecdaba 100644 --- a/askbot/conf/skin_general_settings.py +++ b/askbot/conf/skin_general_settings.py @@ -25,7 +25,6 @@ settings.register( 'To change the logo, select new file, ' 'then submit this whole form.' ), - upload_url = django_settings.ASKBOT_URL + '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/logo.gif', url_resolver = skin_utils.get_media_url ) @@ -58,7 +57,6 @@ settings.register( 'at <a href="%(favicon_info_url)s">this page</a>.' ) % {'favicon_info_url': const.DEPENDENCY_URLS['favicon']}, allowed_file_extensions = ('ico',),#only allow .ico files - upload_url = '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/favicon.gif', url_resolver = skin_utils.get_media_url ) @@ -73,7 +71,6 @@ settings.register( 'An 88x38 pixel image that is used on the login screen ' 'for the password login button.' ), - upload_url = '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/pw-login.gif', url_resolver = skin_utils.get_media_url ) diff --git a/askbot/conf/user_settings.py b/askbot/conf/user_settings.py index 4c5d17db..321d38f9 100644 --- a/askbot/conf/user_settings.py +++ b/askbot/conf/user_settings.py @@ -70,7 +70,6 @@ settings.register( 'To change the avatar image, select new file, ' 'then submit this whole form.' ), - upload_url = '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/nophoto.png', url_resolver = skin_utils.get_media_url ) diff --git a/askbot/deps/livesettings/values.py b/askbot/deps/livesettings/values.py index db366465..c6708bdb 100644 --- a/askbot/deps/livesettings/values.py +++ b/askbot/deps/livesettings/values.py @@ -605,7 +605,10 @@ class ImageValue(StringValue): 'upload_directory', django_settings.MEDIA_ROOT ) - self.upload_url = kwargs.pop('upload_url') + self.upload_url = kwargs.pop( + 'upload_url', + django_settings.MEDIA_URL + ) self.url_resolver = kwargs.pop('url_resolver', None) super(ImageValue, self).__init__(*args, **kwargs) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index cb67a62e..edffc0e5 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -16,6 +16,7 @@ Development version (not released yet) * allowed disabling use of gravatar site-wide (Rosandra Cuello Suñol) * when internal login app is disabled - links to login/logout/add-remove-login-methods are gone (Evgeny) * replaced setting `ASKBOT_FILE_UPLOAD_DIR` with django's `MEDIA_ROOT` (Evgeny) +* replaced setting `ASKBOT_UPLOADED_FILES_URL` with django's `MEDIA_URL` (Evgeny) 0.7.36 (Dec 20, 2011) --------------------- diff --git a/askbot/doc/source/contributors.rst b/askbot/doc/source/contributors.rst index 6285d9a6..30e31175 100644 --- a/askbot/doc/source/contributors.rst +++ b/askbot/doc/source/contributors.rst @@ -39,7 +39,7 @@ Programming and documentation Translations ------------ * Mike Chen, Sailing Cai, suyu8776 - Chinese -* Bruno Sarlo, Adolfo Fitoria - Spanish +* Bruno Sarlo, Adolfo Fitoria, Francisco Espinoza - Spanish * Evgeny Kalinin - Russian * Evgeny Fadeev - English * Oktay Yildiz, Onur Mat, Cemre - Turkish diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 2baf3fd6..27ee77dc 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -69,6 +69,7 @@ LANGUAGE_CODE = 'en' # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') +MEDIA_URL = '/upfiles/' PROJECT_ROOT = os.path.dirname(__file__) @@ -167,8 +168,6 @@ INSTALLED_APPS = ( 'djkombu', 'followit', #'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$ - #requires setting MEDIA_URL - #values of which can be the same as ASKBOT_UPLOADED_FILES_URL, ) @@ -208,7 +207,6 @@ LOGIN_URL = '/%s%s%s' % (ASKBOT_URL,_('account/'),_('signin/')) LOGIN_REDIRECT_URL = ASKBOT_URL #adjust if needed #note - it is important that upload dir url is NOT translated!!! #also, this url must not have the leading slash -ASKBOT_UPLOADED_FILES_URL = 'upfiles/' ALLOW_UNICODE_SLUGS = False ASKBOT_USE_STACKEXCHANGE_URLS = False #mimic url scheme of stackexchange diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 95b918f2..4b01b4df 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -69,6 +69,7 @@ LANGUAGE_CODE = 'en' # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') +MEDIA_URL = '/upfiles/' PROJECT_ROOT = os.path.dirname(__file__) @@ -166,9 +167,6 @@ INSTALLED_APPS = ( 'djkombu', 'followit', #'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$ - #requires setting of MEDIA_URL - #values of which can be the same as ASKBOT_UPLOADED_FILES_URL, - #respectively ) @@ -208,7 +206,6 @@ LOGIN_URL = '/%s%s%s' % (ASKBOT_URL,_('account/'),_('signin/')) LOGIN_REDIRECT_URL = ASKBOT_URL #adjust, if needed #note - it is important that upload dir url is NOT translated!!! #also, this url must not have the leading slash -ASKBOT_UPLOADED_FILES_URL = 'upfiles/' ALLOW_UNICODE_SLUGS = False ASKBOT_USE_STACKEXCHANGE_URLS = False #mimic url scheme of stackexchange diff --git a/askbot/setup_templates/urls.py b/askbot/setup_templates/urls.py index 2ec69cf0..8c92f6d1 100644 --- a/askbot/setup_templates/urls.py +++ b/askbot/setup_templates/urls.py @@ -14,6 +14,11 @@ urlpatterns = patterns('', (r'^settings/', include('askbot.deps.livesettings.urls')), (r'^followit/', include('followit.urls')), (r'^robots.txt$', include('robots.urls')), + url( # TODO: replace with django.conf.urls.static ? + r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], + 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT.replace('\\','/')}, + ), ) if 'rosetta' in settings.INSTALLED_APPS: diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index 34bf658f..bf041001 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -102,9 +102,9 @@ def get_media_url(url, ignore_missing = False): #if file is in upfiles directory, then give that url_copy = url - if url_copy.startswith(django_settings.ASKBOT_UPLOADED_FILES_URL): + if url_copy.startswith(django_settings.MEDIA_URL[1:]): file_path = url_copy.replace( - django_settings.ASKBOT_UPLOADED_FILES_URL, + django_settings.MEDIA_URL[1:], '', 1 ) diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index b37ac52d..72e93d9a 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -211,6 +211,15 @@ def test_celery(): "in your settings.py file" ) +def test_media_url(): + """makes sure that setting `MEDIA_URL` + has leading slash""" + if not django_settings.MEDIA_URL.startswith('/'): + raise ImproperlyConfigured(PREAMBLE + \ + "\nMEDIA_URL parameter must be a unique url on the site\n" + "and must start with a slash - e.g. /media/" + ) + class SettingsTester(object): """class to test contents of the settings.py file""" @@ -291,12 +300,18 @@ def run_startup_tests(): 'LOGIN_REDIRECT_URL = ASKBOT_URL' }, 'ASKBOT_FILE_UPLOAD_DIR': { - 'message': 'Please replace setting ASKBOT_FILE_UPLOAD_DIR ', 'test_for_absence': True, + 'message': 'Please replace setting ASKBOT_FILE_UPLOAD_DIR ', 'replace_hint': "with MEDIA_ROOT = '%s'" + }, + 'ASKBOT_UPLOADED_FILES_URL': { + 'test_for_absence': True, + 'message': 'Please replace setting ASKBOT_UPLOADED_FILES_URL ', + 'replace_hint': "with MEDIA_URL = '/%s'" } }) settings_tester.run() + test_media_url() @transaction.commit_manually def run(): diff --git a/askbot/tests/skin_tests.py b/askbot/tests/skin_tests.py index f8e940ee..ecbea77d 100644 --- a/askbot/tests/skin_tests.py +++ b/askbot/tests/skin_tests.py @@ -65,11 +65,6 @@ class SkinTests(TestCase): new_logo = UploadedFile(file = logo_file) askbot_settings.update('SITE_LOGO_URL', new_logo) logo_url = askbot_settings.SITE_LOGO_URL - self.assertTrue( - logo_url.startswith( - django_settings.ASKBOT_URL + \ - '/' + django_settings.ASKBOT_UPLOADED_FILES_URL - ) - ) + self.assertTrue(logo_url.startswith(django_settings.MEDIA_URL)) response = self.client.get(logo_url) self.assertTrue(response.status_code == 200) diff --git a/askbot/urls.py b/askbot/urls.py index 047ff7ad..cf7d3fe6 100644 --- a/askbot/urls.py +++ b/askbot/urls.py @@ -41,12 +41,6 @@ urlpatterns = patterns('', views.meta.media, name='askbot_media', ), - url( # TODO: replace with django.conf.urls.static ? - r'^%s(?P<path>.*)$' % settings.ASKBOT_UPLOADED_FILES_URL, - 'django.views.static.serve', - {'document_root': settings.MEDIA_ROOT.replace('\\','/')}, - name='uploaded_file', - ), #no translation for this url!! url(r'import-data/$', views.writers.import_data, name='import_data'), url(r'^%s$' % _('about/'), views.meta.about, name='about'), diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 4b4c011e..d76929f7 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -78,9 +78,7 @@ def upload(request):#ajax upload file to a question or answer str(random.randint(0,100000)) ) + file_extension - file_storage = FileSystemStorage( - base_url = reverse('uploaded_file', kwargs = {'path':''}), - ) + file_storage = FileSystemStorage() # use default storage to store file file_storage.save(new_file_name, f) # check file size |