|
@@ -2,7 +2,7 @@ from django.utils.translation import ugettext_lazy as _
|
|
import floppyforms as forms
|
|
import floppyforms as forms
|
|
from misago.conf import settings
|
|
from misago.conf import settings
|
|
from misago.forms import Form, ForumChoiceField
|
|
from misago.forms import Form, ForumChoiceField
|
|
-from misago.models import Forum
|
|
|
|
|
|
+from misago.models import Forum, Poll
|
|
from misago.validators import validate_sluggable
|
|
from misago.validators import validate_sluggable
|
|
from misago.apps.threadtype.mixins import ValidateThreadNameMixin
|
|
from misago.apps.threadtype.mixins import ValidateThreadNameMixin
|
|
|
|
|
|
@@ -14,9 +14,9 @@ class MoveThreadsForm(Form):
|
|
super(MoveThreadsForm, self).__init__(data, request=request, *args, **kwargs)
|
|
super(MoveThreadsForm, self).__init__(data, request=request, *args, **kwargs)
|
|
|
|
|
|
def finalize_form(self):
|
|
def finalize_form(self):
|
|
- self.fields['new_forum'] = ForumChoiceField(label=_("Move Threads to"),
|
|
|
|
- help_text=_("Select forum you want to move threads to."),
|
|
|
|
- queryset=Forum.objects.get(special='root').get_descendants().filter(pk__in=self.request.acl.forums.acl['can_browse']))
|
|
|
|
|
|
+ self.add_field('new_forum', ForumChoiceField(label=_("Move Threads to"),
|
|
|
|
+ help_text=_("Select forum you want to move threads to."),
|
|
|
|
+ queryset=Forum.objects.get(special='root').get_descendants().filter(pk__in=self.request.acl.forums.acl['can_browse'])))
|
|
|
|
|
|
def clean_new_forum(self):
|
|
def clean_new_forum(self):
|
|
new_forum = self.cleaned_data['new_forum']
|
|
new_forum = self.cleaned_data['new_forum']
|
|
@@ -34,18 +34,30 @@ class MergeThreadsForm(Form, ValidateThreadNameMixin):
|
|
super(MergeThreadsForm, self).__init__(data, request=request, *args, **kwargs)
|
|
super(MergeThreadsForm, self).__init__(data, request=request, *args, **kwargs)
|
|
|
|
|
|
def finalize_form(self):
|
|
def finalize_form(self):
|
|
- self.fields['new_forum'] = ForumChoiceField(label=_("Thread Forum"),
|
|
|
|
- help_text=_("Select forum you want to put new thread in."),
|
|
|
|
- queryset=Forum.objects.get(special='root').get_descendants().filter(pk__in=self.request.acl.forums.acl['can_browse']),
|
|
|
|
- initial=self.threads[0].forum)
|
|
|
|
- self.fields['thread_name'] = forms.CharField(label=_("Thread Name"),
|
|
|
|
- help_text=_("Name of new thread that will be created as result of merge."),
|
|
|
|
- max_length=settings.thread_name_max,
|
|
|
|
- initial=self.threads[-1].name,
|
|
|
|
- validators=[validate_sluggable(
|
|
|
|
- _("Thread name must contain at least one alpha-numeric character."),
|
|
|
|
- _("Thread name is too long. Try shorter name.")
|
|
|
|
- )])
|
|
|
|
|
|
+ choices = [(0, _("Don't use any polls"))]
|
|
|
|
+ for thread in self.threads:
|
|
|
|
+ if thread.has_poll:
|
|
|
|
+ choices.append((thread.pk, thread.name))
|
|
|
|
+
|
|
|
|
+ if len(choices) > 2:
|
|
|
|
+ self.add_field('final_poll', forms.TypedChoiceField(label=_("Final Poll"),
|
|
|
|
+ help_text=_("More than one of threads that you are going to merge has poll. Select poll that will be used in merged thread of delete all polls."),
|
|
|
|
+ choices=choices,
|
|
|
|
+ coerce=int,
|
|
|
|
+ initial=choices[1][0]))
|
|
|
|
+
|
|
|
|
+ self.add_field('new_forum', ForumChoiceField(label=_("Thread Forum"),
|
|
|
|
+ help_text=_("Select forum you want to put new thread in."),
|
|
|
|
+ queryset=Forum.objects.get(special='root').get_descendants().filter(pk__in=self.request.acl.forums.acl['can_browse']),
|
|
|
|
+ initial=self.threads[0].forum))
|
|
|
|
+ self.add_field('thread_name', forms.CharField(label=_("Thread Name"),
|
|
|
|
+ help_text=_("Name of new thread that will be created as result of merge."),
|
|
|
|
+ max_length=settings.thread_name_max,
|
|
|
|
+ initial=self.threads[-1].name,
|
|
|
|
+ validators=[validate_sluggable(
|
|
|
|
+ _("Thread name must contain at least one alpha-numeric character."),
|
|
|
|
+ _("Thread name is too long. Try shorter name.")
|
|
|
|
+ )]))
|
|
|
|
|
|
def clean_new_forum(self):
|
|
def clean_new_forum(self):
|
|
new_forum = self.cleaned_data['new_forum']
|
|
new_forum = self.cleaned_data['new_forum']
|