From 6007cf89bed694a4863a9fcbf43425c41a83ea6f Mon Sep 17 00:00:00 2001 From: llxpad Date: Wed, 4 Jan 2012 19:01:50 +0100 Subject: Update askbot/locale/es/LC_MESSAGES/django.po --- askbot/locale/es/LC_MESSAGES/django.po | 76 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/askbot/locale/es/LC_MESSAGES/django.po b/askbot/locale/es/LC_MESSAGES/django.po index d5a88e1d..b88131cc 100644 --- a/askbot/locale/es/LC_MESSAGES/django.po +++ b/askbot/locale/es/LC_MESSAGES/django.po @@ -22,7 +22,7 @@ msgstr "" #: exceptions.py:13 #, fuzzy msgid "Sorry, but anonymous visitors cannot access this function" -msgstr "usuarios anónimos no pueden votar" +msgstr "Lo sentimos pero los usuarios anónimos no pueden acceder a esta función" #: feed.py:26 feed.py:100 msgid " - " @@ -40,16 +40,16 @@ msgstr "últimas preguntas" #: forms.py:74 #, fuzzy msgid "select country" -msgstr "Eliminar cuenta" +msgstr "seleccione país" #: forms.py:83 msgid "Country" -msgstr "" +msgstr "País" #: forms.py:91 #, fuzzy msgid "Country field is required" -msgstr "este campo es requerido" +msgstr "El campo País es requerido" #: forms.py:104 skins/default/templates/widgets/answer_edit_tips.html:45 #: skins/default/templates/widgets/answer_edit_tips.html:49 @@ -66,8 +66,8 @@ msgstr "por favor ingrese un título descriptivo para su pregunta" #, fuzzy, python-format msgid "title must be > %d character" msgid_plural "title must be > %d characters" -msgstr[0] "el título debe contener más de 10 carácteres" -msgstr[1] "el título debe contener más de 10 carácteres" +msgstr[0] "el título debe contener más de %d carácter" +msgstr[1] "el título debe contener más de %d carácteres" #: forms.py:131 msgid "content" @@ -88,10 +88,10 @@ msgid_plural "" "Tags are short keywords, with no spaces within. Up to %(max_tags)d tags can " "be used." msgstr[0] "" -"Las etiquetas son claves cortas, con o sin espacios. Puedes usar más de 5 " -"etiquetas." +"Las etiquetas son claves cortas, sin espacios. Puedes usar hasta %(max_tags)d " +"etiqueta." msgstr[1] "" -"Las etiquetas son claves cortas, con o sin espacios. Puedes usar más de 5 " +"Las etiquetas son claves cortas, sin espacios. Puedes usar hasta %(max_tags)d " "etiquetas." #: forms.py:201 skins/default/templates/question_retag.html:58 @@ -102,35 +102,35 @@ msgstr "etiquetas requeridas" #, fuzzy, python-format msgid "please use %(tag_count)d tag or less" msgid_plural "please use %(tag_count)d tags or less" -msgstr[0] "por favor, use 5 etiquetas o menos" -msgstr[1] "por favor, use 5 etiquetas o menos" +msgstr[0] "por favor, use %(tag_count)d etiqueta o menos" +msgstr[1] "por favor, use %(tag_count)d etiquetas o menos" #: forms.py:218 #, python-format msgid "At least one of the following tags is required : %(tags)s" -msgstr "" +msgstr "Al menos una de las siguientes etiquetas se requieren : %(tags)s" #: forms.py:227 #, fuzzy, python-format msgid "each tag must be shorter than %(max_chars)d character" msgid_plural "each tag must be shorter than %(max_chars)d characters" -msgstr[0] "las etiquetas deben contener menos de 20 carácteres" -msgstr[1] "las etiquetas deben contener menos de 20 carácteres" +msgstr[0] "las etiquetas deben contener menos de %(max_chars)d carácter" +msgstr[1] "las etiquetas deben contener menos de %(max_chars)d carácteres" #: forms.py:235 msgid "use-these-chars-in-tags" -msgstr "" +msgstr "usa-estos-caracteres-en-las-etiquetas" #: forms.py:270 msgid "community wiki (karma is not awarded & many others can edit wiki post)" -msgstr "" +msgstr "wiki comunitaria (no se premia karma y cualquiera puede editar la publicación wiki)" #: forms.py:271 msgid "" "if you choose community wiki option, the question and answer do not generate " "points and name of author will not be shown" msgstr "" -"si marcas la opción Wiki, la pregunta y las respuestas no generan puntos y " +"si marcas la opción Wiki comunitaria,la pregunta y las respuestas no generan puntos y " "el nombre del autor no se muestra" #: forms.py:287 @@ -147,7 +147,7 @@ msgstr "" #: forms.py:364 msgid "Enter number of points to add or subtract" -msgstr "" +msgstr "Ingrese el número de puntos a añadir o quitar" #: forms.py:378 const/__init__.py:250 msgid "approved" @@ -160,7 +160,7 @@ msgstr "visto" #: forms.py:380 const/__init__.py:252 #, fuzzy msgid "suspended" -msgstr "actualizado" +msgstr "pausado" #: forms.py:381 const/__init__.py:253 msgid "blocked" @@ -169,26 +169,26 @@ msgstr "bloqueado" #: forms.py:383 #, fuzzy msgid "administrator" -msgstr "administración" +msgstr "administrador" #: forms.py:384 const/__init__.py:249 #, fuzzy msgid "moderator" -msgstr "moderar-usuario/" +msgstr "moderador" #: forms.py:404 #, fuzzy msgid "Change status to" -msgstr "Cambiar etiquetas" +msgstr "Cambiar estado a" #: forms.py:431 msgid "which one?" -msgstr "" +msgstr "Cuál?" #: forms.py:452 #, fuzzy msgid "Cannot change own status" -msgstr "no se puede votar por sus propias publicaciones" +msgstr "No puede cambiar su propio estado" #: forms.py:458 msgid "Cannot turn other user to moderator" @@ -201,62 +201,64 @@ msgstr "No tiene permitido cambiar el estado de otro moderador" #: forms.py:471 #, fuzzy msgid "Cannot change status to admin" -msgstr "no se puede votar por sus propias publicaciones" +msgstr "No puede cambiar el estado a admin" #: forms.py:477 #, python-format msgid "" "If you wish to change %(username)s's status, please make a meaningful " "selection." -msgstr "" +msgstr "Si desea cambiar el estado de %(username), por favor, haga una selección " +"apropiada." #: forms.py:486 msgid "Subject line" -msgstr "Sujeto" +msgstr "Línea del tema" #: forms.py:493 msgid "Message text" -msgstr "Mensaje de Texto" +msgstr "Texto del mensaje" #: forms.py:579 #, fuzzy msgid "Your name (optional):" -msgstr "Tu nombre:" +msgstr "Su nombre (opcional):" #: forms.py:580 #, fuzzy msgid "Email:" -msgstr "no enviar emails" +msgstr "Correo electrónico:" #: forms.py:582 msgid "Your message:" -msgstr "Tu mensaje:" +msgstr "Su mensaje:" #: forms.py:587 msgid "I don't want to give my email or receive a response:" -msgstr "" +msgstr "No deseo dar mi correo electrónico o recibir una respuesta:" #: forms.py:609 msgid "Please mark \"I dont want to give my mail\" field." -msgstr "" +msgstr "Por favor, marque el campo \"No deseo dar mi correo electrónico\"." #: forms.py:648 msgid "ask anonymously" -msgstr "" +msgstr "pregunte anónimamente" #: forms.py:650 msgid "Check if you do not want to reveal your name when asking this question" -msgstr "" +msgstr "Compruebe si no desea revelar su nombre cuando realice esta pregunta" #: forms.py:810 msgid "" "You have asked this question anonymously, if you decide to reveal your " "identity, please check this box." -msgstr "" +msgstr "Ha solicitado realizar esta pregunta anónimamente, si decide revelar su " +"identidad, por favor marque esta caja." #: forms.py:814 msgid "reveal identity" -msgstr "" +msgstr "revelar identidad" #: forms.py:872 msgid "" -- cgit v1.2.3-1-g7c22 From 4ad37cc4f13474791ff51aa59953f544cc7f9da8 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 4 Jan 2012 16:54:18 -0300 Subject: moved custom header from live settings to the same place in the templates as custom_header.html import --- askbot/skins/default/templates/base.html | 5 +++++ askbot/skins/default/templates/widgets/header.html | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/askbot/skins/default/templates/base.html b/askbot/skins/default/templates/base.html index 1102007b..8287f5ba 100644 --- a/askbot/skins/default/templates/base.html +++ b/askbot/skins/default/templates/base.html @@ -17,6 +17,11 @@ {% include "widgets/system_messages.html" %} {% include "custom_header.html" ignore missing %} + {% if settings.CUSTOM_HEADER|trim != '' %} +
+ {{settings.CUSTOM_HEADER}} +
+ {% endif %} {% include "widgets/header.html" %} {# Logo, user tool navigation and meta navitation #} {% include "widgets/secondary_header.html" %} {# Scope selector, search input and ask button #}
diff --git a/askbot/skins/default/templates/widgets/header.html b/askbot/skins/default/templates/widgets/header.html index d4e7d66a..52e528bc 100644 --- a/askbot/skins/default/templates/widgets/header.html +++ b/askbot/skins/default/templates/widgets/header.html @@ -7,7 +7,6 @@
{% include "widgets/user_navigation.html" %} - {{settings.CUSTOM_HEADER}}
{% if settings.SHOW_LOGO %} {% include "widgets/logo.html" %} -- cgit v1.2.3-1-g7c22 From f797c1e8398958dca45df85fac79f115576ea250 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 7 Jan 2012 10:34:00 -0300 Subject: added option to disable changing email address --- askbot/conf/user_settings.py | 9 +++++++++ askbot/forms.py | 1 - askbot/skins/default/templates/base.html | 5 +++++ .../default/templates/user_profile/user_edit.html | 21 ++++++++++++++------- askbot/skins/default/templates/widgets/header.html | 1 - 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/askbot/conf/user_settings.py b/askbot/conf/user_settings.py index cec13083..086f7583 100644 --- a/askbot/conf/user_settings.py +++ b/askbot/conf/user_settings.py @@ -24,6 +24,15 @@ settings.register( ) ) +settings.register( + livesettings.BooleanValue( + USER_SETTINGS, + 'EDITABLE_EMAIL', + default = True, + description = _('Allow users change own email addresses') + ) +) + settings.register( livesettings.BooleanValue( USER_SETTINGS, diff --git a/askbot/forms.py b/askbot/forms.py index 00735b72..019e5f83 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -920,7 +920,6 @@ class EditAnswerForm(forms.Form): class EditUserForm(forms.Form): email = forms.EmailField( label=u'Email', - help_text=_('this email will be linked to gravatar'), required=True, max_length=255, widget=forms.TextInput(attrs={'size' : 35}) diff --git a/askbot/skins/default/templates/base.html b/askbot/skins/default/templates/base.html index 1102007b..8287f5ba 100644 --- a/askbot/skins/default/templates/base.html +++ b/askbot/skins/default/templates/base.html @@ -17,6 +17,11 @@ {% include "widgets/system_messages.html" %} {% include "custom_header.html" ignore missing %} + {% if settings.CUSTOM_HEADER|trim != '' %} +
+ {{settings.CUSTOM_HEADER}} +
+ {% endif %} {% include "widgets/header.html" %} {# Logo, user tool navigation and meta navitation #} {% include "widgets/secondary_header.html" %} {# Scope selector, search input and ask button #}
diff --git a/askbot/skins/default/templates/user_profile/user_edit.html b/askbot/skins/default/templates/user_profile/user_edit.html index daaa3663..94a1d58d 100644 --- a/askbot/skins/default/templates/user_profile/user_edit.html +++ b/askbot/skins/default/templates/user_profile/user_edit.html @@ -42,17 +42,24 @@ {{ form.username }} {{ form.username.errors }} {% else %} - {{ request.user.username }} + {{ view_user.username }} {% endif %} - {{ form.email.label_tag() }}: - {{ form.email }} {{ form.email.errors }} - - - - {{ form.email.help_text }} + + {{ form.email.label_tag() }}: + + + {% if settings.EDITABLE_EMAIL %} + {{ form.email }} + + {{ form.email.errors }} + {% else %} + {{ view_user.email }} + {% trans %}(cannot be changed){% endtrans %} + {% endif %} + {{ form.realname.label_tag() }}: diff --git a/askbot/skins/default/templates/widgets/header.html b/askbot/skins/default/templates/widgets/header.html index d4e7d66a..52e528bc 100644 --- a/askbot/skins/default/templates/widgets/header.html +++ b/askbot/skins/default/templates/widgets/header.html @@ -7,7 +7,6 @@
{% include "widgets/user_navigation.html" %} - {{settings.CUSTOM_HEADER}}
{% if settings.SHOW_LOGO %} {% include "widgets/logo.html" %} -- cgit v1.2.3-1-g7c22 From 2763ae65e578b14541aec0f915d8eb86351f2e33 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 7 Jan 2012 13:30:27 -0300 Subject: added static_page.html template and used it for custom faq page --- askbot/skins/default/templates/static_page.html | 10 +++++++++ askbot/views/meta.py | 27 ++++++++----------------- 2 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 askbot/skins/default/templates/static_page.html diff --git a/askbot/skins/default/templates/static_page.html b/askbot/skins/default/templates/static_page.html new file mode 100644 index 00000000..c537e199 --- /dev/null +++ b/askbot/skins/default/templates/static_page.html @@ -0,0 +1,10 @@ +{% extends "two_column_body.html" %} + +{% block title %}{% spaceless %}{{title}}{% endspaceless %}{% endblock %} +{% block content %} +
+

{{title}}

+ {{content}} +
+{% endblock %} + diff --git a/askbot/views/meta.py b/askbot/views/meta.py index 493ab8ec..f8cbe8ae 100644 --- a/askbot/views/meta.py +++ b/askbot/views/meta.py @@ -42,30 +42,19 @@ def server_error(request, template='500.html'): return generic_view(request, template) def faq(request): - if getattr(askbot_settings, 'FORUM_FAQ',''): - text = _(getattr(askbot_settings, 'FORUM_FAQ','')) + if askbot_settings.FORUM_FAQ.strip() != '': + return render_into_skin( + 'static_page.html', + {'title': _('FAQ'), 'content': askbot_settings.FORUM_FAQ}, + request + ) + else: data = { 'gravatar_faq_url': reverse('faq') + '#gravatar', - #'send_email_key_url': reverse('send_email_key'), - 'ask_question_url': reverse('ask'), - 'page_class': 'meta', - } - forum_faq = render_text_into_skin(text, data, request) - data_out = { - 'gravatar_faq_url': reverse('faq') + '#gravatar', - #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', - 'forum_faq' : forum_faq, } - return render_into_skin('faq.html', data_out, request) - data = { - 'gravatar_faq_url': reverse('faq') + '#gravatar', - #'send_email_key_url': reverse('send_email_key'), - 'ask_question_url': reverse('ask'), - 'page_class': 'meta', - } - return render_into_skin('faq_static.html', data, request) + return render_into_skin('faq_static.html', data, request) @csrf.csrf_protect def feedback(request): -- cgit v1.2.3-1-g7c22 From dea70d5eacf29d2a42561d8b8c50465d9b06904e Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 7 Jan 2012 14:24:57 -0300 Subject: removed custom templates privacy.html and about.html --- askbot/skins/default/templates/faq.html | 10 ---------- askbot/skins/default/templates/privacy.html | 8 -------- askbot/views/meta.py | 13 +++++++++++-- 3 files changed, 11 insertions(+), 20 deletions(-) delete mode 100644 askbot/skins/default/templates/faq.html delete mode 100644 askbot/skins/default/templates/privacy.html diff --git a/askbot/skins/default/templates/faq.html b/askbot/skins/default/templates/faq.html deleted file mode 100644 index 51873a06..00000000 --- a/askbot/skins/default/templates/faq.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "two_column_body.html" %} - -{% block title %}{% spaceless %}{% trans %}FAQ{% endtrans %}{% endspaceless %}{% endblock %} -{% block content %} -
-

FAQ

- {{forum_faq}} -
-{% endblock %} - diff --git a/askbot/skins/default/templates/privacy.html b/askbot/skins/default/templates/privacy.html deleted file mode 100644 index e9b6f58b..00000000 --- a/askbot/skins/default/templates/privacy.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "two_column_body.html" %} - -{% block title %}{% spaceless %}{% trans %}Privacy policy{% endtrans %}{% endspaceless %}{% endblock %} -{% block content %} -

{% trans %}Privacy policy{% endtrans %}

-{{settings.FORUM_PRIVACY}} -{% endblock %} - diff --git a/askbot/views/meta.py b/askbot/views/meta.py index f8cbe8ae..3ad32b9b 100644 --- a/askbot/views/meta.py +++ b/askbot/views/meta.py @@ -33,7 +33,12 @@ def config_variable(request, variable_name = None, mimetype = None): return HttpResponse(output, mimetype = mimetype) def about(request, template='about.html'): - return generic_view(request, template = template, page_class = 'meta') + title = _('About %(site)s') % {'site': askbot_settings.APP_SHORT_NAME} + data = { + 'title': title, + 'content': askbot_settings.FORUM_ABOUT + } + return render_into_skin('static_page.html', data, request) def page_not_found(request, template='404.html'): return generic_view(request, template) @@ -83,7 +88,11 @@ def feedback(request): feedback.CANCEL_MESSAGE=_('We look forward to hearing your feedback! Please, give it next time :)') def privacy(request): - return render_into_skin('privacy.html', {'page_class': 'meta'}, request) + data = { + 'title': _('Privacy policy'), + 'content': askbot_settings.FORUM_PRIVACY + } + return render_into_skin('static_page.html', data, request) def badges(request):#user status/reputation system #todo: supplement database data with the stuff from badges.py -- cgit v1.2.3-1-g7c22 From b6aa02fbedefbe7e80277c1ec82015b6d5eb93c2 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 7 Jan 2012 15:04:37 -0300 Subject: removed unused about.html template --- askbot/skins/default/templates/about.html | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 askbot/skins/default/templates/about.html diff --git a/askbot/skins/default/templates/about.html b/askbot/skins/default/templates/about.html deleted file mode 100644 index d5d1b949..00000000 --- a/askbot/skins/default/templates/about.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "two_column_body.html" %} - -{% block title %}{% spaceless %}{% trans site_name=settings.APP_SHORT_NAME %}About {{site_name}}{% endtrans %}{% endspaceless %}{% endblock %} -{% block content %} -

{% trans site_name=settings.APP_SHORT_NAME %}About {{site_name}}{% endtrans %}

-
- {{settings.FORUM_ABOUT}} -
-{% endblock %} - -- cgit v1.2.3-1-g7c22 From fc02faa2e23bde7f64429bf8d644b379af5aff20 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 7 Jan 2012 23:40:00 -0300 Subject: replaced ASKBOT_FILE_UPLOAD_DIR setting with MEDIA_ROOT --- askbot/conf/license.py | 1 - askbot/conf/login_providers.py | 1 - askbot/conf/skin_general_settings.py | 3 --- askbot/conf/user_settings.py | 1 - askbot/deps/livesettings/values.py | 6 +++++- askbot/doc/source/changelog.rst | 1 + askbot/setup_templates/settings.py | 7 +++---- askbot/setup_templates/settings.py.mustache | 6 +++--- askbot/skins/utils.py | 2 +- askbot/startup_procedures.py | 26 +++++++++++++++++++++----- askbot/tests/page_load_tests.py | 4 ++-- askbot/urls.py | 2 +- askbot/views/writers.py | 1 - 13 files changed, 37 insertions(+), 24 deletions(-) diff --git a/askbot/conf/license.py b/askbot/conf/license.py index 20a2743f..dfb18530 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_directory = django_settings.ASKBOT_FILE_UPLOAD_DIR, 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 b6073eea..49f568bd 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_directory=django_settings.ASKBOT_FILE_UPLOAD_DIR, upload_url='/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default='/images/logo.gif', description=_('Upload your icon'), diff --git a/askbot/conf/skin_general_settings.py b/askbot/conf/skin_general_settings.py index 387ac1f6..f43f45d8 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_directory = django_settings.ASKBOT_FILE_UPLOAD_DIR, 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( 'about favicon ' 'at this page.' ) % {'favicon_info_url': const.DEPENDENCY_URLS['favicon']}, - upload_directory = django_settings.ASKBOT_FILE_UPLOAD_DIR, allowed_file_extensions = ('ico',),#only allow .ico files upload_url = '/' + django_settings.ASKBOT_UPLOADED_FILES_URL, default = '/images/favicon.gif', @@ -75,7 +73,6 @@ settings.register( 'An 88x38 pixel image that is used on the login screen ' 'for the password login button.' ), - upload_directory = django_settings.ASKBOT_FILE_UPLOAD_DIR, 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 086f7583..4c5d17db 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_directory = django_settings.ASKBOT_FILE_UPLOAD_DIR, 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 9587a16d..db366465 100644 --- a/askbot/deps/livesettings/values.py +++ b/askbot/deps/livesettings/values.py @@ -4,6 +4,7 @@ http://code.google.com/p/django-values/ """ from decimal import Decimal from django import forms +from django.conf import settings as django_settings from django.core.exceptions import ImproperlyConfigured from django.utils import simplejson from django.utils.datastructures import SortedDict @@ -600,7 +601,10 @@ class ImageValue(StringValue): 'allowed_file_extensions', ('jpg', 'gif', 'png') ) - self.upload_directory = kwargs.pop('upload_directory') + self.upload_directory = kwargs.pop( + 'upload_directory', + django_settings.MEDIA_ROOT + ) self.upload_url = kwargs.pop('upload_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 c228e158..cb67a62e 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -15,6 +15,7 @@ Development version (not released yet) text to live settings and allowed body-less questions (Radim Řehůřek, Evgeny) * 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) 0.7.36 (Dec 20, 2011) --------------------- diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 715e6ce8..2baf3fd6 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -68,7 +68,7 @@ LANGUAGE_CODE = 'en' # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -ASKBOT_FILE_UPLOAD_DIR = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') +MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') PROJECT_ROOT = os.path.dirname(__file__) @@ -167,9 +167,8 @@ INSTALLED_APPS = ( 'djkombu', 'followit', #'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$ - #requires setting of MEDIA_ROOT and MEDIA_URL - #values of which can be the same as ASKBOT_FILE_UPLOAD_DIR and ASKBOT_UPLOADED_FILES_URL, - #respectively + #requires setting MEDIA_URL + #values of which can be the same as ASKBOT_UPLOADED_FILES_URL, ) diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 69da823a..95b918f2 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -68,7 +68,7 @@ LANGUAGE_CODE = 'en' # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -ASKBOT_FILE_UPLOAD_DIR = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') +MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') PROJECT_ROOT = os.path.dirname(__file__) @@ -166,8 +166,8 @@ INSTALLED_APPS = ( 'djkombu', 'followit', #'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$ - #requires setting of MEDIA_ROOT and MEDIA_URL - #values of which can be the same as ASKBOT_FILE_UPLOAD_DIR and ASKBOT_UPLOADED_FILES_URL, + #requires setting of MEDIA_URL + #values of which can be the same as ASKBOT_UPLOADED_FILES_URL, #respectively ) diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index da3a8a06..34bf658f 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -109,7 +109,7 @@ def get_media_url(url, ignore_missing = False): 1 ) file_path = os.path.join( - django_settings.ASKBOT_FILE_UPLOAD_DIR, + django_settings.MEDIA_ROOT, file_path ) if os.path.isfile(file_path): diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index 9c962f2a..b37ac52d 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -228,14 +228,25 @@ class SettingsTester(object): self.requirements = requirements - def test_setting(self, name, value = None, message = None): + def test_setting(self, name, + value = None, message = None, + test_for_absence = False, + replace_hint = None + ): """if setting does is not present or if the value != required_value, adds an error message """ - if not hasattr(self.settings, name): - self.messages.append(message) - elif value and getattr(self.settings, name) != value: - self.messages.append(message) + if test_for_absence: + if hasattr(self.settings, name): + if replace_hint: + value = getattr(self.settings, name) + message += replace_hint % value + self.messages.append(message) + else: + if not hasattr(self.settings, name): + self.messages.append(message) + elif value and getattr(self.settings, name) != value: + self.messages.append(message) def run(self): for setting_name in self.requirements: @@ -278,6 +289,11 @@ def run_startup_tests(): 'where you want to send users after they log in\n' 'a reasonable default is\n' 'LOGIN_REDIRECT_URL = ASKBOT_URL' + }, + 'ASKBOT_FILE_UPLOAD_DIR': { + 'message': 'Please replace setting ASKBOT_FILE_UPLOAD_DIR ', + 'test_for_absence': True, + 'replace_hint': "with MEDIA_ROOT = '%s'" } }) settings_tester.run() diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py index 3ecc126f..d92d0e0c 100644 --- a/askbot/tests/page_load_tests.py +++ b/askbot/tests/page_load_tests.py @@ -122,11 +122,11 @@ class PageLoadTestCase(AskbotTestCase): self.try_url( 'about', status_code=status_code, - template='about.html') + template='static_page.html') self.try_url( 'privacy', status_code=status_code, - template='privacy.html') + template='static_page.html') self.try_url('logout', template='authopenid/logout.html') #todo: test different tabs self.try_url( diff --git a/askbot/urls.py b/askbot/urls.py index 4bfab225..047ff7ad 100644 --- a/askbot/urls.py +++ b/askbot/urls.py @@ -44,7 +44,7 @@ urlpatterns = patterns('', url( # TODO: replace with django.conf.urls.static ? r'^%s(?P.*)$' % settings.ASKBOT_UPLOADED_FILES_URL, 'django.views.static.serve', - {'document_root': settings.ASKBOT_FILE_UPLOAD_DIR.replace('\\','/')}, + {'document_root': settings.MEDIA_ROOT.replace('\\','/')}, name='uploaded_file', ), #no translation for this url!! diff --git a/askbot/views/writers.py b/askbot/views/writers.py index f8da2181..4b4c011e 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -79,7 +79,6 @@ def upload(request):#ajax upload file to a question or answer ) + file_extension file_storage = FileSystemStorage( - location = settings.ASKBOT_FILE_UPLOAD_DIR, base_url = reverse('uploaded_file', kwargs = {'path':''}), ) # use default storage to store file -- cgit v1.2.3-1-g7c22 From 1acf3a7b2e02cb414aad5ba7940e9132ccfded78 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 00:55:46 -0300 Subject: replaced ASKBOT_UPLOADED_FILES_URL with django setting MEDIA_URL --- askbot/conf/license.py | 1 - askbot/conf/login_providers.py | 1 - askbot/conf/skin_general_settings.py | 3 --- askbot/conf/user_settings.py | 1 - askbot/deps/livesettings/values.py | 5 ++++- askbot/doc/source/changelog.rst | 1 + askbot/doc/source/contributors.rst | 2 +- askbot/setup_templates/settings.py | 4 +--- askbot/setup_templates/settings.py.mustache | 5 +---- askbot/setup_templates/urls.py | 5 +++++ askbot/skins/utils.py | 4 ++-- askbot/startup_procedures.py | 17 ++++++++++++++++- askbot/tests/skin_tests.py | 7 +------ askbot/urls.py | 6 ------ 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 this page.' ) % {'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.*)$' % 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.*)$' % 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 -- cgit v1.2.3-1-g7c22 From 6a60ef133bec17d184fe7f1a678511a67ddfee99 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 11:24:29 -0300 Subject: allowed changing of file storage backend from settings.py file --- askbot/deps/livesettings/values.py | 17 ++++++++++++----- askbot/doc/source/changelog.rst | 1 + askbot/views/writers.py | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/askbot/deps/livesettings/values.py b/askbot/deps/livesettings/values.py index c6708bdb..e5516d8b 100644 --- a/askbot/deps/livesettings/values.py +++ b/askbot/deps/livesettings/values.py @@ -639,13 +639,20 @@ class ImageValue(StringValue): """uploaded_file is an instance of django UploadedFile object """ - #1) come up with a file name + #0) initialize file storage + file_storage_class = storage.get_storage_class() - file_storage = storage.FileSystemStorage( - location = self.upload_directory, - base_url = self.upload_url - ) + storage_settings = {} + if django_settings.DEFAULT_FILE_STORAGE == \ + 'django.core.files.storage.FileSystemStorage': + storage_settings = { + 'location': self.upload_directory, + 'base_url': self.upload_url + } + file_storage = file_storage_class(**storage_settings) + + #1) come up with a file name #todo: need better function here to calc name file_name = file_storage.get_available_name(uploaded_file.name) file_storage.save(file_name, uploaded_file) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index edffc0e5..45a6f49b 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -17,6 +17,7 @@ Development version (not released yet) * 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) +* allowed changing file storage backend for file uploads by configuration (Evgeny) 0.7.36 (Dec 20, 2011) --------------------- diff --git a/askbot/views/writers.py b/askbot/views/writers.py index d76929f7..c4d60de9 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -12,7 +12,7 @@ import random import sys import tempfile import time -from django.core.files.storage import FileSystemStorage +from django.core.files.storage import get_storage_class from django.shortcuts import get_object_or_404 from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404 @@ -78,7 +78,7 @@ def upload(request):#ajax upload file to a question or answer str(random.randint(0,100000)) ) + file_extension - file_storage = FileSystemStorage() + file_storage = get_storage_class()() # use default storage to store file file_storage.save(new_file_name, f) # check file size -- cgit v1.2.3-1-g7c22 From ab10f5dec0120613245e2442f9368753c1b8ecde Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 19:22:10 -0300 Subject: small bug fixes and allowed media url to start with http --- askbot/skins/default/templates/meta/bottom_scripts.html | 2 +- askbot/startup_procedures.py | 6 ++++-- askbot/views/meta.py | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/askbot/skins/default/templates/meta/bottom_scripts.html b/askbot/skins/default/templates/meta/bottom_scripts.html index ad7bffa1..9a78d8a0 100644 --- a/askbot/skins/default/templates/meta/bottom_scripts.html +++ b/askbot/skins/default/templates/meta/bottom_scripts.html @@ -76,7 +76,7 @@ {% if settings.USE_CUSTOM_JS %} {% endif %} diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index 72e93d9a..05426898 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -214,10 +214,12 @@ def test_celery(): def test_media_url(): """makes sure that setting `MEDIA_URL` has leading slash""" - if not django_settings.MEDIA_URL.startswith('/'): + media_url = django_settings.MEDIA_URL + #todo: add proper url validation to MEDIA_URL setting + if not (media_url.startswith('/') or media_url.startswith('http')): raise ImproperlyConfigured(PREAMBLE + \ "\nMEDIA_URL parameter must be a unique url on the site\n" - "and must start with a slash - e.g. /media/" + "and must start with a slash - e.g. /media/ or http(s)://" ) class SettingsTester(object): diff --git a/askbot/views/meta.py b/askbot/views/meta.py index 3ad32b9b..6415077a 100644 --- a/askbot/views/meta.py +++ b/askbot/views/meta.py @@ -29,6 +29,7 @@ def config_variable(request, variable_name = None, mimetype = None): """Print value from the configuration settings as response content. All parameters are required. """ + #todo add http header-based caching here!!! output = getattr(askbot_settings, variable_name, '') return HttpResponse(output, mimetype = mimetype) -- cgit v1.2.3-1-g7c22 From 90a2ba19a40ae9ee1400290848bb54ceb19ceba3 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 22:37:48 -0300 Subject: now images and logos can be uploaded to amazon s3 --- askbot/doc/source/changelog.rst | 1 + askbot/skins/common/media/js/editor.js | 7 +++---- askbot/skins/utils.py | 5 +++++ askbot/views/writers.py | 11 ++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 45a6f49b..8f9cf9f2 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -18,6 +18,7 @@ Development version (not released yet) * replaced setting `ASKBOT_FILE_UPLOAD_DIR` with django's `MEDIA_ROOT` (Evgeny) * replaced setting `ASKBOT_UPLOADED_FILES_URL` with django's `MEDIA_URL` (Evgeny) * allowed changing file storage backend for file uploads by configuration (Evgeny) +* file uploads to amazon S3 now work with proper configuration (Evgeny) 0.7.36 (Dec 20, 2011) --------------------- diff --git a/askbot/skins/common/media/js/editor.js b/askbot/skins/common/media/js/editor.js index f5b1e2af..e580f9f6 100644 --- a/askbot/skins/common/media/js/editor.js +++ b/askbot/skins/common/media/js/editor.js @@ -42,11 +42,11 @@ function ajaxFileUpload(imageUrl, startUploadHandler) url: askbot['urls']['upload'], secureuri:false, fileElementId:'file-upload', - dataType: 'xml', + dataType: 'json', success: function (data, status) { - var fileURL = $(data).find('file_url').text(); - var error = $(data).find('error').text(); + var fileURL = data['file_url']; + var error = data['error']; if(error != ''){ alert(error); if (startUploadHandler){ @@ -57,7 +57,6 @@ function ajaxFileUpload(imageUrl, startUploadHandler) }else{ imageUrl.attr('value', fileURL); } - }, error: function (data, status, e) { diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index bf041001..50c0d4fb 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -98,6 +98,11 @@ def get_media_url(url, ignore_missing = False): #before = datetime.datetime.now() url = urllib.unquote(unicode(url)) while url[0] == '/': url = url[1:] + + #a hack allowing urls media stored on external locations to + #just pass through unchanged + if url.startswith('http://') or url.startswith('https://'): + return url #todo: handles case of multiple skin directories #if file is in upfiles directory, then give that diff --git a/askbot/views/writers.py b/askbot/views/writers.py index c4d60de9..916c0e17 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -103,11 +103,12 @@ def upload(request):#ajax upload file to a question or answer result = '' file_url = '' - #%s - xml_template = "%s" - xml = xml_template % (result, error, file_url) - - return HttpResponse(xml, mimetype="application/xml") + data = simplejson.dumps({ + 'result': result, + 'error': error, + 'file_url': file_url + }) + return HttpResponse(data, mimetype = 'application/json') def __import_se_data(dump_file): """non-view function that imports the SE data -- cgit v1.2.3-1-g7c22 From 78f0010086729c335ed028fbbb7c53dd5473ea39 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 22:58:01 -0300 Subject: fixed runaway link patterns bug --- askbot/utils/markup.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/askbot/utils/markup.py b/askbot/utils/markup.py index 3ebea3e4..ac96ec74 100644 --- a/askbot/utils/markup.py +++ b/askbot/utils/markup.py @@ -11,15 +11,11 @@ from markdown2 import Markdown #url taken from http://regexlib.com/REDetails.aspx?regexp_id=501 by Brian Bothwell URL_RE = re.compile("((? Date: Sun, 8 Jan 2012 22:59:11 -0300 Subject: fixed runaway link patterns bug --- askbot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askbot/__init__.py b/askbot/__init__.py index d4727712..7b12329c 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -9,7 +9,7 @@ import smtplib import sys import logging -VERSION = (0, 7, 36) +VERSION = (0, 7, 37) #keys are module names used by python imports, #values - the package qualifier to use for pip -- cgit v1.2.3-1-g7c22 From b7509cdeeff8b3431915bc16d92a8ae2de9a824c Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 8 Jan 2012 23:03:25 -0300 Subject: updated changelog for the new release --- askbot/doc/source/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 8f9cf9f2..ce18fe11 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -1,8 +1,8 @@ Changes in Askbot ================= -Development version (not released yet) --------------------------------------- +0.7.37 (Jan 8, 2012) +-------------------- * added basic slugification treatment to question titles with ``ALLOW_UNICODE_SLUGS = True`` (Evgeny) * added verification of the project directory name to -- cgit v1.2.3-1-g7c22