Exemple #1
0
    def __init__(self, workflow, *args, **kwargs):
        super(NewWorkflowForm, self).__init__(*args, **kwargs)
        self.instance = workflow
        # Creation of pair of lists of lists for development and done
        lists = workflow.board.lists.all().order_by("id")
        num_lists = lists.count()
        list_position = {lists[i].id: i + 1 for i in range(0, num_lists)}
        list_choices = [("empty", "Empty")] + [(list_.id, list_.name)
                                               for list_ in lists]

        # Development lists
        for list_i in range(0, num_lists):
            development_list_name_i = "development_list_{0}".format(list_i)
            self.fields[development_list_name_i] = models.ChoiceField(
                choices=list_choices,
                initial="empty",
                label=u"'Development' list in position {0}".format(list_i))
            # In case we are editing, get default value of the select of the lists
            if workflow.workflow_lists.filter(order=list_i,
                                              is_done_list=False).exists():
                list_id_in_position_i = workflow.workflow_lists.get(
                    order=list_i, is_done_list=False).list_id
                self.fields[development_list_name_i].initial = list_position[
                    list_id_in_position_i]

        # Done lists
        for list_i in range(0, num_lists):
            done_list_name_i = "done_list_{0}".format(list_i)
            self.fields[done_list_name_i] = models.ChoiceField(
                choices=list_choices,
                initial="empty",
                label=u"'Done' list in position {0}".format(list_i))

            if workflow.workflow_lists.filter(order=list_i,
                                              is_done_list=True).exists():
                list_id_in_position_i = workflow.workflow_lists.get(
                    order=list_i, is_done_list=True).list_id
                self.fields[done_list_name_i].initial = list_position[
                    list_id_in_position_i]
Exemple #2
0
    def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop("instance")
        self.member = kwargs.pop("member")
        super(SwapListForm, self).__init__(*args, **kwargs)
        lists = self.instance.board.lists.order_by("position")

        if lists.exists():
            self.fields["list_to_be_swapped_with"] = models.ChoiceField(
                label="Swap this list position with",
                choices=[(list_i.id, list_i.name) for list_i in lists],
                required=True
            )
            self.fields["list_to_be_swapped_with"].initial = self.instance.id
Exemple #3
0
class DeliveryForm(models.ModelForm):
    shipping_method = models.ChoiceField(
        label=_("Shipping by"),
        choices=get_shipping_choices,
    )

    class Meta:
        model = DeliveryModel
        exclude = []

    def has_changed(self):
        return True

    def clean_shipping_method(self):
        if not self.cleaned_data['shipping_method']:
            return self.instance.shipping_method
        return self.cleaned_data['shipping_method']
Exemple #4
0
class YogaCreategForm(forms.Form):
    level_form = models_fields.ChoiceField(choices=[(1,"Junior"),(2,'Middle'),(3,'Senior')])
    title_form = models_fields.ModelChoiceField(queryset=Yoga.objects.all(),
                                                empty_label='请选择对应瑜伽动作名称',
                                                to_field_name='title')
Exemple #5
0
 def _define_choicefield(self, item, required, tname, lang):
     return models.ChoiceField(
         label=f"{tname}",
         required=False,
         widget=forms.Select(attrs={"class": "treq" if required else ""}),
         choices=self._get_thesauro_keyword_label(item, lang))
Exemple #6
0
 def _define_choicefield(self, item, required, tname, lang):
     return models.ChoiceField(label=f"{tname}",
                               required=required,
                               choices=self._get_thesauro_keyword_label(
                                   item, lang))