from django.utils.safestring import mark_safe
from general import NextUrlField, UserNameField, SetPasswordForm
from forum import settings
-
-#from forum_modules.recaptcha.formfield import ReCaptchaField
-
import logging
class TitleField(forms.CharField):
super(AskForm, self).__init__(data, *args, **kwargs)
self.fields['tags'] = TagNamesField(user)
-
- #if int(user.reputation) < settings.CAPTCHA_IF_REP_LESS_THAN and not (user.is_superuser or user.is_staff):
- # self.fields['captcha'] = ReCaptchaField()
if settings.WIKI_ON:
self.fields['wiki'] = WikiField()
text = AnswerEditorField()
wiki = WikiField()
- def __init__(self, data=None, user=None, *args, **kwargs):
- super(AnswerForm, self).__init__(data, *args, **kwargs)
-
- #if int(user.reputation) < settings.CAPTCHA_IF_REP_LESS_THAN and not (user.is_superuser or user.is_staff):
- # self.fields['captcha'] = ReCaptchaField()
+ def __init__(self, question, *args, **kwargs):
+ super(AnswerForm, self).__init__(*args, **kwargs)
if settings.WIKI_ON:
self.fields['wiki'] = WikiField()
+ #if question.nis.wiki:
+ # self.fields['wiki'].initial = True
+
+
class RetagQuestionForm(forms.Form):
tags = TagNamesField()
# initialize the default values
self.fields['tags'] = TagNamesField(user)
self.fields['tags'].initial = revision.tagnames
- #if int(user.reputation) < settings.CAPTCHA_IF_REP_LESS_THAN and not (user.is_superuser or user.is_staff):
- # self.fields['captcha'] = ReCaptchaField()
-
if settings.WIKI_ON:
self.fields['wiki'] = WikiField(disabled=(question.nis.wiki and not user.can_cancel_wiki(question)), initial=question.nis.wiki)
self.fields['text'].initial = revision.body
- #if int(user.reputation) < settings.CAPTCHA_IF_REP_LESS_THAN and not (user.is_superuser or user.is_staff):
- # self.fields['captcha'] = ReCaptchaField()
-
if settings.WIKI_ON:
self.fields['wiki'] = WikiField(disabled=(answer.nis.wiki and not user.can_cancel_wiki(answer)), initial=answer.nis.wiki)
\r
MIN_REP_SET = SettingSet('minrep', _('Minimum reputation config'), _("Configure the minimum reputation required to perform certain actions on your site."), 300)\r
\r
-#CAPTCHA_IF_REP_LESS_THAN = Setting('CAPTCHA_IF_REP_LESS_THAN', 0, MIN_REP_SET, dict(\r
-#label = _("Show captcha if user with less reputation than"),\r
-#help_text = _("If the user has less reputation, captcha is used to when adding new content.")))\r
-\r
REP_TO_VOTE_UP = Setting('REP_TO_VOTE_UP', 15, MIN_REP_SET, dict(\r
label = _("Minimum reputation to vote up"),\r
help_text = _("The minimum reputation an user must have to be allowed to vote up.")))\r
<div class="title-desc">
{{ form.summary.help_text }}
</div>
-
- {% if form.captcha %}
- <div class="question-captcha">
- {{ form.captcha.errors }}
- {{ form.captcha }}
- </div>
- {% endif %}
-
<input type="button" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event, this.form)" />
<input type="button" value="{% trans "Cancel" %}" class="submit" onclick="submitClicked(event, this.form);history.back(-1);" />
</form>
<p class="title-desc">
{{ form.tags.help_text }}
</p>
-
- {% if form.captcha %}
- <div class="question-captcha" style="float: left">
- {{ form.captcha.errors }}
- {{ form.captcha }}
- </div>
- <div class="clear"></div>
- {% endif %}
-
{% if not request.user.is_authenticated %}
<input name="ask" type="button" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event, this.form)"/>
{% else %}
{{ answer.text.errors }}\r
<div id="previewer" class="wmd-preview"></div> \r
</div>\r
- \r
- {% if answer.captcha %}\r
- <div class="question-captcha" style="float: left;">\r
- {{ answer.captcha.errors }}\r
- {{ answer.captcha }}\r
- </div>\r
- <div class="clear"></div>\r
- {% endif %}\r
- \r
<p><span class="form-error"></span></p>\r
<input type="button"\r
{% if user.is_anonymous %}\r
<div class="title-desc">
{{ form.summary.help_text }}
</div>
-
- {% if form.captcha %}
- <div class="question-captcha" style="float: left">
- {{ form.captcha.errors }}
- {{ form.captcha }}
- </div>
- <div class="clear"></div>
- {% endif %}
-
<div class="error" ></div>
<input type="button" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event, this.form)" />
<input type="button" value="{% trans "Cancel" %}" class="submit" onclick="submitClicked(event, null); history.back(-1);" />
return HttpResponsePermanentRedirect(question.get_absolute_url())
if request.POST:
- answer_form = AnswerForm(request.POST, user=request.user)
+ answer_form = AnswerForm(question, request.POST)
else:
- answer_form = AnswerForm(user=request.user)
+ answer_form = AnswerForm(question)
answers = request.user.get_visible_answers(question)
question = get_object_or_404(Question, id=id)
if request.POST:
- form = AnswerForm(request.POST, request.user)
+ form = AnswerForm(question, request.POST)
if request.session.pop('reviewing_pending_data', False) or not form.is_valid():
request.session['redirect_POST_data'] = request.POST
)
if 'rosetta' in settings.INSTALLED_APPS:
- urlpatterns = patterns('',
+ urlpatterns += patterns('',
url(r'^rosetta/', include('rosetta.urls')),
- ) + urlpatterns
+ )