Skip to content

Commit

Permalink
Fix on error with decoding settings from database. Ans dome other stuff.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@172 0cfe37f9-358a-4d5e-be75-b63607b5c754
  • Loading branch information
hernani committed May 8, 2010
1 parent 08dbd72 commit 87e592d
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 158 deletions.
2 changes: 1 addition & 1 deletion forum/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__all__ = ['admin','auth','const','feed','forms','managers','models','sitemap','urls','views']

115 changes: 0 additions & 115 deletions forum/const.py

This file was deleted.

2 changes: 1 addition & 1 deletion forum/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from models import Question
from django.conf import settings
class RssLastestQuestionsFeed(Feed):
title = str(settings.APP_TITLE) + _(' - ')+ _('latest questions')
title = settings.APP_TITLE + _(' - ')+ _('latest questions')
link = settings.APP_URL #+ '/' + _('question/')
description = settings.APP_DESCRIPTION
#ttl = 10
Expand Down
10 changes: 6 additions & 4 deletions forum/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from datetime import date
from django import forms
from models import *
from const import *
from django.utils.translation import ugettext as _
from django.contrib.humanize.templatetags.humanize import apnumber
from forum.models import User
Expand Down Expand Up @@ -130,9 +129,6 @@ def __init__(self, question, *args, **kwargs):
self.fields['wiki'].initial = True


class CloseForm(forms.Form):
reason = forms.ChoiceField(choices=CLOSE_REASONS)

class RetagQuestionForm(forms.Form):
tags = TagNamesField()
# initialize the default values
Expand Down Expand Up @@ -233,6 +229,12 @@ def clean_email(self):
raise forms.ValidationError(_('this email has already been registered, please use another one'))
return self.cleaned_data['email']

NOTIFICATION_CHOICES = (
('i', _('Instantly')),
('d', _('Daily')),
('w', _('Weekly')),
('n', _('No notifications')),
)

class SubscriptionSettingsForm(forms.Form):
member_joins = forms.ChoiceField(widget=forms.RadioSelect, choices=NOTIFICATION_CHOICES)
Expand Down
1 change: 0 additions & 1 deletion forum/management/commands/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from django.contrib.contenttypes.models import ContentType

from forum.models import *
from forum.const import *

class BaseCommand(NoArgsCommand):
def update_activities_auditted(self, cursor, activity_ids):
Expand Down
1 change: 0 additions & 1 deletion forum/management/commands/send_email_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.conf import settings
from forum.models import KeyValue, Activity, User, QuestionSubscription
from forum.utils.mail import send_email
from forum import const

class QuestionRecord:
def __init__(self, question):
Expand Down
2 changes: 0 additions & 2 deletions forum/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
from django.contrib.sitemaps import ping_google
import django.dispatch
from django.conf import settings
from forum import const
import logging

from forum.const import *

class LazyQueryList(object):
def __init__(self, model, items):
Expand Down
18 changes: 7 additions & 11 deletions forum/models/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from base import *
from forum import const
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser
from django.db.models import Q
Expand Down Expand Up @@ -151,12 +150,9 @@ def get_vote_count_today(self):

def get_reputation_by_upvoted_today(self):
today = datetime.datetime.now()
sum = self.reputes.filter(
models.Q(reputation_type=TYPE_REPUTATION_GAIN_BY_UPVOTED) |
models.Q(reputation_type=TYPE_REPUTATION_LOST_BY_UPVOTE_CANCELED),
reputed_at__range=(today - datetime.timedelta(days=1), today)).aggregate(models.Sum('value'))

if sum.get('value__sum', None) is not None: return sum['value__sum']
sum = self.reputes.filter(reputed_at__range=(today - datetime.timedelta(days=1), today)).aggregate(models.Sum('value'))
#todo: redo this, maybe transform in the daily cap
#if sum.get('value__sum', None) is not None: return sum['value__sum']
return 0

def get_flagged_items_count_today(self):
Expand Down Expand Up @@ -248,10 +244,10 @@ class SubscriptionSettings(models.Model):
enable_notifications = models.BooleanField(default=True)

#notify if
member_joins = models.CharField(max_length=1, default='n', choices=const.NOTIFICATION_CHOICES)
new_question = models.CharField(max_length=1, default='d', choices=const.NOTIFICATION_CHOICES)
new_question_watched_tags = models.CharField(max_length=1, default='i', choices=const.NOTIFICATION_CHOICES)
subscribed_questions = models.CharField(max_length=1, default='i', choices=const.NOTIFICATION_CHOICES)
member_joins = models.CharField(max_length=1, default='n')
new_question = models.CharField(max_length=1, default='d')
new_question_watched_tags = models.CharField(max_length=1, default='i')
subscribed_questions = models.CharField(max_length=1, default='i')

#auto_subscribe_to
all_questions = models.BooleanField(default=False)
Expand Down
2 changes: 1 addition & 1 deletion forum/settings/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PAGES_SET = SettingSet('about', 'About page', "Define the text in the about page. You can use markdown and some basic html tags.", 2000, True)

ABOUT_PAGE_TEXT = Setting('ABOUT_PAGE_TEXT',
"""
u"""
**Please customize this text in the administration area**
Here you can **ask** and **answer** questions, **comment**
Expand Down
3 changes: 3 additions & 0 deletions forum/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self, name, default, set=None, field_context=None):

Setting.sets[set.name].append(self)

def __str__(self):
return str(self.value)

def __unicode__(self):
return unicode(self.value)

Expand Down
12 changes: 6 additions & 6 deletions forum/settings/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
help_text = _("Your site favicon."),
widget=ImageFormWidget))

APP_TITLE = Setting('APP_TITLE', 'OSQA: Open Source Q&A Forum', BASIC_SET, dict(
APP_TITLE = Setting('APP_TITLE', u'OSQA: Open Source Q&A Forum', BASIC_SET, dict(
label = _("Application title"),
help_text = _("The title of your application that will show in the browsers title bar")))

APP_SHORT_NAME = Setting('APP_SHORT_NAME', 'OSQA', BASIC_SET, dict(
APP_SHORT_NAME = Setting(u'APP_SHORT_NAME', 'OSQA', BASIC_SET, dict(
label = _("Application short name"),
help_text = "The short name for your application that will show up in many places."))

APP_KEYWORDS = Setting('APP_KEYWORDS', 'OSQA,CNPROG,forum,community', BASIC_SET, dict(
APP_KEYWORDS = Setting('APP_KEYWORDS', u'OSQA,CNPROG,forum,community', BASIC_SET, dict(
label = _("Application keywords"),
help_text = _("The meta keywords that will be available through the HTML meta tags.")))

APP_DESCRIPTION = Setting('APP_DESCRIPTION', 'Ask and answer questions.', BASIC_SET, dict(
APP_DESCRIPTION = Setting('APP_DESCRIPTION', u'Ask and answer questions.', BASIC_SET, dict(
label = _("Application description"),
help_text = _("The description of your application"),
widget=Textarea))

APP_INTRO = Setting('APP_INTRO', '<p>Ask and answer questions, make the world better!</p>', BASIC_SET, dict(
APP_INTRO = Setting('APP_INTRO', u'<p>Ask and answer questions, make the world better!</p>', BASIC_SET, dict(
label = _("Application intro"),
help_text = _("The introductory page that is visible in the sidebar for anonymous users."),
widget=Textarea))

APP_COPYRIGHT = Setting('APP_COPYRIGHT', 'Copyright OSQA, 2010. Some rights reserved under creative commons license.', BASIC_SET, dict(
APP_COPYRIGHT = Setting('APP_COPYRIGHT', u'Copyright OSQA, 2010. Some rights reserved under creative commons license.', BASIC_SET, dict(
label = _("Copyright notice"),
help_text = _("The copyright notice visible at the footer of your page.")))
2 changes: 1 addition & 1 deletion forum/settings/faq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
FAQ_SET = SettingSet('faq', 'FAQ page', "Define the text in the about page. You can use markdown and some basic html tags.", 2000, True)

FAQ_PAGE_TEXT = Setting('FAQ_PAGE_TEXT',
"""
u"""
**Please customize this text in the administration area**
**Frequently Asked Questions (FAQ)**
Expand Down
1 change: 0 additions & 1 deletion forum/templatetags/extra_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from django import template
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from forum.const import *
from forum.models import Question, Answer, QuestionRevision, AnswerRevision, NodeRevision
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
Expand Down
1 change: 0 additions & 1 deletion forum/templatetags/user_tags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django import template
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from forum import const

register = template.Library()

Expand Down
3 changes: 1 addition & 2 deletions forum/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from forum.settings.forms import SettingsSetForm

from forum.models import Question, Answer, User, Node, Action
from forum import const
from forum import settings

def super_user_required(fn):
Expand All @@ -27,7 +26,7 @@ def wrapper(request, *args, **kwargs):
def index(request):
return render_to_response('osqaadmin/index.html', {
'sets': get_all_sets(),
'settings_pack': str(settings.SETTINGS_PACK),
'settings_pack': unicode(settings.SETTINGS_PACK),
'statistics': get_statistics(),
'recent_activity': get_recent_activity(),
}, context_instance=RequestContext(request))
Expand Down
1 change: 0 additions & 1 deletion forum/views/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.utils.translation import ungettext, ugettext as _
from django.template import RequestContext
from forum.models import *
from forum.forms import CloseForm
from forum.actions import *
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
Expand Down
1 change: 0 additions & 1 deletion forum/views/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from forum.utils.diff import textDiff as htmldiff
from forum.forms import *
from forum.models import *
from forum.const import *
from forum.utils.forms import get_next_url
from forum.actions import QuestionViewAction
from forum.modules.decorators import decoratable
Expand Down
2 changes: 0 additions & 2 deletions forum/views/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from forum.actions import AskAction, AnswerAction, ReviseAction, RollbackAction, RetagAction
from forum.forms import *
from forum.models import *
from forum.const import *
from forum.utils.forms import get_next_url
from forum.views.commands import SpamNotAllowedException

Expand All @@ -29,7 +28,6 @@ class FileSizeNotAllow(Exception):
class UploadPermissionNotAuthorized(Exception):
pass

#<result><msg><![CDATA[%s]]></msg><error><![CDATA[%s]]></error><file_url>%s</file_url></result>
xml_template = "<result><msg><![CDATA[%s]]></msg><error><![CDATA[%s]]></error><file_url>%s</file_url></result>"

try:
Expand Down
11 changes: 6 additions & 5 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@
except:
pass

try:
import rosetta
INSTALLED_APPS.append('rosetta')
except:
pass
if not DEBUG:
try:
import rosetta
INSTALLED_APPS.append('rosetta')
except:
pass

AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]
2 changes: 1 addition & 1 deletion settings_local.py.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ logging.basicConfig(
ADMINS = (('Forum Admin', '[email protected]'),)
MANAGERS = ADMINS

DEBUG = True
DEBUG = False
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': True
}
Expand Down

0 comments on commit 87e592d

Please sign in to comment.