summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-24 23:08:29 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-24 23:08:29 -0400
commitff84855c68c0259a03add207f2e3b313e0c17621 (patch)
tree3b3c4ec32a26d848ca1a9112e9ec0aa144efaf51
parenta91dc795f94e9c159e3cc9ecd4131ac0511366dc (diff)
downloadaskbot-ff84855c68c0259a03add207f2e3b313e0c17621.tar.gz
askbot-ff84855c68c0259a03add207f2e3b313e0c17621.tar.bz2
askbot-ff84855c68c0259a03add207f2e3b313e0c17621.zip
added option to disable the big ask button
-rw-r--r--askbot/conf/main_pages.py14
-rw-r--r--askbot/conf/questions_page.py71
-rw-r--r--askbot/doc/source/changelog.rst1
-rw-r--r--askbot/media/js/live_search.js11
-rw-r--r--askbot/media/style/style.less43
-rw-r--r--askbot/templates/widgets/search_bar.html38
-rw-r--r--askbot/templates/widgets/secondary_header.html13
-rw-r--r--askbot/tests/db_api_tests.py33
-rw-r--r--askbot/tests/utils.py22
9 files changed, 124 insertions, 122 deletions
diff --git a/askbot/conf/main_pages.py b/askbot/conf/main_pages.py
index 940d2e91..06339a2f 100644
--- a/askbot/conf/main_pages.py
+++ b/askbot/conf/main_pages.py
@@ -15,6 +15,20 @@ MAIN_PAGES = livesettings.ConfigurationGroup(
settings.register(
livesettings.BooleanValue(
MAIN_PAGES,
+ 'ASK_BUTTON_ENABLED',
+ default=True,
+ description=_('Enable big Ask button'),
+ help_text=_(
+ 'Disabling this button will reduce number of new questions. '
+ 'If this button is disabled, the ask button in the search menu '
+ 'will still be available.'
+ )
+ )
+)
+
+settings.register(
+ livesettings.BooleanValue(
+ MAIN_PAGES,
'ALL_SCOPE_ENABLED',
default=True,
description=_('Enable "All Questions" selector'),
diff --git a/askbot/conf/questions_page.py b/askbot/conf/questions_page.py
deleted file mode 100644
index b1a9b689..00000000
--- a/askbot/conf/questions_page.py
+++ /dev/null
@@ -1,71 +0,0 @@
-"""
-Settings responsible for display of questions lists
-"""
-from askbot.conf.settings_wrapper import settings
-from askbot.conf.super_groups import DATA_AND_FORMATTING
-from askbot.deps import livesettings
-from django.utils.translation import ugettext_lazy as _
-
-MAIN_PAGES = livesettings.ConfigurationGroup(
- 'MAIN_PAGES',
- _('Questions page'),
- super_group=DATA_AND_FORMATTING
- )
-
-settings.register(
- livesettings.StringValue(
- MAIN_PAGES,
- 'ALL_SCOPE_ENABLED',
- default=True,
- description=_('Enable "All Questions" selector'),
- )
-)
-
-settings.register(
- livesettings.BooleanValue(
- MAIN_PAGES,
- 'UNANSWERED_SCOPE_ENABLED',
- default=True,
- description=_('Enable "Unanswered Questions" selector'),
- )
-)
-
-settings.register(
- livesettings.BooleanValue(
- MAIN_PAGES,
- 'FOLLOWED_SCOPE_ENABLED',
- default=True,
- description=_('Enable "Followed Questions" selector'),
- )
-)
-
-SCOPE_CHOICES_AUTHENTICATED = (
- ('all', _('All Questions')),
- ('unanswered', _('Unanswered Questions')),
- ('followed', _('Followed Questions'))
-)
-
-settings.register(
- livesettings.StringValue(
- MAIN_PAGES,
- 'DEFAULT_SCOPE_AUTHENTICATED',
- choices=SCOPE_CHOICES_AUTHENTICATED,
- default='all',
- description=_('Default questions selector for the authenticated users')
- )
-)
-
-SCOPE_CHOICES_ANONYMOUS = (#anonymous users can't see followed questions
- ('all', _('All Questions')),
- ('unanswered', _('Unanswered Questions')),
-)
-
-settings.register(
- livesettings.StringValue(
- MAIN_PAGES,
- 'DEFAULT_SCOPE_ANONYMOUS',
- choices=SCOPE_CHOICES_ANONYMOUS,
- default='all',
- description=_('Default questions selector for the anonymous users')
- )
-)
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst
index 24b72181..59db9e05 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -3,6 +3,7 @@ Changes in Askbot
Development version
-------------------
+* Allowed to disable the big "ask" button.
* Some support for the media compression (Tyler Mandry)
* Allowed to enable and disable question scopes on the main page
* Added full text support for some languages with Postgresql:
diff --git a/askbot/media/js/live_search.js b/askbot/media/js/live_search.js
index 4817431f..dfae8321 100644
--- a/askbot/media/js/live_search.js
+++ b/askbot/media/js/live_search.js
@@ -291,10 +291,13 @@ InputToolTip.prototype.setClickHandler = function(handler) {
InputToolTip.prototype.createDom = function() {
var element = this.makeElement('div');
this._element = element;
-
- element.html(gettext('search or ask your question'));
element.addClass('input-tool-tip');
+ element.html(gettext('search or ask your question'));
+ this.decorate(element);
+};
+InputToolTip.prototype.decorate = function(element) {
+ this._element = element;
var handler = this._clickHandler;
var me = this;
element.click(function() {
@@ -815,7 +818,9 @@ FullTextSearch.prototype.decorate = function(element) {
toolTip.setClickHandler(function() {
element.focus();
});
- this._element.after(toolTip.getElement());
+
+ element.after(toolTip.getElement());
+
//below is called after getElement, b/c element must be defined
if (this._prevText !== '') {
toolTip.hide();//hide if search query is not empty
diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less
index 667d0ec7..1f8f1b13 100644
--- a/askbot/media/style/style.less
+++ b/askbot/media/style/style.less
@@ -446,10 +446,6 @@ body.user-messages {
.sprites(-51px,-36px);
}
-#scopeNav {
- height: 41px;
-}
-
.scope-selector {
display:block;
float:left;
@@ -536,6 +532,7 @@ body.user-messages {
padding: 0 0 10px 0;
margin: 0;
position: relative;
+ width: 100%;
li {
padding: 5px 10px;
position: relative;
@@ -584,7 +581,7 @@ input[type="submit"].searchBtn {
line-height: 22px;
text-align: center;
float:right;
- margin: -33px 28px 0 0;
+ margin: -39px -48px 0 0;
width: 48px;
.sprites(-98px,-37px);
.rounded-corners(0);
@@ -593,6 +590,19 @@ input[type="submit"].searchBtn {
position: relative;
z-index: 10001;
}
+
+.groups-page, /* todo: clean up - should not need this */
+.tags-page,
+.badges-pages,
+.user-profile-page,
+.meta,
+.openid-signin,
+.users-page {
+ input[type="submit"].searchBtn {
+ margin-top: 1px;
+ }
+}
+
.ask-page {
input[type="submit"].searchBtn {
display: none;
@@ -634,7 +644,7 @@ input[type="button"].cancelSearchBtn {
width: 35px !important;
cursor:pointer;
float: right;
- margin: -34px 0 0 0;
+ margin: -40px 0 0 0;
position: relative;
z-index: 10001;
}
@@ -697,7 +707,7 @@ input[type="submit"].link:hover {
font-size: 20px;
height: 42px;
line-height: 44px;
- margin-top: -35px;
+ margin-top: 6px;
text-transform: uppercase;
width: 200px;/* to match width of sidebar */
}
@@ -722,23 +732,37 @@ input[type="submit"].link:hover {
body.anon.ask-page .search-drop-menu {
margin: 0;
}
+#scopeNav {
+ height: 41px;
+ float: left;
+ width: 280px;
+}
.scopes-True-True-False {
#searchBar,
.search-drop-menu {
margin-left: 228px;
}
+ #scopeNav {
+ width: 180px;
+ }
}
.scopes-True-False-True {
#searchBar,
.search-drop-menu {
margin-left: 203px;
}
+ #scopeNav {
+ width: 150px;
+ }
}
.scopes-False-True-True {
#searchBar,
.search-drop-menu {
margin-left: 286px;
}
+ #scopeNav {
+ width: 238px;
+ }
}
.scopes-True-False-False,
.scopes-False-True-False,
@@ -749,11 +773,6 @@ body.anon.ask-page .search-drop-menu {
}
}
-#searchBar.cancelable {
- padding-right: 82px;
-}
-
-
/* ----- Content layout, check two_column_body.html or one_column_body.html ----- */
#ContentLeft {
diff --git a/askbot/templates/widgets/search_bar.html b/askbot/templates/widgets/search_bar.html
index 3e7785e8..5f0bb8de 100644
--- a/askbot/templates/widgets/search_bar.html
+++ b/askbot/templates/widgets/search_bar.html
@@ -5,22 +5,28 @@
class="{% if query %}cancelable{% endif %}"
>
{# url action depends on which tab is active #}
- {% if active_tab == "tags" %}
- <input type="hidden" name="t" value="tag"/>
- {% else %}
- {% if active_tab == "users" %}
- <input type="hidden" name="t" value="user"/>
- {% endif %}
- {% endif %}
- {# class was searchInput #}
- <input
- class="searchInput"
- type="text"
- autocomplete="off"
- value="{{ query|default_if_none('') }}"
- name="query"
- id="keywords"
- />
+ {% if active_tab == "tags" %}
+ <input type="hidden" name="t" value="tag"/>
+ {% elif active_tab == "users" %}
+ <input type="hidden" name="t" value="user"/>
+ {% endif %}
+ <input
+ class="searchInput"
+ type="text"
+ autocomplete="off"
+ value="{{ query|default_if_none('') }}"
+ name="query"
+ id="keywords"
+ />
+ <input type="submit" value="" name="search" class="searchBtn" />
+ <input type="button"
+ value="X"
+ name="reset_query"
+ class="cancelSearchBtn"
+ {% if not query %}{# query is only defined by questions view (active_tab) #}
+ style="display: none;"
+ {% endif %}
+ />
</div>
{% endspaceless %}
{% endif %}
diff --git a/askbot/templates/widgets/secondary_header.html b/askbot/templates/widgets/secondary_header.html
index 58a2254e..f3f78fa7 100644
--- a/askbot/templates/widgets/secondary_header.html
+++ b/askbot/templates/widgets/secondary_header.html
@@ -32,16 +32,9 @@
three buttons below are in the opposite order because
they are floated at the right
#}
- {% include "widgets/ask_button.html" %}
- <input type="submit" value="" name="search" class="searchBtn" />
- <input type="button"
- value="X"
- name="reset_query"
- class="cancelSearchBtn"
- {% if not query %}{# query is only defined by questions view (active_tab) #}
- style="display: none;"
- {% endif %}
- />
+ {% if settings.ASK_BUTTON_ENABLED %}
+ {% include "widgets/ask_button.html" %}
+ {% endif %}
{# clears button floats #}
<div class="clearfix"></div>
</div>
diff --git a/askbot/tests/db_api_tests.py b/askbot/tests/db_api_tests.py
index 91c25867..8d775fd0 100644
--- a/askbot/tests/db_api_tests.py
+++ b/askbot/tests/db_api_tests.py
@@ -3,6 +3,7 @@ functions that happen on behalf of users
e.g. ``some_user.do_something(...)``
"""
+from bs4 import BeautifulSoup
from django.core import exceptions
from django.core.urlresolvers import reverse
from django.test.client import Client
@@ -667,3 +668,35 @@ class GroupTests(AskbotTestCase):
self.assertEqual(acts[0].recipients.count(), 1)
recipient = acts[0].recipients.all()[0]
self.assertEqual(recipient, mod)
+
+class LinkPostingTests(AskbotTestCase):
+
+ def assert_no_link(self, html):
+ soup = BeautifulSoup(html)
+ links = soup.findAll('a')
+ self.assertEqual(len(links), 0)
+
+ def assert_has_link(self, html, url):
+ soup = BeautifulSoup(html)
+ links = soup.findAll('a')
+ self.assertTrue(len(links) > 0)
+ self.assertEqual(links[0]['href'], url)
+
+ @with_settings(
+ EDITOR_TYPE='markdown',
+ MIN_REP_TO_SUGGEST_LINK=5,
+ MIN_REP_TO_INSERT_LINK=30
+ )
+ def test_admin_can_help_low_rep_user_insert_link(self):
+ #create a low rep user
+ low = self.create_user('low', reputation=10)
+ #create an admin
+ admin = self.create_user('admin', status='d')
+ #low re user posts a question with a link
+ text = 'hello, please read http://wikipedia.org'
+ question = self.post_question(user=low, body_text=text)
+ self.assert_no_link(question.html)
+ self.edit_question(user=admin, question=question, body_text=text + ' ok')
+ self.assert_has_link(question.html, 'http://wikipedia.org')
+
+
diff --git a/askbot/tests/utils.py b/askbot/tests/utils.py
index ee3cd37e..141f229a 100644
--- a/askbot/tests/utils.py
+++ b/askbot/tests/utils.py
@@ -96,11 +96,12 @@ class AskbotTestCase(TestCase):
def create_user(
self,
- username = 'user',
- email = None,
- notification_schedule = None,
- date_joined = None,
- status = 'a'
+ username='user',
+ email=None,
+ notification_schedule=None,
+ date_joined=None,
+ reputation=1,
+ status='a'
):
"""creates user with username, etc and
makes the result accessible as
@@ -116,11 +117,12 @@ class AskbotTestCase(TestCase):
email = username + '@example.com'
user_object = create_user(
- username = username,
- email = email,
- notification_schedule = notification_schedule,
- date_joined = date_joined,
- status = status
+ username=username,
+ email=email,
+ notification_schedule=notification_schedule,
+ date_joined=date_joined,
+ status=status,
+ reputation=reputation
)
setattr(self, username, user_object)