summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-05-09 15:18:10 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-05-09 15:18:10 -0400
commit56af1f30e5fc9bcab600d57506dc06db167730b1 (patch)
tree2231a41a02c547bb63417aa5747daa084f0e1cfd
parent5ec0ae6635bc9ece491c23b18507f2a558ce14e5 (diff)
downloadaskbot-56af1f30e5fc9bcab600d57506dc06db167730b1.tar.gz
askbot-56af1f30e5fc9bcab600d57506dc06db167730b1.tar.bz2
askbot-56af1f30e5fc9bcab600d57506dc06db167730b1.zip
finished moving settings to livesettings, available at url /settings
-rw-r--r--django_authopenid/forms.py3
-rw-r--r--django_authopenid/views.py10
-rw-r--r--forum/auth.py90
-rw-r--r--forum/conf/__init__.py4
-rw-r--r--forum/conf/email.py33
-rw-r--r--forum/conf/settings_wrapper.py7
-rw-r--r--forum/conf/skin_counter_settings.py273
-rw-r--r--forum/conf/skin_general_settings.py39
-rw-r--r--forum/conf/user_settings.py31
-rw-r--r--forum/context.py8
-rw-r--r--forum/feed.py10
-rw-r--r--forum/forms.py6
-rw-r--r--forum/importers/stackexchange/management/commands/load_stackexchange.py4
-rw-r--r--forum/middleware/anon_user.py4
-rw-r--r--forum/models/__init__.py4
-rw-r--r--forum/search/state_manager.py4
-rw-r--r--forum/skins/__init__.py39
-rw-r--r--forum/skins/default/templates/ask.html4
-rw-r--r--forum/skins/default/templates/ask_form.html4
-rw-r--r--forum/skins/default/templates/faq.html4
-rw-r--r--forum/templatetags/extra_tags.py53
-rw-r--r--forum/utils/forms.py3
-rw-r--r--forum/views/commands.py4
-rw-r--r--forum/views/users.py4
-rwxr-xr-xsettings_local.py.dist100
25 files changed, 517 insertions, 228 deletions
diff --git a/django_authopenid/forms.py b/django_authopenid/forms.py
index 2f34986c..2fd3fd7f 100644
--- a/django_authopenid/forms.py
+++ b/django_authopenid/forms.py
@@ -35,6 +35,7 @@ from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from django.utils.translation import ugettext as _
from django.conf import settings
+from forum.conf import settings as forum_settings
import types
import re
from django.utils.safestring import mark_safe
@@ -254,7 +255,7 @@ class ChangeEmailForm(forms.Form):
def clean_email(self):
""" check if email don't exist """
if 'email' in self.cleaned_data:
- if settings.EMAIL_UNIQUE == True:
+ if forum_settings.EMAIL_UNIQUE == True:
try:
user = User.objects.get(email = self.cleaned_data['email'])
if self.user and self.user == user:
diff --git a/django_authopenid/views.py b/django_authopenid/views.py
index 0212955c..688a41fc 100644
--- a/django_authopenid/views.py
+++ b/django_authopenid/views.py
@@ -508,7 +508,7 @@ def register(request):
#if user just logged in and did not need to create the new account
if user_ != None:
- if settings.EMAIL_VALIDATION == 'on':
+ if forum_settings.EMAIL_VALIDATION == True:
logging.debug('sending email validation')
send_new_email_key(user_,nomessage=True)
output = validation_email_sent(request)
@@ -750,7 +750,7 @@ def set_new_email(user, new_email, nomessage=False):
user.email = new_email
user.email_isvalid = False
user.save()
- if settings.EMAIL_VALIDATION == 'on':
+ if forum_settings.EMAIL_VALIDATION == True:
send_new_email_key(user,nomessage=nomessage)
def _send_email_key(user):
@@ -788,7 +788,7 @@ def send_email_key(request):
authopenid/changeemail.html template
"""
- if settings.EMAIL_VALIDATION != 'off':
+ if forum_settings.EMAIL_VALIDATION == True:
if request.user.email_isvalid:
return render_to_response('authopenid/changeemail.html',
{ 'email': request.user.email,
@@ -818,7 +818,7 @@ def verifyemail(request,id=None,key=None):
url = /email/verify/{{user.id}}/{{user.email_key}}/
"""
logging.debug('')
- if settings.EMAIL_VALIDATION != 'off':
+ if forum.settings.EMAIL_VALIDATION == True:
user = User.objects.get(id=id)
if user:
if user.email_key == key:
@@ -855,7 +855,7 @@ def changeemail(request, action='change'):
if form.is_valid():
new_email = form.cleaned_data['email']
if new_email != user_.email:
- if settings.EMAIL_VALIDATION == 'on':
+ if forum_settings.EMAIL_VALIDATION == True:
action = 'validate'
else:
action = 'done_novalidate'
diff --git a/forum/auth.py b/forum/auth.py
index d45e3647..6c9998cb 100644
--- a/forum/auth.py
+++ b/forum/auth.py
@@ -14,7 +14,7 @@ from models import mark_offensive, delete_post_or_answer
from const import TYPE_REPUTATION
import logging
-from forum.conf import settings
+from forum.conf import settings as forum_settings
def can_moderate_users(user):
return user.is_superuser
@@ -22,13 +22,13 @@ def can_moderate_users(user):
def can_vote_up(user):
"""Determines if a User can vote Questions and Answers up."""
return user.is_authenticated() and (
- user.reputation >= settings.MIN_REP_TO_VOTE_UP or
+ user.reputation >= forum_settings.MIN_REP_TO_VOTE_UP or
user.is_superuser)
def can_flag_offensive(user):
"""Determines if a User can flag Questions and Answers as offensive."""
return user.is_authenticated() and (
- user.reputation >= settings.MIN_REP_TO_FLAG_OFFENSIVE or
+ user.reputation >= forum_settings.MIN_REP_TO_FLAG_OFFENSIVE or
user.is_superuser)
def can_add_comments(user,subject):
@@ -36,7 +36,7 @@ def can_add_comments(user,subject):
if user.is_authenticated():
if user.id == subject.author.id:
return True
- if user.reputation >= settings.MIN_REP_TO_LEAVE_COMMENTS:
+ if user.reputation >= forum_settings.MIN_REP_TO_LEAVE_COMMENTS:
return True
if user.is_superuser:
return True
@@ -47,55 +47,55 @@ def can_add_comments(user,subject):
def can_vote_down(user):
"""Determines if a User can vote Questions and Answers down."""
return user.is_authenticated() and (
- user.reputation >= settings.MIN_REP_TO_VOTE_DOWN or
+ user.reputation >= forum_settings.MIN_REP_TO_VOTE_DOWN or
user.is_superuser)
def can_retag_questions(user):
"""Determines if a User can retag Questions."""
return user.is_authenticated() and (
- settings.MIN_REP_TO_RETAG_OTHERS_QUESTIONS
+ forum_settings.MIN_REP_TO_RETAG_OTHERS_QUESTIONS
<= user.reputation
- < settings.MIN_REP_TO_EDIT_OTHERS_POSTS or
+ < forum_settings.MIN_REP_TO_EDIT_OTHERS_POSTS or
user.is_superuser)
def can_edit_post(user, post):
"""Determines if a User can edit the given Question or Answer."""
return user.is_authenticated() and (
user.id == post.author_id or
- (post.wiki and user.reputation >= settings.MIN_REP_TO_EDIT_WIKI) or
- user.reputation >= settings.MIN_REP_TO_EDIT_OTHERS_POSTS or
+ (post.wiki and user.reputation >= forum_settings.MIN_REP_TO_EDIT_WIKI) or
+ user.reputation >= forum_settings.MIN_REP_TO_EDIT_OTHERS_POSTS or
user.is_superuser)
def can_delete_comment(user, comment):
"""Determines if a User can delete the given Comment."""
return user.is_authenticated() and (
user.id == comment.user_id or
- user.reputation >= settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS or
+ user.reputation >= forum_settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS or
user.is_superuser)
def can_view_offensive_flags(user):
"""Determines if a User can view offensive flag counts."""
return user.is_authenticated() and (
- user.reputation >= settings.MIN_REP_TO_VIEW_OFFENSIVE_FLAGS or
+ user.reputation >= forum_settings.MIN_REP_TO_VIEW_OFFENSIVE_FLAGS or
user.is_superuser)
def can_close_question(user, question):
"""Determines if a User can close the given Question."""
return user.is_authenticated() and (
(user.id == question.author_id and
- user.reputation >= settings.MIN_REP_TO_CLOSE_OWN_QUESTIONS) or
- user.reputation >= settings.MIN_REP_TO_CLOSE_OTHERS_QUESTIONS or
+ user.reputation >= forum_settings.MIN_REP_TO_CLOSE_OWN_QUESTIONS) or
+ user.reputation >= forum_settings.MIN_REP_TO_CLOSE_OTHERS_QUESTIONS or
user.is_superuser)
def can_lock_posts(user):
"""Determines if a User can lock Questions or Answers."""
return user.is_authenticated() and (
- user.reputation >= settings.MIN_REP_TO_LOCK_POSTS or
+ user.reputation >= forum_settings.MIN_REP_TO_LOCK_POSTS or
user.is_superuser)
def can_follow_url(user):
"""Determines if the URL link can be followed by Google search engine."""
- return user.reputation >= settings.MIN_REP_TO_DISABLE_URL_NOFOLLOW
+ return user.reputation >= forum_settings.MIN_REP_TO_DISABLE_URL_NOFOLLOW
def can_accept_answer(user, question, answer):
return (user.is_authenticated() and
@@ -106,7 +106,7 @@ def can_accept_answer(user, question, answer):
def can_reopen_question(user, question):
return (user.is_authenticated() and
user.id == question.author_id and
- user.reputation >= settings.MIN_REP_TO_REOPEN_OWN_QUESTIONS) or user.is_superuser
+ user.reputation >= forum_settings.MIN_REP_TO_REOPEN_OWN_QUESTIONS) or user.is_superuser
def can_delete_post(user, post):
if user.is_superuser:
@@ -143,7 +143,7 @@ def can_view_user_edit(request_user, target_user):
def can_upload_files(request_user):
return (request_user.is_authenticated() and
- request_user.reputation >= settings.MIN_REP_TO_UPLOAD_FILES) or \
+ request_user.reputation >= forum_settings.MIN_REP_TO_UPLOAD_FILES) or \
request_user.is_superuser
###########################################
@@ -166,7 +166,7 @@ def onFlaggedItem(item, post, user, timestamp=None):
post.save()
post.author.reputation = calculate_reputation(post.author.reputation,
- settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE)
+ forum_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE)
post.author.save()
question = post
@@ -174,35 +174,35 @@ def onFlaggedItem(item, post, user, timestamp=None):
question = post.question
reputation = Repute(user=post.author,
- negative=settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE,
question=question, reputed_at=timestamp,
reputation_type=-4,
reputation=post.author.reputation)
reputation.save()
#todo: These should be updated to work on same revisions.
- if post.offensive_flag_count == settings.MIN_FLAGS_TO_HIDE_POST:
+ if post.offensive_flag_count == forum_settings.MIN_FLAGS_TO_HIDE_POST:
post.author.reputation = calculate_reputation(post.author.reputation,
- settings.REP_LOSS_FOR_RECEIVING_THREE_FLAGS_PER_REVISION)
+ forum_settings.REP_LOSS_FOR_RECEIVING_THREE_FLAGS_PER_REVISION)
post.author.save()
reputation = Repute(user=post.author,
- negative=settings.REP_LOSS_FOR_RECEIVING_THREE_FLAGS_PER_REVISION,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_THREE_FLAGS_PER_REVISION,
question=question,
reputed_at=timestamp,
reputation_type=-6,
reputation=post.author.reputation)
reputation.save()
- elif post.offensive_flag_count == settings.MIN_FLAGS_TO_DELETE_POST:
+ elif post.offensive_flag_count == forum_settings.MIN_FLAGS_TO_DELETE_POST:
post.author.reputation = calculate_reputation(post.author.reputation,
- settings.REP_LOSS_FOR_RECEIVING_FIVE_FLAGS_PER_REVISION)
+ forum_settings.REP_LOSS_FOR_RECEIVING_FIVE_FLAGS_PER_REVISION)
post.author.save()
reputation = Repute(user=post.author,
- negative=settings.REP_LOSS_FOR_RECEIVING_FIVE_FLAGS_PER_REVISION,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_FIVE_FLAGS_PER_REVISION,
question=question,
reputed_at=timestamp,
reputation_type=-7,
@@ -232,7 +232,7 @@ def onAnswerAccept(answer, user, timestamp=None):
answer.author.reputation = calculate_reputation(
answer.author.reputation,
- settings.REP_GAIN_FOR_RECEIVING_ANSWER_ACCEPTANCE
+ forum_settings.REP_GAIN_FOR_RECEIVING_ANSWER_ACCEPTANCE
)
answer.author.save()
reputation = Repute(user=answer.author,
@@ -244,10 +244,10 @@ def onAnswerAccept(answer, user, timestamp=None):
reputation.save()
user.reputation = calculate_reputation(user.reputation,
- settings.REP_GAIN_FOR_ACCEPTING_ANSWER)
+ forum_settings.REP_GAIN_FOR_ACCEPTING_ANSWER)
user.save()
reputation = Repute(user=user,
- positive=settings.REP_GAIN_FOR_ACCEPTING_ANSWER,
+ positive=forum_settings.REP_GAIN_FOR_ACCEPTING_ANSWER,
question=answer.question,
reputed_at=timestamp,
reputation_type=3,
@@ -265,10 +265,10 @@ def onAnswerAcceptCanceled(answer, user, timestamp=None):
answer.question.save()
answer.author.reputation = calculate_reputation(answer.author.reputation,
- settings.REP_LOSS_FOR_RECEIVING_CANCELATION_OF_ANSWER_ACCEPTANCE)
+ forum_settings.REP_LOSS_FOR_RECEIVING_CANCELATION_OF_ANSWER_ACCEPTANCE)
answer.author.save()
reputation = Repute(user=answer.author,
- negative=settings.REP_LOSS_FOR_RECEIVING_CANCELATION_OF_ANSWER_ACCEPTANCE,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_CANCELATION_OF_ANSWER_ACCEPTANCE,
question=answer.question,
reputed_at=timestamp,
reputation_type=-2,
@@ -276,10 +276,10 @@ def onAnswerAcceptCanceled(answer, user, timestamp=None):
reputation.save()
user.reputation = calculate_reputation(user.reputation,
- settings.REP_LOSS_FOR_CANCELING_ANSWER_ACCEPTANCE)
+ forum_settings.REP_LOSS_FOR_CANCELING_ANSWER_ACCEPTANCE)
user.save()
reputation = Repute(user=user,
- negative=settings.REP_LOSS_FOR_CANCELING_ANSWER_ACCEPTANCE,
+ negative=forum_settings.REP_LOSS_FOR_CANCELING_ANSWER_ACCEPTANCE,
question=answer.question,
reputed_at=timestamp,
reputation_type=-1,
@@ -299,9 +299,9 @@ def onUpVoted(vote, post, user, timestamp=None):
if not post.wiki:
author = post.author
todays_rep_gain = Repute.objects.get_reputation_by_upvoted_today(author)
- if todays_rep_gain < settings.MAX_REP_GAIN_PER_USER_PER_DAY:
+ if todays_rep_gain < forum_settings.MAX_REP_GAIN_PER_USER_PER_DAY:
author.reputation = calculate_reputation(author.reputation,
- settings.REP_GAIN_FOR_RECEIVING_UPVOTE)
+ forum_settings.REP_GAIN_FOR_RECEIVING_UPVOTE)
author.save()
question = post
@@ -309,7 +309,7 @@ def onUpVoted(vote, post, user, timestamp=None):
question = post.question
reputation = Repute(user=author,
- positive=settings.REP_GAIN_FOR_RECEIVING_UPVOTE,
+ positive=forum_settings.REP_GAIN_FOR_RECEIVING_UPVOTE,
question=question,
reputed_at=timestamp,
reputation_type=1,
@@ -331,7 +331,7 @@ def onUpVotedCanceled(vote, post, user, timestamp=None):
if not post.wiki:
author = post.author
author.reputation = calculate_reputation(author.reputation,
- settings.REP_LOSS_FOR_RECEIVING_UPVOTE_CANCELATION)
+ forum_settings.REP_LOSS_FOR_RECEIVING_UPVOTE_CANCELATION)
author.save()
question = post
@@ -339,7 +339,7 @@ def onUpVotedCanceled(vote, post, user, timestamp=None):
question = post.question
reputation = Repute(user=author,
- negative=settings.REP_LOSS_FOR_RECEIVING_UPVOTE_CANCELATION,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_UPVOTE_CANCELATION,
question=question,
reputed_at=timestamp,
reputation_type=-8,
@@ -359,7 +359,7 @@ def onDownVoted(vote, post, user, timestamp=None):
if not post.wiki:
author = post.author
author.reputation = calculate_reputation(author.reputation,
- settings.REP_LOSS_FOR_DOWNVOTING)
+ forum_settings.REP_LOSS_FOR_DOWNVOTING)
author.save()
question = post
@@ -367,7 +367,7 @@ def onDownVoted(vote, post, user, timestamp=None):
question = post.question
reputation = Repute(user=author,
- negative=settings.REP_LOSS_FOR_DOWNVOTING,
+ negative=forum_settings.REP_LOSS_FOR_DOWNVOTING,
question=question,
reputed_at=timestamp,
reputation_type=-3,
@@ -375,11 +375,11 @@ def onDownVoted(vote, post, user, timestamp=None):
reputation.save()
user.reputation = calculate_reputation(user.reputation,
- settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE)
+ forum_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE)
user.save()
reputation = Repute(user=user,
- negative=settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE,
+ negative=forum_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE,
question=question,
reputed_at=timestamp,
reputation_type=-5,
@@ -401,7 +401,7 @@ def onDownVotedCanceled(vote, post, user, timestamp=None):
if not post.wiki:
author = post.author
author.reputation = calculate_reputation(author.reputation,
- settings.REP_GAIN_FOR_RECEIVING_DOWNVOTE_CANCELATION)
+ forum_settings.REP_GAIN_FOR_RECEIVING_DOWNVOTE_CANCELATION)
author.save()
question = post
@@ -409,7 +409,7 @@ def onDownVotedCanceled(vote, post, user, timestamp=None):
question = post.question
reputation = Repute(user=author,
- positive=settings.REP_GAIN_FOR_RECEIVING_DOWNVOTE_CANCELATION,
+ positive=forum_settings.REP_GAIN_FOR_RECEIVING_DOWNVOTE_CANCELATION,
question=question,
reputed_at=timestamp,
reputation_type=4,
@@ -417,11 +417,11 @@ def onDownVotedCanceled(vote, post, user, timestamp=None):
reputation.save()
user.reputation = calculate_reputation(user.reputation,
- settings.REP_GAIN_FOR_CANCELING_DOWNVOTE)
+ forum_settings.REP_GAIN_FOR_CANCELING_DOWNVOTE)
user.save()
reputation = Repute(user=user,
- positive=settings.REP_GAIN_FOR_CANCELING_DOWNVOTE,
+ positive=forum_settings.REP_GAIN_FOR_CANCELING_DOWNVOTE,
question=question,
reputed_at=timestamp,
reputation_type=5,
diff --git a/forum/conf/__init__.py b/forum/conf/__init__.py
index 0c0c3b1a..54ea2e32 100644
--- a/forum/conf/__init__.py
+++ b/forum/conf/__init__.py
@@ -7,6 +7,10 @@ import forum.conf.forum_data_rules
import forum.conf.flatpages
import forum.conf.site_settings
import forum.conf.external_keys
+import forum.conf.skin_counter_settings
+import forum.conf.skin_general_settings
+import forum.conf.user_settings
#import main settings object
from forum.conf.settings_wrapper import settings
+
diff --git a/forum/conf/email.py b/forum/conf/email.py
index 702a2a67..67704fd8 100644
--- a/forum/conf/email.py
+++ b/forum/conf/email.py
@@ -2,7 +2,8 @@
Email related settings
"""
from forum.conf.settings_wrapper import settings
-from livesettings import ConfigurationGroup, IntegerValue
+from livesettings import ConfigurationGroup, IntegerValue, BooleanValue
+from livesettings import StringValue
from django.utils.translation import ugettext as _
EMAIL = ConfigurationGroup(
@@ -19,9 +20,31 @@ settings.register(
)
)
-#todo: move email.py email_settings.py?
+settings.register(
+ BooleanValue(
+ EMAIL,
+ 'EMAIL_VALIDATION',
+ default=False,
+ description=_('Require email verification before allowing to post'),
+ help_text=_('Active email verification is done by sending a verification key in email')
+ )
+)
-EMAIL_VALIDATION = 'off' #string - on|off
-EMAIL_UNIQUE = False
-ANONYMOUS_USER_EMAIL = 'anonymous@askbot.org'
+settings.register(
+ BooleanValue(
+ EMAIL,
+ 'EMAIL_UNIQUE',
+ default=True,
+ description=_('Allow only one account per email address')
+ )
+)
+settings.register(
+ StringValue(
+ EMAIL,
+ 'ANONYMOUS_USER_EMAIL',
+ default='anonymous@askbot.org',
+ description=_('Fake email for anonymous user'),
+ help_text=_('Use this setting to control gravatar for email-less user')
+ )
+)
diff --git a/forum/conf/settings_wrapper.py b/forum/conf/settings_wrapper.py
index abf49e5f..d00856b6 100644
--- a/forum/conf/settings_wrapper.py
+++ b/forum/conf/settings_wrapper.py
@@ -6,9 +6,12 @@ via dotted lookup.
for example to lookup value of setting BLAH you would do
-from forum.conf import settings
+from forum.conf import settings as forum_settings
-settings.BLAH
+forum_settings.BLAH
+
+NOTE that at the moment there is distinction between settings
+(django settings) and forum_settings (livesettings)
the value will be taken from livesettings database or cache
note that during compilation phase database is not accessible
diff --git a/forum/conf/skin_counter_settings.py b/forum/conf/skin_counter_settings.py
index 7f612e93..51c7e332 100644
--- a/forum/conf/skin_counter_settings.py
+++ b/forum/conf/skin_counter_settings.py
@@ -1,24 +1,251 @@
-VOTE_COUNTER_EXPECTED_MAXIMUM = 3
+"""
+Skin settings to color view, vote and answer counters
+"""
+from forum.conf.settings_wrapper import settings
+from livesettings import ConfigurationGroup, IntegerValue, StringValue
+from django.utils.translation import ugettext as _
from forum_modules.grapefruit import Color
-COLORS_VOTE_COUNTER_EMPTY_BG = 'white'
-COLORS_VOTE_COUNTER_EMPTY_FG = 'gray'
-COLORS_VOTE_COUNTER_MIN_BG = 'white'
-COLORS_VOTE_COUNTER_MIN_FG = 'black'
-COLORS_VOTE_COUNTER_MAX_BG = '#a9d0f5'
-COLORS_VOTE_COUNTER_MAX_FG = Color.NewFromHtml(COLORS_VOTE_COUNTER_MAX_BG).DarkerColor(0.7).html
-VIEW_COUNTER_EXPECTED_MAXIMUM = 100
-COLORS_VIEW_COUNTER_EMPTY_BG = 'gray'
-COLORS_VIEW_COUNTER_EMPTY_FG = 'white'
-COLORS_VIEW_COUNTER_MIN_BG = '#D0F5A9'
-COLORS_VIEW_COUNTER_MIN_FG = Color.NewFromHtml(COLORS_VIEW_COUNTER_MIN_BG).DarkerColor(0.6).html
-COLORS_VIEW_COUNTER_MAX_BG = '#FF8000'#'#F7BE81'
-COLORS_VIEW_COUNTER_MAX_FG = Color.NewFromHtml(COLORS_VIEW_COUNTER_MAX_BG).DarkerColor(0.7).html
-ANSWER_COUNTER_EXPECTED_MAXIMUM = 4
-COLORS_ANSWER_COUNTER_EMPTY_BG = Color.NewFromHtml('#a40000').Blend(Color.NewFromHtml('white'),0.8).html
-COLORS_ANSWER_COUNTER_EMPTY_FG = 'yellow'
-COLORS_ANSWER_COUNTER_MIN_BG = '#AEB404'#'#81F7F3'#'#A9D0F5'#'#045FB4'
-COLORS_ANSWER_COUNTER_MIN_FG = 'white'#'#81F7F3'
-COLORS_ANSWER_COUNTER_MAX_BG = Color.NewFromHtml('#61380B').Blend(Color.NewFromHtml('white'),0.75).html
-COLORS_ANSWER_COUNTER_MAX_FG = '#ffff00'
-COLORS_ANSWER_COUNTER_ACCEPTED_BG = Color.NewFromHtml('darkgreen').Blend(Color.NewFromHtml('white'),0.8).html
-COLORS_ANSWER_COUNTER_ACCEPTED_FG = '#D0F5A9'
+
+SKIN_COUNTER_SETTINGS = ConfigurationGroup(
+ 'SKIN_COUNTER_SETTINGS',
+ _('Skin: view, vote and answer counters')
+ )
+
+settings.register(
+ IntegerValue(
+ SKIN_COUNTER_SETTINGS,
+ 'VOTE_COUNTER_EXPECTED_MAXIMUM',
+ default=3,
+ description=_('Vote counter value to give "full color"')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_EMPTY_BG',
+ default='white',
+ description=_('Background color for votes = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_EMPTY_FG',
+ default='gray',
+ description=_('Foreground color for votes = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_MIN_BG',
+ default='white',
+ description=_('Background color for votes = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_MIN_FG',
+ default='black',
+ description=_('Foreground color for votes = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_MAX_BG',
+ default='#a9d0f5',
+ description=_('Background color for votes = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VOTE_COUNTER_MAX_FG',
+ default=Color.NewFromHtml(
+ settings.COLORS_VOTE_COUNTER_MAX_BG
+ ).DarkerColor(0.7).html,
+ description=_('Foreground color for votes = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ IntegerValue(
+ SKIN_COUNTER_SETTINGS,
+ 'VIEW_COUNTER_EXPECTED_MAXIMUM',
+ default=100,
+ description=_('View counter value to give "full color"')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_EMPTY_BG',
+ default='gray',
+ description=_('Background color for views = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_EMPTY_FG',
+ default='white',
+ description=_('Foreground color for views = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_MIN_BG',
+ default='#D0F5A9',
+ description=_('Background color for views = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_MIN_FG',
+ default=Color.NewFromHtml(
+ settings.COLORS_VIEW_COUNTER_MIN_BG
+ ).DarkerColor(0.6).html,
+ description=_('Foreground color for views = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_MAX_BG',
+ default='#FF8000',
+ description=_('Background color for views = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_VIEW_COUNTER_MAX_FG',
+ default=Color.NewFromHtml(
+ settings.COLORS_VIEW_COUNTER_MAX_BG
+ ).DarkerColor(0.7).html,
+ description=_('Foreground color for views = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ IntegerValue(
+ SKIN_COUNTER_SETTINGS,
+ 'ANSWER_COUNTER_EXPECTED_MAXIMUM',
+ default=4,
+ description=_('Answer counter value to give "full color"')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_EMPTY_BG',
+ default=Color.NewFromHtml('#a40000').Blend(
+ Color.NewFromHtml('white'),0.8
+ ).html,
+ description=_('Background color for answers = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_EMPTY_FG',
+ default='yellow',
+ description=_('Foreground color for answers = 0'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_MIN_BG',
+ default='#AEB404',
+ description=_('Background color for answers = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_MIN_FG',
+ default='white',
+ description=_('Foreground color for answers = 1'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_MAX_BG',
+ default=Color.NewFromHtml('#61380B').Blend(
+ Color.NewFromHtml('white'),0.75
+ ).html,
+ description=_('Background color for answers = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_MAX_FG',
+ default='#ffff00',
+ description=_('Foreground color for answers = MAX'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_ACCEPTED_BG',
+ default=Color.NewFromHtml('darkgreen').Blend(
+ Color.NewFromHtml('white'),0.8
+ ).html,
+ description=_('Background color for accepted'),
+ help_text=_('HTML color name of hex value')
+ )
+)
+
+settings.register(
+ StringValue(
+ SKIN_COUNTER_SETTINGS,
+ 'COLORS_ANSWER_COUNTER_ACCEPTED_FG',
+ default='#D0F5A9',
+ description=_('Foreground color for accepted answer'),
+ help_text=_('HTML color name of hex value')
+ )
+)
diff --git a/forum/conf/skin_general_settings.py b/forum/conf/skin_general_settings.py
index 14165587..dab6e94c 100644
--- a/forum/conf/skin_general_settings.py
+++ b/forum/conf/skin_general_settings.py
@@ -1,3 +1,36 @@
-#skin settings
-RESOURCE_REVISION=4
-ASKBOT_DEFAULT_SKIN = 'default'
+"""
+General skin settings
+"""
+from forum.conf.settings_wrapper import settings
+from livesettings import ConfigurationGroup, StringValue, IntegerValue
+from django.utils.translation import ugettext as _
+from forum.skins import get_skin_choices
+
+GENERAL_SKIN_SETTINGS = ConfigurationGroup(
+ 'GENERAL_SKIN_SETTINGS',
+ _('Skin: general settings'),
+ )
+
+settings.register(
+ StringValue(
+ GENERAL_SKIN_SETTINGS,
+ 'ASKBOT_DEFAULT_SKIN',
+ default='default',
+ choices=get_skin_choices(),
+ description=_('Select skin'),
+ )
+)
+
+settings.register(
+ IntegerValue(
+ GENERAL_SKIN_SETTINGS,
+ 'MEDIA_RESOURCE_REVISION',
+ default=1,
+ description=_('Skin media revision number'),
+ help_text=_(
+ 'Increment this number when you change '
+ 'image in skin media or stylesheet'
+ )
+ )
+)
+
diff --git a/forum/conf/user_settings.py b/forum/conf/user_settings.py
index 62e7095c..1aa92d18 100644
--- a/forum/conf/user_settings.py
+++ b/forum/conf/user_settings.py
@@ -1,2 +1,29 @@
-EDITABLE_SCREEN_NAME = False#True or False - can user change screen name?
-MIN_USERNAME_LENGTH = 1
+"""
+User policy settings
+"""
+from forum.conf.settings_wrapper import settings
+from livesettings import ConfigurationGroup, BooleanValue, IntegerValue
+from django.utils.translation import ugettext as _
+
+USER_SETTINGS = ConfigurationGroup(
+ 'USER_SETTINGS',
+ _('User policy settings')
+ )
+
+settings.register(
+ BooleanValue(
+ USER_SETTINGS,
+ 'EDITABLE_SCREEN_NAME',
+ default=True,
+ description=_('Allow editing user screen name')
+ )
+)
+
+settings.register(
+ IntegerValue(
+ USER_SETTINGS,
+ 'MIN_USERNAME_LENGTH',
+ default=1,
+ description=_('Minimum allowed length for screen name')
+ )
+)
diff --git a/forum/context.py b/forum/context.py
index 1cbb82ba..47fb43f2 100644
--- a/forum/context.py
+++ b/forum/context.py
@@ -13,12 +13,12 @@ def application_settings(context):
'FORUM_PRIVACY': forum_settings.FORUM_PRIVACY,
'GOOGLE_SITEMAP_CODE':forum_settings.GOOGLE_SITEMAP_CODE,
'GOOGLE_ANALYTICS_KEY':forum_settings.GOOGLE_ANALYTICS_KEY,
- 'RESOURCE_REVISION':settings.RESOURCE_REVISION,
- 'ASKBOT_SKIN':settings.ASKBOT_DEFAULT_SKIN,
- 'EMAIL_VALIDATION': settings.EMAIL_VALIDATION,
+ 'EMAIL_VALIDATION': forum_settings.EMAIL_VALIDATION,
+ 'RESOURCE_REVISION':forum_settings.MEDIA_RESOURCE_REVISION,
+ 'ASKBOT_SKIN':forum_settings.ASKBOT_DEFAULT_SKIN,
+ 'EDITABLE_SCREEN_NAME':forum_settings.EDITABLE_SCREEN_NAME,
'FORUM_SCRIPT_ALIAS': settings.FORUM_SCRIPT_ALIAS,
'LANGUAGE_CODE': settings.LANGUAGE_CODE,
- 'EDITABLE_SCREEN_NAME':settings.EDITABLE_SCREEN_NAME,
}
return {'settings':my_settings}
diff --git a/forum/feed.py b/forum/feed.py
index 5d124eb9..94065120 100644
--- a/forum/feed.py
+++ b/forum/feed.py
@@ -13,13 +13,13 @@
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
from django.utils.translation import ugettext as _
from models import Question
-from forum.conf import settings
+from forum.conf import settings as forum_settings
class RssLastestQuestionsFeed(Feed):
- title = settings.APP_TITLE + _(' - ')+ _('latest questions')
- link = settings.APP_URL
- description = settings.APP_DESCRIPTION
+ title = forum_settings.APP_TITLE + _(' - ')+ _('latest questions')
+ link = forum_settings.APP_URL
+ description = forum_settings.APP_DESCRIPTION
#ttl = 10
- copyright = settings.APP_COPYRIGHT
+ copyright = forum_settings.APP_COPYRIGHT
def item_link(self, item):
return self.link + item.get_absolute_url()
diff --git a/forum/forms.py b/forum/forms.py
index 52cf00cc..e69d8480 100644
--- a/forum/forms.py
+++ b/forum/forms.py
@@ -293,7 +293,7 @@ class EditAnswerForm(forms.Form):
class EditUserForm(forms.Form):
email = forms.EmailField(label=u'Email', help_text=_('this email does not have to be linked to gravatar'), required=True, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- if settings.EDITABLE_SCREEN_NAME:
+ if forum_settings.EDITABLE_SCREEN_NAME:
username = UserNameField(label=_('Screen name'))
realname = forms.CharField(label=_('Real name'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
website = forms.URLField(label=_('Website'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
@@ -304,7 +304,7 @@ class EditUserForm(forms.Form):
def __init__(self, user, *args, **kwargs):
super(EditUserForm, self).__init__(*args, **kwargs)
logging.debug('initializing the form')
- if settings.EDITABLE_SCREEN_NAME:
+ if forum_settings.EDITABLE_SCREEN_NAME:
self.fields['username'].initial = user.username
self.fields['username'].user_instance = user
self.fields['email'].initial = user.email
@@ -323,7 +323,7 @@ class EditUserForm(forms.Form):
"""For security reason one unique email in database"""
if self.user.email != self.cleaned_data['email']:
#todo dry it, there is a similar thing in openidauth
- if settings.EMAIL_UNIQUE == True:
+ if forum_settings.EMAIL_UNIQUE == True:
if 'email' in self.cleaned_data:
try:
user = User.objects.get(email = self.cleaned_data['email'])
diff --git a/forum/importers/stackexchange/management/commands/load_stackexchange.py b/forum/importers/stackexchange/management/commands/load_stackexchange.py
index ee22e33a..308ac0bb 100644
--- a/forum/importers/stackexchange/management/commands/load_stackexchange.py
+++ b/forum/importers/stackexchange/management/commands/load_stackexchange.py
@@ -11,7 +11,7 @@ import forum.models as askbot
import forum.importers.stackexchange.models as se
from forum.forms import EditUserEmailFeedsForm
from forum.utils.html import sanitize_html
-from django.conf import settings
+from forum.conf import settings as forum_settings
from django.contrib.auth.models import Message as DjangoMessage
from django.utils.translation import ugettext as _
#from markdown2 import Markdown
@@ -209,7 +209,7 @@ class X(object):#
@classmethod
def get_email(cls, email):#todo: fix fringe case - user did not give email!
if email is None:
- return settings.ANONYMOUS_USER_EMAIL
+ return forum_settings.ANONYMOUS_USER_EMAIL
else:
assert(email != '')
return email
diff --git a/forum/middleware/anon_user.py b/forum/middleware/anon_user.py
index 2d1dcd2d..51d35fa7 100644
--- a/forum/middleware/anon_user.py
+++ b/forum/middleware/anon_user.py
@@ -3,7 +3,7 @@ from forum.utils.forms import get_next_url
from django.utils.translation import ugettext as _
from forum.user_messages import create_message, get_and_delete_messages
from django.core.urlresolvers import reverse
-from forum.conf import settings
+from forum.conf import settings as forum_settings
from forum import const
import logging
@@ -32,5 +32,5 @@ class ConnectToSessionMessagesMiddleware(object):
#also set the first greeting one time per session only
if 'greeting_set' not in request.session:
request.session['greeting_set'] = True
- msg = _(const.GREETING_FOR_ANONYMOUS_USER) % settings.GREETING_URL
+ msg = _(const.GREETING_FOR_ANONYMOUS_USER) % forum_settings.GREETING_URL
request.user.message_set.create(message=msg)
diff --git a/forum/models/__init__.py b/forum/models/__init__.py
index 5140f9e1..024379db 100644
--- a/forum/models/__init__.py
+++ b/forum/models/__init__.py
@@ -408,8 +408,8 @@ def record_user_full_updated(instance, **kwargs):
def post_stored_anonymous_content(sender,user,session_key,signal,*args,**kwargs):
aq_list = AnonymousQuestion.objects.filter(session_key = session_key)
aa_list = AnonymousAnswer.objects.filter(session_key = session_key)
- from django.conf import settings
- if settings.EMAIL_VALIDATION == 'on':#add user to the record
+ from forum.conf import settings as forum_settings
+ if forum_settings.EMAIL_VALIDATION == True:#add user to the record
for aq in aq_list:
aq.author = user
aq.save()
diff --git a/forum/search/state_manager.py b/forum/search/state_manager.py
index ac3f7014..86cc5662 100644
--- a/forum/search/state_manager.py
+++ b/forum/search/state_manager.py
@@ -2,7 +2,7 @@
#that lives in the session and takes care of the state
#persistece during the search session
from forum import const
-from forum.conf import settings
+from forum.conf import settings as forum_settings
import logging
ACTIVE_COMMANDS = (
@@ -25,7 +25,7 @@ class SearchState(object):
self.tags = None
self.author = None
self.sort = const.DEFAULT_POST_SORT_METHOD
- self.page_size = int(settings.DEFAULT_QUESTIONS_PAGE_SIZE)
+ self.page_size = int(forum_settings.DEFAULT_QUESTIONS_PAGE_SIZE)
self.page = 1
self.logged_in = False
logging.debug('new search state initialized')
diff --git a/forum/skins/__init__.py b/forum/skins/__init__.py
index 10b6a340..fcb4dd59 100644
--- a/forum/skins/__init__.py
+++ b/forum/skins/__init__.py
@@ -1,13 +1,13 @@
-from django.conf import settings
+from forum.conf import settings as forum_settings
from django.template import loader
from django.template.loaders import filesystem
from django.http import HttpResponse
import os.path
+import os
import logging
#module for skinning askbot
-#at this point skin can be changed only in settings file
-#via ASKBOT_DEFAULT_SKIN variable
+#via ASKBOT_DEFAULT_SKIN configureation variable (not django setting)
#note - Django template loaders use method django.utils._os.safe_join
#to work on unicode file paths
@@ -15,18 +15,28 @@ import logging
def load_template_source(name, dirs=None):
try:
- tname = os.path.join(settings.ASKBOT_DEFAULT_SKIN,'templates',name)
+ tname = os.path.join(forum_settings.ASKBOT_DEFAULT_SKIN,'templates',name)
return filesystem.load_template_source(tname,dirs)
except:
tname = os.path.join('default','templates',name)
return filesystem.load_template_source(tname,dirs)
load_template_source.is_usable = True
+def get_skin_dirs():
+ #todo: handle case of multiple skin directories
+ d = os.path.dirname
+ n = os.path.normpath
+ j = os.path.join
+ f = os.path.isfile
+ skin_dirs = []
+ skin_dirs.append( n(j(d(d(__file__)), 'skins')) )
+ return skin_dirs
+
def find_media_source(url):
"""returns url prefixed with the skin name
of the first skin that contains the file
directories are searched in this order:
- settings.ASKBOT_DEFAULT_SKIN, then 'default', then 'commmon'
+ forum_settings.ASKBOT_DEFAULT_SKIN, then 'default', then 'commmon'
if file is not found - returns None
and logs an error message
"""
@@ -35,11 +45,12 @@ def find_media_source(url):
n = os.path.normpath
j = os.path.join
f = os.path.isfile
- skins = n(j(d(d(__file__)),'skins'))
+ #todo: handles case of multiple skin directories
+ skins = get_skin_dirs()[0]
try:
- media = os.path.join(skins, settings.ASKBOT_DEFAULT_SKIN, url)
+ media = os.path.join(skins, forum_settings.ASKBOT_DEFAULT_SKIN, url)
assert(f(media))
- use_skin = settings.ASKBOT_DEFAULT_SKIN
+ use_skin = forum_settings.ASKBOT_DEFAULT_SKIN
except:
try:
media = j(skins, 'default', url)
@@ -55,3 +66,15 @@ def find_media_source(url):
use_skin = ''
return None
return use_skin + '/' + url
+
+def get_skin_choices():
+ dirs = get_skin_dirs()
+ items = os.listdir(dirs[0])
+ skin_list = ['default']
+ for i in items:
+ if i == 'common':
+ continue
+ if i not in skin_list:
+ skin_list.append(i)
+
+ return [(i,i) for i in skin_list]
diff --git a/forum/skins/default/templates/ask.html b/forum/skins/default/templates/ask.html
index 4278f4cb..82828fe9 100644
--- a/forum/skins/default/templates/ask.html
+++ b/forum/skins/default/templates/ask.html
@@ -69,7 +69,7 @@
<p>{% trans "login to post question info" %}</p>
</div>
{% else %}
- {% ifequal settings.EMAIL_VALIDATION 'on' %}
+ {% if settings.EMAIL_VALIDATION %}
{% if not request.user.email_isvalid %}
<div class="message">
{% blocktrans with request.user.email as email %}must have valid {{email}} to post,
@@ -77,7 +77,7 @@
{% endblocktrans %}
</div>
{% endif %}
- {% endifequal %}
+ {% endif %}
{% endif %}
<div class="form-item">
<label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
diff --git a/forum/skins/default/templates/ask_form.html b/forum/skins/default/templates/ask_form.html
index 25e9fe6c..1bb3866b 100644
--- a/forum/skins/default/templates/ask_form.html
+++ b/forum/skins/default/templates/ask_form.html
@@ -10,13 +10,13 @@
{% if not request.user.is_authenticated %}
<p>{% trans "login to post question info" %}</p>
{% else %}
- {% ifequal settings.EMAIL_VALIDATION 'on' %}
+ {% if settings.EMAIL_VALIDATION %}
{% if not request.user.email_isvalid %}
{% blocktrans with request.user.email as email %}must have valid {{email}} to post,
see {{email_validation_faq_url}}
{% endblocktrans %}
{% endif %}
- {% endifequal %}
+ {% endif %}
{% endif %}
<input id="id_title" class="questionTitleInput" name="title"
value="{% if form.initial.title %}{{form.initial.title}}{% endif %}"/>
diff --git a/forum/skins/default/templates/faq.html b/forum/skins/default/templates/faq.html
index cc790ccc..c944240a 100644
--- a/forum/skins/default/templates/faq.html
+++ b/forum/skins/default/templates/faq.html
@@ -98,13 +98,13 @@
</table>
</div>
{% comment %}
- {% ifequal settings.EMAIL_VALIDATION 'on' %}
+ {% if settings.EMAIL_VALIDATION %}
<div>
<a id='validate'></a><h3 class="subtitle">{% trans "how to validate email title" %}</h3>
<!--special case here message must contain paragraphs-->
{% blocktrans %}how to validate email info with {{send_email_key_url}} {{gravatar_faq_url}}{% endblocktrans %}
</div>
- {% endifequal %}
+ {% endif %}
{% endcomment %}
<div>
<a id='gravatar'></a><h3 class="subtitle">{% trans "what is gravatar" %}</h3>
diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py
index 36de4ec5..39a1ded7 100644
--- a/forum/templatetags/extra_tags.py
+++ b/forum/templatetags/extra_tags.py
@@ -294,7 +294,10 @@ def media(url):
url = skins.find_media_source(url)
if url:
url = '///' + settings.FORUM_SCRIPT_ALIAS + '/m/' + url
- return posixpath.normpath(url) + '?v=%d' % settings.RESOURCE_REVISION
+ return posixpath.normpath(url) + '?v=%d' \
+ % forum_settings.MEDIA_RESOURCE_REVISION
+ else:
+ return '' #todo: raise exception here?
class ItemSeparatorNode(template.Node):
def __init__(self,separator):
@@ -374,7 +377,7 @@ class BlockMediaUrlNode(template.Node):
url = skins.find_media_source(url)
url = prefix + url
- out = posixpath.normpath(url) + '?v=%d' % settings.RESOURCE_REVISION
+ out = posixpath.normpath(url) + '?v=%d' % forum_settings.MEDIA_RESOURCE_REVISION
return out.replace(' ','')
@register.tag(name='blockmedia')
@@ -424,39 +427,39 @@ def question_counter_widget(question):
#background and foreground colors for each item
(views_fg, views_bg) = colors.get_counter_colors(
view_count,
- max = settings.VIEW_COUNTER_EXPECTED_MAXIMUM,
- zero_bg = settings.COLORS_VIEW_COUNTER_EMPTY_BG,
- zero_fg = settings.COLORS_VIEW_COUNTER_EMPTY_FG,
- min_bg = settings.COLORS_VIEW_COUNTER_MIN_BG,
- min_fg = settings.COLORS_VIEW_COUNTER_MIN_FG,
- max_bg = settings.COLORS_VIEW_COUNTER_MAX_BG,
- max_fg = settings.COLORS_VIEW_COUNTER_MAX_FG,
+ max = forum_settings.VIEW_COUNTER_EXPECTED_MAXIMUM,
+ zero_bg = forum_settings.COLORS_VIEW_COUNTER_EMPTY_BG,
+ zero_fg = forum_settings.COLORS_VIEW_COUNTER_EMPTY_FG,
+ min_bg = forum_settings.COLORS_VIEW_COUNTER_MIN_BG,
+ min_fg = forum_settings.COLORS_VIEW_COUNTER_MIN_FG,
+ max_bg = forum_settings.COLORS_VIEW_COUNTER_MAX_BG,
+ max_fg = forum_settings.COLORS_VIEW_COUNTER_MAX_FG,
)
(answers_fg, answers_bg) = colors.get_counter_colors(
answer_count,
- max = settings.ANSWER_COUNTER_EXPECTED_MAXIMUM,
- zero_bg = settings.COLORS_ANSWER_COUNTER_EMPTY_BG,
- zero_fg = settings.COLORS_ANSWER_COUNTER_EMPTY_FG,
- min_bg = settings.COLORS_ANSWER_COUNTER_MIN_BG,
- min_fg = settings.COLORS_ANSWER_COUNTER_MIN_FG,
- max_bg = settings.COLORS_ANSWER_COUNTER_MAX_BG,
- max_fg = settings.COLORS_ANSWER_COUNTER_MAX_FG,
+ max = forum_settings.ANSWER_COUNTER_EXPECTED_MAXIMUM,
+ zero_bg = forum_settings.COLORS_ANSWER_COUNTER_EMPTY_BG,
+ zero_fg = forum_settings.COLORS_ANSWER_COUNTER_EMPTY_FG,
+ min_bg = forum_settings.COLORS_ANSWER_COUNTER_MIN_BG,
+ min_fg = forum_settings.COLORS_ANSWER_COUNTER_MIN_FG,
+ max_bg = forum_settings.COLORS_ANSWER_COUNTER_MAX_BG,
+ max_fg = forum_settings.COLORS_ANSWER_COUNTER_MAX_FG,
)
if answer_accepted:
#todo: maybe recalculate the foreground color too
- answers_bg = settings.COLORS_ANSWER_COUNTER_ACCEPTED_BG
- answers_fg = settings.COLORS_ANSWER_COUNTER_ACCEPTED_FG
+ answers_bg = forum_settings.COLORS_ANSWER_COUNTER_ACCEPTED_BG
+ answers_fg = forum_settings.COLORS_ANSWER_COUNTER_ACCEPTED_FG
(votes_fg, votes_bg) = colors.get_counter_colors(
vote_count,
- max = settings.VOTE_COUNTER_EXPECTED_MAXIMUM,
- zero_bg = settings.COLORS_VOTE_COUNTER_EMPTY_BG,
- zero_fg = settings.COLORS_VOTE_COUNTER_EMPTY_FG,
- min_bg = settings.COLORS_VOTE_COUNTER_MIN_BG,
- min_fg = settings.COLORS_VOTE_COUNTER_MIN_FG,
- max_bg = settings.COLORS_VOTE_COUNTER_MAX_BG,
- max_fg = settings.COLORS_VOTE_COUNTER_MAX_FG,
+ max = forum_settings.VOTE_COUNTER_EXPECTED_MAXIMUM,
+ zero_bg = forum_settings.COLORS_VOTE_COUNTER_EMPTY_BG,
+ zero_fg = forum_settings.COLORS_VOTE_COUNTER_EMPTY_FG,
+ min_bg = forum_settings.COLORS_VOTE_COUNTER_MIN_BG,
+ min_fg = forum_settings.COLORS_VOTE_COUNTER_MIN_FG,
+ max_bg = forum_settings.COLORS_VOTE_COUNTER_MAX_BG,
+ max_fg = forum_settings.COLORS_VOTE_COUNTER_MAX_FG,
)
#returns a dictionary with keys like 'votes_bg', etc
diff --git a/forum/utils/forms.py b/forum/utils/forms.py
index d8d04d05..946c1fd9 100644
--- a/forum/utils/forms.py
+++ b/forum/utils/forms.py
@@ -3,6 +3,7 @@ import re
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.conf import settings
+from forum.conf import settings as forum_settings
from django.http import str_to_unicode
from django.contrib.auth.models import User
import logging
@@ -121,7 +122,7 @@ class UserEmailField(forms.EmailField):
email = super(UserEmailField,self).clean(email.strip())
if self.skip_clean:
return email
- if settings.EMAIL_UNIQUE == True:
+ if forum_settings.EMAIL_UNIQUE == True:
try:
user = User.objects.get(email = email)
logging.debug('email taken')
diff --git a/forum/views/commands.py b/forum/views/commands.py
index 2905426c..4746f71d 100644
--- a/forum/views/commands.py
+++ b/forum/views/commands.py
@@ -210,7 +210,9 @@ def vote(request, id):#todo: pretty incomprehensible view used by various ajax c
if user.is_authenticated():
if user not in question.followed_by.all():
question.followed_by.add(user)
- if settings.EMAIL_VALIDATION == 'on' and user.email_isvalid == False:
+ if forum_settings.EMAIL_VALIDATION == True \
+ and user.email_isvalid == False:
+
response_data['message'] = \
_('subscription saved, %(email)s needs validation, see %(details_url)s') \
% {'email':user.email,'details_url':reverse('faq') + '#validate'}
diff --git a/forum/views/users.py b/forum/views/users.py
index a8b9398d..8a7ecaa6 100644
--- a/forum/views/users.py
+++ b/forum/views/users.py
@@ -109,7 +109,7 @@ def set_new_email(user, new_email, nomessage=False):
user.email = new_email
user.email_isvalid = False
user.save()
- #if settings.EMAIL_VALIDATION == 'on':
+ #if forum_settings.EMAIL_VALIDATION == True:
# send_new_email_key(user,nomessage=nomessage)
@login_required
@@ -124,7 +124,7 @@ def edit_user(request, id):
set_new_email(user, new_email)
- if settings.EDITABLE_SCREEN_NAME:
+ if forum_settings.EDITABLE_SCREEN_NAME:
user.username = sanitize_html(form.cleaned_data['username'])
user.real_name = sanitize_html(form.cleaned_data['realname'])
diff --git a/settings_local.py.dist b/settings_local.py.dist
index 137ad6ec..a75a09c1 100755
--- a/settings_local.py.dist
+++ b/settings_local.py.dist
@@ -1,6 +1,5 @@
# encoding:utf-8
import os.path
-from django.utils.translation import ugettext as _
SITE_SRC_ROOT = os.path.dirname(__file__)
LOG_FILENAME = 'askbot.log'
@@ -18,26 +17,17 @@ ADMINS = (('Forum Admin', 'forum@example.com'),)
MANAGERS = ADMINS
#DEBUG SETTINGS
-DEBUG = False
+DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)
DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
-DATABASE_ENGINE = '' #mysql, etc
+DATABASE_ENGINE = 'mysql' #mysql, etc
DATABASE_HOST = ''
DATABASE_PORT = ''
-#set this value to 'dummy://' if you don't want to use cache, or set up your favourite caching mechanism
-#see http://docs.djangoproject.com/en/1.1/topics/cache/ for details
-#example (set local file system cache in a cache folder in the root of the askbot install):
-#CACHE_BACKEND = 'file://%s' % os.path.join(os.path.dirname(__file__),'cache').replace('\\','/')
-CACHE_BACKEND = 'dummy://'
-
-#If you use memcache you may want to uncomment the following line to enable memcached based sessions
-#SESSION_ENGINE = 'django.contrib.sessions.backends.cache_db'
-
#email server settings
SERVER_EMAIL = ''
DEFAULT_FROM_EMAIL = ''
@@ -48,80 +38,32 @@ EMAIL_HOST='askbot.org'
EMAIL_PORT='25'
EMAIL_USE_TLS=False
-#HACK - anonymous user email - for email-less users
-ANONYMOUS_USER_EMAIL = 'anonymous@askbot.org'
-
#LOCALIZATIONS
TIME_ZONE = 'America/New_York'
-###########################
-#
-# this will allow running your forum with url like http://site.com/forum
-#
-# FORUM_SCRIPT_ALIAS = 'forum/'
-#
+#this will allow running your forum with url like http://site.com/forum
+#FORUM_SCRIPT_ALIAS = 'forum/'
FORUM_SCRIPT_ALIAS = '' #no leading slash, default = '' empty string
-
#OTHER SETTINGS
-APP_TITLE = u'ASKBOT: Open Source Q&A Forum'
-APP_SHORT_NAME = u'ASKBOT'
-APP_KEYWORDS = u'ASKBOT,CNPROG,forum,community'
-APP_DESCRIPTION = u'Ask and answer questions.'
-APP_INTRO = u'<p>Ask and answer questions, make the world better!</p>'
-APP_COPYRIGHT = 'Copyright ASKBOT, 2009. Some rights reserved under creative commons license.'
-LOGIN_URL = '/%s%s%s' % (FORUM_SCRIPT_ALIAS,'account/','signin/')
-GREETING_URL = LOGIN_URL #may be url of "faq" page or "about", etc
+_ = lambda v:v
+LOGIN_URL = '/%s%s%s' % (FORUM_SCRIPT_ALIAS,_('account/'),_('signin/'))
USE_I18N = True
LANGUAGE_CODE = 'en'
-EMAIL_VALIDATION = 'off' #string - on|off
-MIN_USERNAME_LENGTH = 1
-EMAIL_UNIQUE = False
-APP_URL = 'http://askbot.org' #used by email notif system and RSS
-GOOGLE_SITEMAP_CODE = ''
-GOOGLE_ANALYTICS_KEY = ''
-WIKI_ON = True
-FEEDBACK_SITE_URL = None #None or url
-EDITABLE_SCREEN_NAME = False #True or False - can user change screen name?
-
-DJANGO_VERSION = 1.1
-RESOURCE_REVISION=4
-
-#please get these at recaptcha.net
-RECAPTCHA_PRIVATE_KEY='...'
-RECAPTCHA_PUBLIC_KEY='...'
-ASKBOT_DEFAULT_SKIN = 'default'
-
-
-#Facebook settings
-USE_FB_CONNECT=False
-FB_API_KEY='' #your api key from facebook
-FB_SECRET='' #your application secret
-USE_EXTERNAL_LEGACY_LOGIN = False #DO NOT USE, and do not delete this line, will be removed later
-#counter colors
-from forum_modules.grapefruit import Color
-VOTE_COUNTER_EXPECTED_MAXIMUM = 5
-COLORS_VOTE_COUNTER_EMPTY_BG = 'white'
-COLORS_VOTE_COUNTER_EMPTY_FG = 'gray'
-COLORS_VOTE_COUNTER_MIN_BG = 'white'
-COLORS_VOTE_COUNTER_MIN_FG = 'black'
-COLORS_VOTE_COUNTER_MAX_BG = '#a9d0f5'
-COLORS_VOTE_COUNTER_MAX_FG = Color.NewFromHtml(COLORS_VOTE_COUNTER_MAX_BG).DarkerColor(0.7).html
-VIEW_COUNTER_EXPECTED_MAXIMUM = 100
-COLORS_VIEW_COUNTER_EMPTY_BG = 'gray'
-COLORS_VIEW_COUNTER_EMPTY_FG = 'white'
-COLORS_VIEW_COUNTER_MIN_BG = '#D0F5A9'
-COLORS_VIEW_COUNTER_MIN_FG = Color.NewFromHtml(COLORS_VIEW_COUNTER_MIN_BG).DarkerColor(0.6).html
-COLORS_VIEW_COUNTER_MAX_BG = '#FF8000'#'#F7BE81'
-COLORS_VIEW_COUNTER_MAX_FG = Color.NewFromHtml(COLORS_VIEW_COUNTER_MAX_BG).DarkerColor(0.7).html
-ANSWER_COUNTER_EXPECTED_MAXIMUM = 4
-COLORS_ANSWER_COUNTER_EMPTY_BG = Color.NewFromHtml('#a40000').Blend(Color.NewFromHtml('white'),0.8).html
-COLORS_ANSWER_COUNTER_EMPTY_FG = 'yellow'
-COLORS_ANSWER_COUNTER_MIN_BG = '#AEB404'#'#81F7F3'#'#A9D0F5'#'#045FB4'
-COLORS_ANSWER_COUNTER_MIN_FG = 'white'#'#81F7F3'
-COLORS_ANSWER_COUNTER_MAX_BG = Color.NewFromHtml('#61380B').Blend(Color.NewFromHtml('white'),0.75).html
-COLORS_ANSWER_COUNTER_MAX_FG = '#ffff00'
-COLORS_ANSWER_COUNTER_ACCEPTED_BG = Color.NewFromHtml('darkgreen').Blend(Color.NewFromHtml('white'),0.8).html
-COLORS_ANSWER_COUNTER_ACCEPTED_FG = '#D0F5A9'
+#Do not use these - will be phased out
+USE_EXTERNAL_LEGACY_LOGIN = False
+EXTERNAL_LEGACY_LOGIN_HOST = 'login.askbot.net'
+EXTERNAL_LEGACY_LOGIN_PORT = 80
+EXTERNAL_LEGACY_LOGIN_PROVIDER_NAME = '<span class="orange">ASKBOT</span>'
+
+#SPHINX SETTINGS
+USE_SPHINX_SEARCH = False #if True all SPHINX_* settings are required
+#also sphinx search engine and djangosphinxs app must be installed
+#sample sphinx configuration file is /sphinx/sphinx.conf
+SPHINX_API_VERSION = 0x113 #refer to djangosphinx documentation
+SPHINX_SEARCH_INDICES=('askbot',) #a tuple of index names remember about a comma after the
+#last item, especially if you have just one :)
+SPHINX_SERVER='localhost'
+SPHINX_PORT=3312