return u' '.join(list_temp)
class WikiField(forms.BooleanField):
return u' '.join(list_temp)
class WikiField(forms.BooleanField):
- def __init__(self, *args, **kwargs):
+ def __init__(self, disabled=False, *args, **kwargs):
super(WikiField, self).__init__(*args, **kwargs)
self.required = False
self.label = _('community wiki')
self.help_text = _('if you choose community wiki option, the question and answer do not generate points and name of author will not be shown')
super(WikiField, self).__init__(*args, **kwargs)
self.required = False
self.label = _('community wiki')
self.help_text = _('if you choose community wiki option, the question and answer do not generate points and name of author will not be shown')
+ if disabled:
+ self.widget=forms.CheckboxInput(attrs={'disabled': "disabled"})
- return value and settings.WIKI_ON
class EmailNotifyField(forms.BooleanField):
def __init__(self, *args, **kwargs):
class EmailNotifyField(forms.BooleanField):
def __init__(self, *args, **kwargs):
title = TitleField()
text = QuestionEditorField()
tags = TagNamesField()
title = TitleField()
text = QuestionEditorField()
tags = TagNamesField()
+ def __init__(self, *args, **kwargs):
+ super(AskForm, self).__init__(*args, **kwargs)
+ if settings.WIKI_ON:
+ self.fields['wiki'] = WikiField()
class AnswerForm(forms.Form):
text = AnswerEditorField()
class AnswerForm(forms.Form):
text = AnswerEditorField()
def __init__(self, question, *args, **kwargs):
super(AnswerForm, self).__init__(*args, **kwargs)
def __init__(self, question, *args, **kwargs):
super(AnswerForm, self).__init__(*args, **kwargs)
- if question.nis.wiki and settings.WIKI_ON:
- self.fields['wiki'].initial = True
+ if settings.WIKI_ON:
+ self.fields['wiki'] = WikiField()
+
+ if question.nis.wiki:
+ self.fields['wiki'].initial = True
class RetagQuestionForm(forms.Form):
class RetagQuestionForm(forms.Form):
tags = TagNamesField()
summary = SummaryField()
tags = TagNamesField()
summary = SummaryField()
- def __init__(self, question, revision=None, *args, **kwargs):
+ def __init__(self, question, user, revision=None, *args, **kwargs):
super(EditQuestionForm, self).__init__(*args, **kwargs)
if revision is None:
super(EditQuestionForm, self).__init__(*args, **kwargs)
if revision is None:
self.fields['title'].initial = revision.title
self.fields['text'].initial = revision.body
self.fields['tags'].initial = revision.tagnames
self.fields['title'].initial = revision.title
self.fields['text'].initial = revision.body
self.fields['tags'].initial = revision.tagnames
-
- # Once wiki mode is enabled, it can't be disabled
- if settings.WIKI_ON and not question.nis.wiki:
- self.fields['wiki'] = WikiField()
+
+ if settings.WIKI_ON:
+ self.fields['wiki'] = WikiField(disabled=(question.nis.wiki and not user.can_cancel_wiki(question)), initial=question.nis.wiki)
class EditAnswerForm(forms.Form):
text = AnswerEditorField()
summary = SummaryField()
class EditAnswerForm(forms.Form):
text = AnswerEditorField()
summary = SummaryField()
- def __init__(self, answer, revision=None, *args, **kwargs):
+ def __init__(self, answer, user, revision=None, *args, **kwargs):
super(EditAnswerForm, self).__init__(*args, **kwargs)
if revision is None:
super(EditAnswerForm, self).__init__(*args, **kwargs)
if revision is None:
self.fields['text'].initial = revision.body
self.fields['text'].initial = revision.body
+ if settings.WIKI_ON:
+ self.fields['wiki'] = WikiField(disabled=(answer.nis.wiki and not user.can_cancel_wiki(answer)), initial=answer.nis.wiki)
+
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}))
realname = forms.CharField(label=_('Real name'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
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}))
realname = forms.CharField(label=_('Real name'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
def can_wikify(self, post):\r
return False\r
\r
def can_wikify(self, post):\r
return False\r
\r
+ def can_cancel_wiki(self, post):\r
+ return False\r
+\r
def can_retag_questions(self):\r
return False\r
\r
def can_retag_questions(self):\r
return False\r
\r
def can_wikify(self, post):\r
return self == post.author or self.reputation >= int(settings.REP_TO_WIKIFY)\r
\r
def can_wikify(self, post):\r
return self == post.author or self.reputation >= int(settings.REP_TO_WIKIFY)\r
\r
+ @true_if_is_super_or_staff\r
+ def can_cancel_wiki(self, post):\r
+ return self == post.author\r
+\r
@true_if_is_super_or_staff\r
def can_retag_questions(self):\r
return self.reputation >= int(settings.REP_TO_RETAG)\r
@true_if_is_super_or_staff\r
def can_retag_questions(self):\r
return self.reputation >= int(settings.REP_TO_RETAG)\r
color: #333;
background: url("../images/wiki.png") no-repeat left center;
padding-left: 36px;
color: #333;
background: url("../images/wiki.png") no-repeat left center;
padding-left: 36px;
min-height: 32px;
line-height: 15px;
}
min-height: 32px;
line-height: 15px;
}
color: #777777;
cursor: pointer;
padding: 3px;
}
color: #777777;
cursor: pointer;
padding: 3px;
}
+.action-link a {
+ color: inherit;
+}
+
.action-link a.ajax-command:hover {
background-color: #777777;
color: #FFFFFF;
.action-link a.ajax-command:hover {
background-color: #777777;
color: #FFFFFF;
{% endifnotequal %}\r
{% endfor %}\r
{% if menu|length %}\r
{% endifnotequal %}\r
{% endfor %}\r
{% if menu|length %}\r
- | <span id="node-{{ node.id }}-menu" class="context-menu">\r
- <span id="node-{{ node.id }}-menu-trigger" class="context-menu-trigger">{% trans "more" %} ▼</span>\r
+ <span class="action-link-separator">|</span>\r
+ <span id="node-{{ node.id }}-menu" class="context-menu">\r
+ <span id="node-{{ node.id }}-menu-trigger" class="action-link context-menu-trigger">{% trans "more" %} ▼</span>\r
<ul id="node-{{ node.id }}-menu-dropdown" class="context-menu-dropdown">\r
{% for item in menu %}\r
<li class="item"><a class="{{ item.classes }}" href="{{ item.url }}" title="{{ item.title }}" >{{ item.text }}</a></li>\r
<ul id="node-{{ node.id }}-menu-dropdown" class="context-menu-dropdown">\r
{% for item in menu %}\r
<li class="item"><a class="{{ item.classes }}" href="{{ item.url }}" title="{{ item.title }}" >{{ item.text }}</a></li>\r
</div>\r
<div class="answer-controls post-controls">\r
{% post_controls answer request.user %}\r
</div>\r
<div class="answer-controls post-controls">\r
{% post_controls answer request.user %}\r
+ {% wiki_symbol request.user answer %}\r
</div>\r
<div class="post-update-info-container">\r
{% contributors_info answer %}\r
</div>\r
<div class="post-update-info-container">\r
{% contributors_info answer %}\r
controls.append(post_control(_('delete'), reverse('delete_post', kwargs={'id': post.id}),\r
command=True, confirm=True))\r
\r
controls.append(post_control(_('delete'), reverse('delete_post', kwargs={'id': post.id}),\r
command=True, confirm=True))\r
\r
- if (not post.nis.wiki) and user.can_wikify(post):\r
- menu.append(post_control(_('mark as community wiki'), reverse('wikify', kwargs={'id': post.id}),\r
- command=True, confirm=True))\r
+ if settings.WIKI_ON:\r
+ if (not post.nis.wiki) and user.can_wikify(post):\r
+ menu.append(post_control(_('mark as community wiki'), reverse('wikify', kwargs={'id': post.id}),\r
+ command=True, confirm=True))\r
+\r
+ elif post.nis.wiki and user.can_cancel_wiki(post):\r
+ menu.append(post_control(_('cancel community wiki'), reverse('wikify', kwargs={'id': post.id}),\r
+ command=True, confirm=True))\r
\r
if post.node_type == "answer" and user.can_convert_to_comment(post):\r
menu.append(post_control(_('convert to comment'), reverse('convert_to_comment', kwargs={'id': post.id}),\r
\r
if post.node_type == "answer" and user.can_convert_to_comment(post):\r
menu.append(post_control(_('convert to comment'), reverse('convert_to_comment', kwargs={'id': post.id}),\r
@command
def wikify(request, id):
node = get_object_or_404(Node, id=id)
@command
def wikify(request, id):
node = get_object_or_404(Node, id=id)
-
- if node.nis.wiki:
- raise CommandException(_("This post is already marked as community wiky."))
-
user = request.user
if not user.is_authenticated():
raise AnonymousNotAllowedException(_('mark posts as community wiki'))
user = request.user
if not user.is_authenticated():
raise AnonymousNotAllowedException(_('mark posts as community wiki'))
- if not user.can_wikify(node):
- raise NotEnoughRepPointsException(_('mark posts as community wiki'))
+ if node.nis.wiki:
+ if not user.can_cancel_wiki(node):
+ raise NotEnoughRepPointsException(_('cancel a community wiki post'))
+
+ if node.nstate.wiki.action_type == "wikify":
+ node.nstate.wiki.cancel()
+ else:
+ node.nstate.wiki = None
+ else:
+ if not user.can_wikify(node):
+ raise NotEnoughRepPointsException(_('mark posts as community wiki'))
- WikifyAction(node=node, user=user, ip=request.META['REMOTE_ADDR']).save()
+ WikifyAction(node=node, user=user, ip=request.META['REMOTE_ADDR']).save()
form = AskForm(request.POST)
if form.is_valid():
if request.user.is_authenticated():
form = AskForm(request.POST)
if form.is_valid():
if request.user.is_authenticated():
- question = AskAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data).node
+ ask_action = AskAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
+ question = ask_action.node
+
+ if settings.WIKI_ON and request.POST.get('wiki', False):
+ question.nstate.wiki = ask_action
+
return HttpResponseRedirect(question.get_absolute_url())
else:
request.session['temp_node_data'] = request.POST
return HttpResponseRedirect(question.get_absolute_url())
else:
request.session['temp_node_data'] = request.POST
revision = question.revisions.get(revision=revision_form.cleaned_data['revision'])
if 'select_revision' in request.POST:
revision = question.revisions.get(revision=revision_form.cleaned_data['revision'])
if 'select_revision' in request.POST:
- form = EditQuestionForm(question, revision)
+ form = EditQuestionForm(question, request.user, revision)
- form = EditQuestionForm(question, revision, data=request.POST)
+ form = EditQuestionForm(question, request.user, revision, data=request.POST)
if not 'select_revision' in request.POST and form.is_valid():
if form.has_changed():
if not 'select_revision' in request.POST and form.is_valid():
if form.has_changed():
- ReviseAction(user=request.user, node=question, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
+ action = ReviseAction(user=request.user, node=question, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
+
+ if settings.WIKI_ON:
+ if request.POST.get('wiki', False) and not question.nis.wiki:
+ question.nstate.wiki = action
+ elif question.nis.wiki and (not request.POST.get('wiki', False)) and request.user.can_cancel_wiki(question):
+ question.nstate.wiki = None
else:
if not revision == question.active_revision:
RollbackAction(user=request.user, node=question).save(data=dict(activate=revision))
else:
if not revision == question.active_revision:
RollbackAction(user=request.user, node=question).save(data=dict(activate=revision))
return HttpResponseRedirect(question.get_absolute_url())
else:
revision_form = RevisionForm(question)
return HttpResponseRedirect(question.get_absolute_url())
else:
revision_form = RevisionForm(question)
- form = EditQuestionForm(question)
+ form = EditQuestionForm(question, request.user)
return render_to_response('question_edit.html', {
'question': question,
return render_to_response('question_edit.html', {
'question': question,
revision = answer.revisions.get(revision=revision_form.cleaned_data['revision'])
if 'select_revision' in request.POST:
revision = answer.revisions.get(revision=revision_form.cleaned_data['revision'])
if 'select_revision' in request.POST:
- form = EditAnswerForm(answer, revision)
+ form = EditAnswerForm(answer, request.user, revision)
- form = EditAnswerForm(answer, revision, data=request.POST)
+ form = EditAnswerForm(answer, request.user, revision, data=request.POST)
if not 'select_revision' in request.POST and form.is_valid():
if form.has_changed():
if not 'select_revision' in request.POST and form.is_valid():
if form.has_changed():
- ReviseAction(user=request.user, node=answer, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
+ action = ReviseAction(user=request.user, node=answer, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
+
+ if settings.WIKI_ON:
+ if request.POST.get('wiki', False) and not answer.nis.wiki:
+ answer.nstate.wiki = action
+ elif answer.nis.wiki and (not request.POST.get('wiki', False)) and request.user.can_cancel_wiki(answer):
+ answer.nstate.wiki = None
else:
if not revision == answer.active_revision:
RollbackAction(user=request.user, node=answer, ip=request.META['REMOTE_ADDR']).save(data=dict(activate=revision))
else:
if not revision == answer.active_revision:
RollbackAction(user=request.user, node=answer, ip=request.META['REMOTE_ADDR']).save(data=dict(activate=revision))
else:
revision_form = RevisionForm(answer)
else:
revision_form = RevisionForm(answer)
- form = EditAnswerForm(answer)
+ form = EditAnswerForm(answer, request.user)
return render_to_response('answer_edit.html', {
'answer': answer,
'revision_form': revision_form,
return render_to_response('answer_edit.html', {
'answer': answer,
'revision_form': revision_form,
form = AnswerForm(question, request.POST)
if form.is_valid():
if request.user.is_authenticated():
form = AnswerForm(question, request.POST)
if form.is_valid():
if request.user.is_authenticated():
- answer = AnswerAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(dict(question=question, **form.cleaned_data)).node
+ answer_action = AnswerAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(dict(question=question, **form.cleaned_data))
+ answer = answer_action.node
+
+ if settings.WIKI_ON and request.POST.get('wiki', False):
+ answer.nstate.wiki = answer_action
+
return HttpResponseRedirect(answer.get_absolute_url())
else:
request.session['temp_node_data'] = request.POST
return HttpResponseRedirect(answer.get_absolute_url())
else:
request.session['temp_node_data'] = request.POST