summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2014-06-15 04:50:44 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2014-06-15 04:50:44 -0300
commitd4d19211375de71a1c411ae01a16d451ce5917b9 (patch)
treed3ecad213d432c43dfff818dfe3f941dde4b5b39
parent1b480d55662bee861e20a1a2ed26394a91712aec (diff)
downloadaskbot-d4d19211375de71a1c411ae01a16d451ce5917b9.tar.gz
askbot-d4d19211375de71a1c411ae01a16d451ce5917b9.tar.bz2
askbot-d4d19211375de71a1c411ae01a16d451ce5917b9.zip
added validation to custom logo destination url
-rw-r--r--askbot/conf/skin_general_settings.py22
-rw-r--r--askbot/doc/source/changelog.rst1
-rw-r--r--askbot/doc/source/contributors.rst1
-rw-r--r--askbot/templates/widgets/logo.html6
4 files changed, 26 insertions, 4 deletions
diff --git a/askbot/conf/skin_general_settings.py b/askbot/conf/skin_general_settings.py
index 2a4c76fa..beaf04be 100644
--- a/askbot/conf/skin_general_settings.py
+++ b/askbot/conf/skin_general_settings.py
@@ -6,6 +6,8 @@ from askbot.deps.livesettings import ConfigurationGroup
from askbot.deps.livesettings import values
from django.utils.translation import ugettext_lazy as _
from django.conf import settings as django_settings
+from django.core.validators import URLValidator
+from django.core.exceptions import ValidationError
from askbot.skins import utils as skin_utils
from askbot import const
from askbot.conf.super_groups import CONTENT_AND_UI
@@ -16,12 +18,28 @@ GENERAL_SKIN_SETTINGS = ConfigurationGroup(
super_group = CONTENT_AND_UI
)
+def logo_destination_callback(old_url, new_url):
+ url = new_url.strip()
+ if url == '':
+ return ''
+
+ if url.startswith('/'):
+ return url
+
+ validate = URLValidator()
+ try:
+ validate(url)
+ return url
+ except ValidationError:
+ raise ValueError(_('Please enter a valid url'))
+
settings.register(
values.StringValue(
GENERAL_SKIN_SETTINGS,
'LOGO_DESTINATION_URL',
- default = '/',
- description = _('Destination URL for the site logo'),
+ default = '',
+ description = _('Custom destination URL for the logo'),
+ update_callback=logo_destination_callback
)
)
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst
index e554e324..67928fbc 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -3,6 +3,7 @@ Changes in Askbot
Development master branch (only on github)
------------------------------------------
+* Allow custom destination url under the logo
* Option to allow asking without registration (Egil Moeller)
* Implemented Mozilla Persona authentication
* Allowed custom providers of gravatar service (michas2)
diff --git a/askbot/doc/source/contributors.rst b/askbot/doc/source/contributors.rst
index 2ebcaebb..d1e2dd3a 100644
--- a/askbot/doc/source/contributors.rst
+++ b/askbot/doc/source/contributors.rst
@@ -58,6 +58,7 @@ Programming, bug fixes and documentation
* `Francis Devereux <https://github.com/frankoid>`_
* `Andrew Chen <https://github.com/yongjhih>`_
* `Egil Moeller <https://github.com/redhog>`_
+* `Jerry Zhenlei Cai <https://github.com/jerryzhenleicai>`_
Translations
------------
diff --git a/askbot/templates/widgets/logo.html b/askbot/templates/widgets/logo.html
index afa0a95b..c0349d1f 100644
--- a/askbot/templates/widgets/logo.html
+++ b/askbot/templates/widgets/logo.html
@@ -1,5 +1,7 @@
-<a id="logo" href="{%if settings.LOGO_DESTINATION_URL%}{{ settings.LOGO_DESTINATION_URL}}{% else %} {% url questions %}{% endif %}"><img
+<a
+ id="logo"
+ href="{% if settings.LOGO_DESTINATION_URL %}{{ settings.LOGO_DESTINATION_URL }}{% else %}{% url questions %}{% endif %}"
+><img
src="{{ settings.SITE_LOGO_URL|media }}"
- title="{% trans %}back to home page{% endtrans %}"
alt="{% trans site=settings.APP_SHORT_NAME %}{{site}} logo{% endtrans %}"/>
</a>