From 8a8cde4fb9957ad829682870ec9dc87f0fe50ac7 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 16 Mar 2012 10:52:33 -0400 Subject: fixed editing answer by selecting the revision --- askbot/views/writers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 4b1ae744..3cb9c45d 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -423,7 +423,7 @@ def edit_answer(request, id): # Replace with those from the selected revision rev = revision_form.cleaned_data['revision'] selected_revision = models.PostRevision.objects.answer_revisions().get( - answer = answer, + post = answer, revision = rev ) form = forms.EditAnswerForm(answer, selected_revision) -- cgit v1.2.3-1-g7c22 From d42a274ec16ad2f3e1777450dff3e0ad550bd4d2 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 17 Mar 2012 19:12:39 -0400 Subject: removed CSRF_COOKIE_DOMAIN setting from the settings.py template --- askbot/setup_templates/settings.py | 3 ++- askbot/setup_templates/settings.py.mustache | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 6d263816..b1d7dd06 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -222,6 +222,7 @@ import djcelery djcelery.setup_loader() CSRF_COOKIE_NAME = 'askbot_csrf' -CSRF_COOKIE_DOMAIN = ''#enter domain name here - e.g. example.com +#enter domain name here - e.g. example.com +#CSRF_COOKIE_DOMAIN = '' STATICFILES_DIRS = ( os.path.join(ASKBOT_ROOT, 'skins'),) diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 71ccf0f2..855e6294 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -222,7 +222,8 @@ djcelery.setup_loader() DOMAIN_NAME = '{{domain_name}}' CSRF_COOKIE_NAME = '{{domain_name}}_csrf' -CSRF_COOKIE_DOMAIN = DOMAIN_NAME #note that this can be edited +#https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/ +#CSRF_COOKIE_DOMAIN = DOMAIN_NAME STATIC_ROOT = os.path.join(PROJECT_ROOT, "static") STATICFILES_DIRS = (os.path.join(ASKBOT_ROOT, 'skins'),) -- cgit v1.2.3-1-g7c22 From e19ec430aa70805fe4adf90d91a300c66a0bbd0d Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 17 Mar 2012 19:31:38 -0400 Subject: added .box class div around the custom sidebars --- askbot/skins/default/templates/main_page/sidebar.html | 14 +++++++++----- askbot/skins/default/templates/question/sidebar.html | 8 ++++++-- askbot/skins/default/templates/user_profile/user.html | 11 ++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/askbot/skins/default/templates/main_page/sidebar.html b/askbot/skins/default/templates/main_page/sidebar.html index c89d62f4..9fb8fab9 100644 --- a/askbot/skins/default/templates/main_page/sidebar.html +++ b/askbot/skins/default/templates/main_page/sidebar.html @@ -1,17 +1,21 @@ {% import "macros.html" as macros %} -{{ settings.SIDEBAR_MAIN_HEADER }} +
+ {{ settings.SIDEBAR_MAIN_HEADER }} +
{% if contributors and settings.SIDEBAR_MAIN_SHOW_AVATARS %} - {% include "widgets/contributors.html" %} + {% include "widgets/contributors.html" %} {% endif %} {% if request.user.is_authenticated() and settings.SIDEBAR_MAIN_SHOW_TAG_SELECTOR %} - {% include "widgets/tag_selector.html" %} + {% include "widgets/tag_selector.html" %} {% endif %} {% if tags and settings.SIDEBAR_MAIN_SHOW_TAGS %} - {% include "widgets/related_tags.html" %} + {% include "widgets/related_tags.html" %} {% endif %} -{{ settings.SIDEBAR_MAIN_FOOTER }} +
+ {{ settings.SIDEBAR_MAIN_FOOTER }} +
diff --git a/askbot/skins/default/templates/question/sidebar.html b/askbot/skins/default/templates/question/sidebar.html index 30a6990c..86a543c7 100644 --- a/askbot/skins/default/templates/question/sidebar.html +++ b/askbot/skins/default/templates/question/sidebar.html @@ -1,5 +1,7 @@ {% import "macros.html" as macros %} -{{ settings.SIDEBAR_QUESTION_HEADER }} +
+ {{ settings.SIDEBAR_QUESTION_HEADER }} +

{% trans %}Question tools{% endtrans %}

{% if favorited %} @@ -69,4 +71,6 @@ {#% endcache %#} {% endif %} -{{ settings.SIDEBAR_QUESTION_FOOTER }} +
+ {{ settings.SIDEBAR_QUESTION_FOOTER }} +
diff --git a/askbot/skins/default/templates/user_profile/user.html b/askbot/skins/default/templates/user_profile/user.html index 1693303e..789c3c86 100644 --- a/askbot/skins/default/templates/user_profile/user.html +++ b/askbot/skins/default/templates/user_profile/user.html @@ -31,10 +31,11 @@ {% endblock %} {% endblock %} {% block sidebar %} - -{{ settings.SIDEBAR_PROFILE_HEADER }} - -{{ settings.SIDEBAR_PROFILE_FOOTER }} - +
+ {{ settings.SIDEBAR_PROFILE_HEADER }} +
+
+ {{ settings.SIDEBAR_PROFILE_FOOTER }} +
{% endblock %} -- cgit v1.2.3-1-g7c22 From b275ccaae847f1c97d1fbffa38f88a2b011730ef Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 18 Mar 2012 21:18:34 -0400 Subject: tags can be made optional via live settings --- askbot/conf/forum_data_rules.py | 9 ++++++ askbot/doc/source/changelog.rst | 1 + askbot/forms.py | 12 ++++---- askbot/models/question.py | 15 ++++++++-- askbot/skins/common/media/js/post.js | 8 ++++-- .../skins/common/templates/widgets/edit_post.html | 32 ++++++++++++---------- .../skins/default/templates/meta/editor_data.html | 2 ++ askbot/skins/utils.py | 5 +++- askbot/views/writers.py | 2 +- 9 files changed, 60 insertions(+), 26 deletions(-) diff --git a/askbot/conf/forum_data_rules.py b/askbot/conf/forum_data_rules.py index d6d2efd3..7b35fb44 100644 --- a/askbot/conf/forum_data_rules.py +++ b/askbot/conf/forum_data_rules.py @@ -119,6 +119,15 @@ settings.register( ) ) +settings.register( + livesettings.BooleanValue( + FORUM_DATA_RULES, + 'TAGS_ARE_REQUIRED', + description = _('Are tags required?'), + default = False, + ) +) + settings.register( livesettings.StringValue( FORUM_DATA_RULES, diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 65020d71..a1a2eaf7 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -24,6 +24,7 @@ Development version (not released yet) * Check order of middleware classes (Daniel Mican) * Added "reply by email" function (`Vasil Vangelovski `_) * Enabled "ask by email" via Lamson (Evgeny) +* Tags can be optional (Evgeny) 0.7.39 (Jan 11, 2012) --------------------- diff --git a/askbot/forms.py b/askbot/forms.py index 500bedd9..b444b55e 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -179,10 +179,10 @@ class AnswerEditorField(EditorField): class TagNamesField(forms.CharField): def __init__(self, *args, **kwargs): super(TagNamesField, self).__init__(*args, **kwargs) - self.required = True + self.required = askbot_settings.TAGS_ARE_REQUIRED self.widget = forms.TextInput(attrs={'size' : 50, 'autocomplete' : 'off'}) self.max_length = 255 - self.label = _('tags') + self.label = _('tags') #self.help_text = _('please use space to separate tags (this enables autocomplete feature)') self.help_text = ungettext_lazy( 'Tags are short keywords, with no spaces within. ' @@ -195,7 +195,7 @@ class TagNamesField(forms.CharField): def need_mandatory_tags(self): """true, if list of mandatory tags is not empty""" - return len(models.tag.get_mandatory_tags()) > 0 + return askbot_settings.TAGS_ARE_REQUIRED and len(models.tag.get_mandatory_tags()) > 0 def tag_string_matches(self, tag_string, mandatory_tag): """true if tag string matches the mandatory tag""" @@ -218,8 +218,10 @@ class TagNamesField(forms.CharField): value = super(TagNamesField, self).clean(value) data = value.strip() if len(data) < 1: - raise forms.ValidationError(_('tags are required')) - + if askbot_settings.TAGS_ARE_REQUIRED: + raise forms.ValidationError(_('tags are required')) + else: + return ''#don't test for required characters when tags is '' split_re = re.compile(const.TAG_SPLIT_REGEX) tag_strings = split_re.split(data) entered_tags = [] diff --git a/askbot/models/question.py b/askbot/models/question.py index ff39bb7d..8c61385c 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -64,7 +64,15 @@ class ThreadManager(models.Manager): def create_new(self, title, author, added_at, wiki, text, tagnames=None, is_anonymous=False): # TODO: Some of this code will go to Post.objects.create_new - thread = super(ThreadManager, self).create(title=title, tagnames=tagnames, last_activity_at=added_at, last_activity_by=author) + thread = super( + ThreadManager, + self + ).create( + title=title, + tagnames=tagnames, + last_activity_at=added_at, + last_activity_by=author + ) question = Post( post_type='question', @@ -389,7 +397,10 @@ class Thread(models.Model): def get_tag_names(self): "Creates a list of Tag names from the ``tagnames`` attribute." - return self.tagnames.split(u' ') + if self.tagnames.strip() == '': + return list() + else: + return self.tagnames.split(u' ') def get_title(self, question=None): if not question: diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index 0ad59c69..1992b635 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -106,7 +106,7 @@ var CPValidator = function(){ getQuestionFormRules : function(){ return { tags: { - required: true, + required: askbot['settings']['tagsAreRequired'], maxlength: 105, limit_tag_count: true, limit_tag_length: true @@ -961,6 +961,10 @@ var questionRetagger = function(){ }; var drawNewTags = function(new_tags){ + if (new_tags === ''){ + tagsDiv.html(''); + return; + } new_tags = new_tags.split(/\s+/); var tags_html = '' $.each(new_tags, function(index, name){ @@ -1032,7 +1036,7 @@ var questionRetagger = function(){ div.validate({//copy-paste from utils.js rules: { tags: { - required: true, + required: askbot['settings']['tagsAreRequired'], maxlength: askbot['settings']['maxTagsPerPost'] * askbot['settings']['maxTagLength'], limit_tag_count: true, limit_tag_length: true diff --git a/askbot/skins/common/templates/widgets/edit_post.html b/askbot/skins/common/templates/widgets/edit_post.html index 16970a78..ee84f443 100644 --- a/askbot/skins/common/templates/widgets/edit_post.html +++ b/askbot/skins/common/templates/widgets/edit_post.html @@ -15,23 +15,25 @@ {# need label element for resizable input, b/c form validation won't find span #} {% if post_type == 'question' %}
- {% if mandatory_tags %} - - {{ - tag_list_widget( - mandatory_tags, - make_links = False, - css_class = 'clearfix' - ) - }} - {% else %} -