-__all__ = ['admin','auth','const','feed','forms','managers','models','sitemap','urls','views']
+
+++ /dev/null
-# encoding:utf-8
-from django.utils.translation import ugettext as _
-"""
-All constants could be used in other modules
-For reasons that models, views can't have unicode text in this project, all unicode text go here.
-"""
-CLOSE_REASONS = (
- (1, _('duplicate question')),
- (2, _('question is off-topic or not relevant')),
- (3, _('too subjective and argumentative')),
- (4, _('is not an answer to the question')),
- (5, _('the question is answered, right answer was accepted')),
- (6, _('problem is not reproducible or outdated')),
- (7, _('question contains offensive inappropriate, or malicious remarks')),
- (8, _('spam or advertising')),
-)
-
-TYPE_REPUTATION_GAIN_BY_UPVOTED = 1
-TYPE_REPUTATION_GAIN_BY_ANSWER_ACCEPTED = 2
-TYPE_REPUTATION_GAIN_BY_ACCEPTING_ANSWER = 3
-TYPE_REPUTATION_GAIN_BY_DOWNVOTE_CANCELED = 4
-TYPE_REPUTATION_GAIN_BY_CANCELING_DOWNVOTE = 5
-TYPE_REPUTATION_LOST_BY_CANCELLING_ACCEPTED_ANSWER = -1
-TYPE_REPUTATION_LOST_BY_ACCEPTED_ANSWER_CANCELED = -2
-TYPE_REPUTATION_LOST_BY_DOWNVOTED = -3
-TYPE_REPUTATION_LOST_BY_FLAGGED = -4
-TYPE_REPUTATION_LOST_BY_DOWNVOTING = -5
-TYPE_REPUTATION_LOST_BY_FLAGGED_3_TIMES = -6
-TYPE_REPUTATION_LOST_BY_FLAGGED_5_TIMES = -7
-TYPE_REPUTATION_LOST_BY_UPVOTE_CANCELED = -8
-
-TYPE_REPUTATION = (
- (TYPE_REPUTATION_GAIN_BY_UPVOTED, 'gain_by_upvoted'),
- (TYPE_REPUTATION_GAIN_BY_ANSWER_ACCEPTED, 'gain_by_answer_accepted'),
- (TYPE_REPUTATION_GAIN_BY_ACCEPTING_ANSWER, 'gain_by_accepting_answer'),
- (TYPE_REPUTATION_GAIN_BY_DOWNVOTE_CANCELED, 'gain_by_downvote_canceled'),
- (TYPE_REPUTATION_GAIN_BY_CANCELING_DOWNVOTE, 'gain_by_canceling_downvote'),
- (TYPE_REPUTATION_LOST_BY_CANCELLING_ACCEPTED_ANSWER, 'lose_by_canceling_accepted_answer'),
- (TYPE_REPUTATION_LOST_BY_ACCEPTED_ANSWER_CANCELED, 'lose_by_accepted_answer_cancled'),
- (TYPE_REPUTATION_LOST_BY_DOWNVOTED, 'lose_by_downvoted'),
- (TYPE_REPUTATION_LOST_BY_FLAGGED, 'lose_by_flagged'),
- (TYPE_REPUTATION_LOST_BY_DOWNVOTING, 'lose_by_downvoting'),
- (TYPE_REPUTATION_LOST_BY_FLAGGED_3_TIMES, 'lose_by_flagged_lastrevision_3_times'),
- (TYPE_REPUTATION_LOST_BY_FLAGGED_5_TIMES, 'lose_by_flagged_lastrevision_5_times'),
- (TYPE_REPUTATION_LOST_BY_UPVOTE_CANCELED, 'lose_by_upvote_canceled'),
-)
-
-TYPE_ACTIVITY_ASK_QUESTION=1
-TYPE_ACTIVITY_ANSWER=2
-TYPE_ACTIVITY_COMMENT_QUESTION=3
-TYPE_ACTIVITY_COMMENT_ANSWER=4
-TYPE_ACTIVITY_UPDATE_QUESTION=5
-TYPE_ACTIVITY_UPDATE_ANSWER=6
-TYPE_ACTIVITY_PRIZE=7
-TYPE_ACTIVITY_MARK_ANSWER=8
-TYPE_ACTIVITY_VOTE_UP=9
-TYPE_ACTIVITY_VOTE_DOWN=10
-TYPE_ACTIVITY_CANCEL_VOTE_UP=11
-TYPE_ACTIVITY_CANCEL_VOTE_DOWN=19
-TYPE_ACTIVITY_DELETE_QUESTION=12
-TYPE_ACTIVITY_DELETE_ANSWER=13
-TYPE_ACTIVITY_MARK_OFFENSIVE=14
-TYPE_ACTIVITY_UPDATE_TAGS=15
-TYPE_ACTIVITY_FAVORITE=16
-TYPE_ACTIVITY_USER_FULL_UPDATED = 17
-TYPE_ACTIVITY_QUESTION_EMAIL_UPDATE_SENT = 18
-#TYPE_ACTIVITY_EDIT_QUESTION=17
-#TYPE_ACTIVITY_EDIT_ANSWER=18
-
-TYPE_ACTIVITY = (
- (TYPE_ACTIVITY_ASK_QUESTION, _('question')),
- (TYPE_ACTIVITY_ANSWER, _('answer')),
- (TYPE_ACTIVITY_COMMENT_QUESTION, _('commented question')),
- (TYPE_ACTIVITY_COMMENT_ANSWER, _('commented answer')),
- (TYPE_ACTIVITY_UPDATE_QUESTION, _('edited question')),
- (TYPE_ACTIVITY_UPDATE_ANSWER, _('edited answer')),
- (TYPE_ACTIVITY_PRIZE, _('received award')),
- (TYPE_ACTIVITY_MARK_ANSWER, _('marked best answer')),
- (TYPE_ACTIVITY_VOTE_UP, _('upvoted')),
- (TYPE_ACTIVITY_VOTE_DOWN, _('downvoted')),
- (TYPE_ACTIVITY_CANCEL_VOTE_UP, _('upvote canceled')),
- (TYPE_ACTIVITY_CANCEL_VOTE_DOWN, _('downvote canceled')),
- (TYPE_ACTIVITY_DELETE_QUESTION, _('deleted question')),
- (TYPE_ACTIVITY_DELETE_ANSWER, _('deleted answer')),
- (TYPE_ACTIVITY_MARK_OFFENSIVE, _('marked offensive')),
- (TYPE_ACTIVITY_UPDATE_TAGS, _('updated tags')),
- (TYPE_ACTIVITY_FAVORITE, _('selected favorite')),
- (TYPE_ACTIVITY_USER_FULL_UPDATED, _('completed user profile')),
- (TYPE_ACTIVITY_QUESTION_EMAIL_UPDATE_SENT, _('email update sent to user')),
-)
-
-TYPE_RESPONSE = {
- 'QUESTION_ANSWERED' : _('question_answered'),
- 'QUESTION_COMMENTED': _('question_commented'),
- 'ANSWER_COMMENTED' : _('answer_commented'),
- 'ANSWER_ACCEPTED' : _('answer_accepted'),
-}
-
-CONST = {
- 'closed' : _('[closed]'),
- 'deleted' : _('[deleted]'),
- 'default_version' : _('initial version'),
- 'retagged' : _('retagged'),
-}
-
-BRONZE_BADGE = 3
-SILVER_BADGE = 2
-GOLD_BADGE = 1
-
-NOTIFICATION_CHOICES = (
- ('i', _('Instantly')),
- ('d', _('Daily')),
- ('w', _('Weekly')),
- ('n', _('No notifications')),
-)
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
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
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
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)
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):
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):
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):
from base import *\r
-from forum import const\r
from django.contrib.contenttypes.models import ContentType\r
from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser\r
from django.db.models import Q\r
\r
def get_reputation_by_upvoted_today(self):\r
today = datetime.datetime.now()\r
- sum = self.reputes.filter(\r
- models.Q(reputation_type=TYPE_REPUTATION_GAIN_BY_UPVOTED) |\r
- models.Q(reputation_type=TYPE_REPUTATION_LOST_BY_UPVOTE_CANCELED),\r
- reputed_at__range=(today - datetime.timedelta(days=1), today)).aggregate(models.Sum('value'))\r
-\r
- if sum.get('value__sum', None) is not None: return sum['value__sum']\r
+ sum = self.reputes.filter(reputed_at__range=(today - datetime.timedelta(days=1), today)).aggregate(models.Sum('value'))\r
+ #todo: redo this, maybe transform in the daily cap\r
+ #if sum.get('value__sum', None) is not None: return sum['value__sum']\r
return 0\r
\r
def get_flagged_items_count_today(self):\r
enable_notifications = models.BooleanField(default=True)\r
\r
#notify if\r
- member_joins = models.CharField(max_length=1, default='n', choices=const.NOTIFICATION_CHOICES)\r
- new_question = models.CharField(max_length=1, default='d', choices=const.NOTIFICATION_CHOICES)\r
- new_question_watched_tags = models.CharField(max_length=1, default='i', choices=const.NOTIFICATION_CHOICES)\r
- subscribed_questions = models.CharField(max_length=1, default='i', choices=const.NOTIFICATION_CHOICES)\r
+ member_joins = models.CharField(max_length=1, default='n')\r
+ new_question = models.CharField(max_length=1, default='d')\r
+ new_question_watched_tags = models.CharField(max_length=1, default='i')\r
+ subscribed_questions = models.CharField(max_length=1, default='i')\r
\r
#auto_subscribe_to\r
all_questions = models.BooleanField(default=False)\r
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**
Setting.sets[set.name].append(self)
+ def __str__(self):
+ return str(self.value)
+
def __unicode__(self):
return unicode(self.value)
help_text = _("Your site favicon."),\r
widget=ImageFormWidget))\r
\r
-APP_TITLE = Setting('APP_TITLE', 'OSQA: Open Source Q&A Forum', BASIC_SET, dict(\r
+APP_TITLE = Setting('APP_TITLE', u'OSQA: Open Source Q&A Forum', BASIC_SET, dict(\r
label = _("Application title"),\r
help_text = _("The title of your application that will show in the browsers title bar")))\r
\r
-APP_SHORT_NAME = Setting('APP_SHORT_NAME', 'OSQA', BASIC_SET, dict(\r
+APP_SHORT_NAME = Setting(u'APP_SHORT_NAME', 'OSQA', BASIC_SET, dict(\r
label = _("Application short name"),\r
help_text = "The short name for your application that will show up in many places."))\r
\r
-APP_KEYWORDS = Setting('APP_KEYWORDS', 'OSQA,CNPROG,forum,community', BASIC_SET, dict(\r
+APP_KEYWORDS = Setting('APP_KEYWORDS', u'OSQA,CNPROG,forum,community', BASIC_SET, dict(\r
label = _("Application keywords"),\r
help_text = _("The meta keywords that will be available through the HTML meta tags.")))\r
\r
-APP_DESCRIPTION = Setting('APP_DESCRIPTION', 'Ask and answer questions.', BASIC_SET, dict(\r
+APP_DESCRIPTION = Setting('APP_DESCRIPTION', u'Ask and answer questions.', BASIC_SET, dict(\r
label = _("Application description"),\r
help_text = _("The description of your application"),\r
widget=Textarea))\r
\r
-APP_INTRO = Setting('APP_INTRO', '<p>Ask and answer questions, make the world better!</p>', BASIC_SET, dict(\r
+APP_INTRO = Setting('APP_INTRO', u'<p>Ask and answer questions, make the world better!</p>', BASIC_SET, dict(\r
label = _("Application intro"),\r
help_text = _("The introductory page that is visible in the sidebar for anonymous users."),\r
widget=Textarea))\r
\r
-APP_COPYRIGHT = Setting('APP_COPYRIGHT', 'Copyright OSQA, 2010. Some rights reserved under creative commons license.', BASIC_SET, dict(\r
+APP_COPYRIGHT = Setting('APP_COPYRIGHT', u'Copyright OSQA, 2010. Some rights reserved under creative commons license.', BASIC_SET, dict(\r
label = _("Copyright notice"),\r
help_text = _("The copyright notice visible at the footer of your page.")))
\ No newline at end of file
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)**
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
from django import template\r
from django.utils.translation import ugettext as _\r
from django.utils.safestring import mark_safe\r
-from forum import const\r
\r
register = template.Library()\r
\r
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):
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))
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
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
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
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:
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',]
ADMINS = (('Forum Admin', 'forum@example.com'),)
MANAGERS = ADMINS
-DEBUG = True
+DEBUG = False
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': True
}