Ejemplo n.º 1
0
 class Meta:
     model = Estabelecimento_Desempenha_Atv
     exclude = ['Estabelecimento', 'Atividade']
     widgets = {
         'ResponsavelTecnico':
         SelectMultiple(
             attrs={
                 'class': 'js-example-basic-single js-states form-control'
             }),
         'Veiculo':
         Select(attrs={
             'class': 'js-example-basic-single js-states form-control'
         }),
     }
Ejemplo n.º 2
0
 class Meta:
     model = Post
     fields = ["title", "slug", "text", "tag"]
     labels = {
         "slug":
         _("Slug (Человекопонятный url для поста. Необязательный для заполнения. При отсутствии автоматически генерируется )"
           )
     }
     widgets = {
         'title': TextInput(attrs={"class": "form-control"}),
         'slug': TextInput(attrs={"class": "form-control"}),
         "text": Textarea(attrs={"class": "form-control"}),
         "tag": SelectMultiple(attrs={"class": "form-control"})
     }
Ejemplo n.º 3
0
 class Meta:
     model = Book
     fields = ('title', 'text', 'genre')
     widgets = {
         'title': TextInput(attrs={'class': 'form-control'}),
         'text': Textarea(attrs={'class': 'form-control', 'rows': 3}),
         'genre': SelectMultiple(attrs={'class': 'form-control'})
     }
     labels = {
         'title': 'hello title'
     }
     help_text = {
         'text': 'special text for special ppl'
     }
Ejemplo n.º 4
0
 class Meta:
     model = HunterData
     fields = [
         'game', 'budget', 'license_since', 'shooting_experience',
         'physical_fitness', 'age', 'name'
     ]
     widgets = {
         'budget': JRCMoneyWidget(attrs={'label': _('Budget')}),
         'game': SelectMultiple(attrs={
             'hide_add_btns': True,
             'multiple': True
         }),
         'name': TextInput(attrs={'no_label': True})
     }
Ejemplo n.º 5
0
 class Meta:
     model = Book
     fields = ('title', 'text', 'genre')
     widgets = {
         "title": TextInput(attrs={"class": "form-control"}),
         "text": Textarea(attrs={"class": "form-control", "rows": 3, "cols": 4}),
         "genre": SelectMultiple(attrs={"class": "form-control"})
     }
     labels = {
         "title": "hello title"
     }
     help_texts = {
         "text": "enter youre text here"
     }
Ejemplo n.º 6
0
class simics_register_diff(FilterSet):
    def __init__(self, *args, **kwargs):
        start = perf_counter()
        super().__init__(*args, **kwargs)
        checkpoint_choices = choices(kwargs['queryset'], 'checkpoint')
        self.filters['checkpoint'].extra.update(choices=checkpoint_choices)
        self.filters['checkpoint'].widget.attrs['size'] = min(
            len(checkpoint_choices), 50)
        register_choices = choices(kwargs['queryset'], 'register')
        self.filters['register'].extra.update(choices=register_choices)
        self.filters['register'].widget.attrs['size'] = min(
            len(register_choices), 50)
        print('register diff filter', round(perf_counter() - start, 2),
              'seconds')

    checkpoint = MultipleChoiceFilter(
        widget=SelectMultiple(attrs={'class': 'form-control'}), help_text='')
    register = MultipleChoiceFilter(
        widget=SelectMultiple(attrs={'class': 'form-control'}), help_text='')

    class Meta:
        model = models.simics_register_diff
        fields = ('checkpoint', 'register')
Ejemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     super(StateForm, self).__init__(*args, **kwargs)
     AVAILABLE_KINDS = (('Initial', 'Initial'), ('Intermediate',
                                                 'Intermediate'),
                        ('Accepted', 'Accepted'), ('Rejected', 'Rejected'))
     self.fields['name'].widget = TextInput(attrs={'class': 'form-control'})
     self.fields['kind'].widget = Select(attrs={'class': 'form-control'},
                                         choices=AVAILABLE_KINDS)
     self.fields['allowed_groups'] = ModelMultipleChoiceField(
         queryset=Group.objects.all(),
         widget=SelectMultiple(attrs={
             'class': 'form-control',
             'multiple': 'multiple'
         }))
Ejemplo n.º 8
0
 def test_optgroup_select_multiple(self):
     widget = SelectMultiple(choices=(
         ('outer1', 'Outer 1'),
         ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2'))),
     ))
     self.check_html(widget,
                     'nestchoice', ['outer1', 'inner2'],
                     html=("""<select multiple="multiple" name="nestchoice">
         <option value="outer1" selected="selected">Outer 1</option>
         <optgroup label="Group &quot;1&quot;">
         <option value="inner1">Inner 1</option>
         <option value="inner2" selected="selected">Inner 2</option>
         </optgroup>
         </select>"""))
Ejemplo n.º 9
0
    def formfield(self, **kwargs):
        # don't call super, as that overrides default widget if it has choices
        defaults = {
            'required': not self.blank,
            'label': capfirst(self.verbose_name),
            'help_text': self.help_text,
            'choices': self.choices,
            'widget': SelectMultiple(attrs={'class': 'select-tags'})
        }

        if self.has_default():
            defaults['initial'] = self.get_default()
        defaults.update(kwargs)
        return MultiSelectFormField(**defaults)
Ejemplo n.º 10
0
 class Meta:
     model = Book
     fields = ('title', 'text', 'genre')
     widgets = {
         'title': TextInput(attrs={'class':'form-control'}),
         'text':Textarea(attrs={'class':'form-control', 'rows': 3}),
         'genre': SelectMultiple(attrs={'class':'form-control'})
     }
     labels = {
         'title' : 'hello title'
     }
     help_texts = {
         'text' : 'вводи текст руками'
     }
Ejemplo n.º 11
0
 def __init__(self, *args, **kwargs):
     rdsinstance = kwargs.pop("rdsinstance", None)
     super(SchemaForm, self).__init__(*args, **kwargs)
     self.fields[rdsinstance] = forms.MultipleChoiceField(
         label=rdsinstance,
         widget=SelectMultiple(attrs={
             "id": rdsinstance,
             "class": "form-control select2"
         }))
     rdsschema_list = list(
         RdsSchema.objects.filter(
             rdsinstance__instance_name=rdsinstance).values_list(
                 "schema_name", "schema_name"))
     self.fields[rdsinstance].choices = rdsschema_list
Ejemplo n.º 12
0
 class Meta:
     model = Dataset
     fields = ["title", "description", "tags", "contacts", "owner"]
     widgets = {
         "description":
         Textarea(attrs={"placeholder": "Description"}),
         "tags":
         TextInput(attrs={"placeholder": "Comma-separated"}),
         "contacts":
         SelectMultiple(attrs={
             "class": "selectpicker",
             "multiple": "on"
         }),
     }
Ejemplo n.º 13
0
Archivo: forms.py Proyecto: jeancfs/nes
    class Meta:
        model = Patient

        fields = ['gender', 'marital_status', 'country', 'city', 'state']

        widgets = {
            'gender':
            SelectMultiple(attrs={
                'class': 'form-control',
                'required': "",
                'disabled': ''
            }),
            'marital_status':
            SelectMultiple(attrs={
                'class': 'form-control',
                'required': "",
                'disabled': ''
            }),
            'country':
            SelectMultiple(attrs={
                'class': 'form-control',
                'required': "",
                'disabled': ''
            }),
            'state':
            SelectMultiple(attrs={
                'class': 'form-control',
                'required': "",
                'disabled': ''
            }),
            'city':
            SelectMultiple(attrs={
                'class': 'form-control',
                'required': "",
                'disabled': ''
            }),
        }
Ejemplo n.º 14
0
class TeamRoleForObjectForm(Form):
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        self.object = kwargs.pop('object')
        super(TeamRoleForObjectForm, self).__init__(*args, **kwargs)
        self.fields['roles'].choices = [(role.id, role.name)
                                        for role in self.object.roles]
        self.fields['roles'].initial = self.object.roles.first().id
        teams = [
            Team.objects.get(id=binding.object_id)
            for binding in UserRoleBinding.objects.filter(
                user=self.user,
                content_type=ContentType.objects.get_for_model(Team))
        ]
        self.fields['teams'].choices = [(team.id, team.name) for team in teams]
        self.fields['teams'].initial = [
            binding.team.id for binding in TeamRoleBinding.objects.filter(
                role__id=self.fields["roles"].initial,
                object_id=self.object.id,
                content_type=ContentType.objects.get_for_model(
                    self.object.__class__))
        ]

    roles = ChoiceField(label="Role",
                        required=False,
                        choices=[],
                        widget=Select(attrs={'class': 'selectpicker'}))

    teams = MultipleChoiceField(
        label="Teams",
        required=False,
        choices=[],
        widget=SelectMultiple(attrs={
            'class': 'selectpicker',
            'data-live-search': "true"
        }))

    def save(self):
        teams_id = self.cleaned_data.get('teams')
        role_id = int(self.cleaned_data.get('roles'))
        role = Role.objects.get(id=role_id)
        current_teams = self.object.get_teams_in_role(role.name)
        selected_teams = [Team.objects.get(id=team_id) for team_id in teams_id]
        to_remove = list(set(current_teams) - set(selected_teams))
        to_add = list(set(selected_teams) - set(current_teams))
        for team in to_add:
            self.object.add_team_in_role(team, role.name)
        for team in to_remove:
            self.object.remove_team_in_role(team, role.name)
Ejemplo n.º 15
0
class SessionAdmin(AjaxSelectAdmin):
    list_filter = (
        'slot',
        'tags',
        'room',
    )
    list_display = ('title', 'unconference', 'room', 'slot', 'description')
    search_fields = ('title', )

    form = make_ajax_form(Session, {'presenters': 'participant'})
    formfield_overrides = {
        models.ManyToManyField: {
            'widget': SelectMultiple(attrs={'size': '15'})
        }
    }
Ejemplo n.º 16
0
class GroupAdmin(admin.ModelAdmin):
    list_display = ('pk', 'tournament', 'name', 'level')
    search_fields = ['tournament']

    formfield_overrides = {models.ManyToManyField: {'widget': SelectMultiple(attrs={'size': '15'})}, }

    def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        if db_field.name == 'tournament':
            kwargs["queryset"] = Tournament.objects.all().order_by('-date')
        return super(GroupAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)

    def formfield_for_manytomany(self, db_field, request=None, **kwargs):
        if db_field.name == "teams":
            kwargs["queryset"] = TeamOnTournament.objects.all().order_by('-tournament__date', 'team__name')
        return super(GroupAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)
Ejemplo n.º 17
0
 class Meta:
     model = get_user_model()
     fields = [
         'bio',
         'services',
         'worked_with',
         'field_of_study',
         'affiliation',
         'projects',
         'challenges',
     ]
     labels = {
         'bio': _('Share a bit about yourself'),
         'services': _('Services you provide'),
         'field_of_study': _('Your field of study'),
         'affiliation': _('Affiliation'),
         'projects': _('Projects'),
         'challenges': _('Challenges you are facing'),
     }
     widgets = {
         'services': SelectMultiple(attrs={'size': 4, 'class': 'multiple'}),
         'worked_with': autocomplete.ModelSelect2Multiple(url='organization-autocomplete'),
         'challenges': SelectMultiple(attrs={'size': 4, 'class': 'multiple'}),
     }
Ejemplo n.º 18
0
class SearchForm(Form):
    project_id = CharField(
        max_length=80,
        required=False,
        help_text="this field auto-completes",
        widget=TextInput(attrs={'data-provider': 'typeahead'}))
    text = CharField(
        max_length=80,
        required=False,
        label="Descriptive Text",
        help_text="find in Title, Descriptions, Objectives, Skills")
    status = ModelMultipleChoiceField(
        queryset=Status.objects.all(),
        required=False,
        widget=SelectMultiple(attrs={'size': len(Status.objects.all())}))
    nasa_centers = ModelMultipleChoiceField(
        queryset=Center.objects.all(),
        required=False,
        label="NASA Centers",
        widget=SelectMultiple(attrs={'size': len(Center.objects.all())}))
    date = DateField(required=False, help_text="MM/DD/YYYY or YYYY-MM-DD")
    date_start = DateField(required=False,
                           help_text="MM/DD/YYYY or YYYY-MM-DD")
    date_end = DateField(required=False, help_text="MM/DD/YYYY or YYYY-MM-DD")
Ejemplo n.º 19
0
    class Meta:
        model = Post
        fields = [
            'titulo', 'slug', 'resumo', 'content', 'autor', 'categoria',
            'status'
        ]

        widgets = {
            'titulo': TextInput(attrs={'class': u'form-control'}),
            'slug': TextInput(attrs={'class': u'form-control'}),
            'resumo': TextInput(attrs={'class': u'form-control'}),
            'autor': Select(attrs={'class': u'form-control'}),
            'categoria': SelectMultiple(attrs={'class': u'form-control'}),
            'status': Select(attrs={'class': u'form-control'}),
        }
Ejemplo n.º 20
0
Archivo: forms.py Proyecto: sm2x/vron
 class Meta:
     model = Group
     fields = ['name', 'permissions']
     widgets = {
         'name':
         TextInput(attrs={
             'class': 'form-control',
             'autofocus': 'true'
         }),
         'permissions':
         SelectMultiple(attrs={
             'class': 'form-control',
             'style': 'height: 200px;'
         })
     }
Ejemplo n.º 21
0
    class Meta:
        model = Book
        fields = ('title', 'price', 'pub_date', 'publish', 'authors')

        labels = {
            'title': '标题',
            'price': '价格',
            'pub_date': '出版日期',
            'publish': '出版社',
            'authors': '作者列表'
        }
        widgets = {
            'title': TextInput(attrs={'class': 'form-control'}),
            'price': NumberInput(attrs={'class': 'form-control'}),
            'pub_date': DateInput(attrs={
                'class': 'form-control',
                'type': 'date'
            }),
            'publish': Select(attrs={
                'class': 'form-control',
            }),
            'authors': SelectMultiple(attrs={
                'class': 'form-control',
            })
        }

        error_messages = {
            'title': {
                'max_length': "不能超过32字符",
                "required": "标题不能为空",
                'unique': '书名已存在',
            },
            'price': {
                "required": "价格不能为空",
                'max_digits': '数字不能超过5个(包括小数)',
                'max_decimal_places': '小数最多为2位',
            },
            'pub_date': {
                "required": "出版日期不能为空",
                'invalid': '日期格式错误',
            },
            'publish': {
                'required': '出版社不能为空',
            },
            'authors': {
                'required': '作者不能为空',
            }
        }
Ejemplo n.º 22
0
 class Meta:
     model = Book
     fields = ['title', 'text', 'genre', 'book_image']
     widgets = {
         'title':
         TextInput(attrs={'class': 'form-control'}),
         'text':
         Textarea(attrs={
             'class': 'form-control',
             'rows': 5,
             'cols': 50
         }),
         'genre':
         SelectMultiple(attrs={'class': 'form-control'})
     }
     help_text = {'title': "", 'text': ""}
Ejemplo n.º 23
0
 class Meta:
     model = Meeting
     fields = ('meet_date', 'meet_facility', 'meet_arendator', 'meet_buyer',
               'access', 'rieltor', 'meet_status', 'meet_comment')
     widgets = {
         'access':
         SelectMultiple(attrs={
             'class': 'multiple',
             'multiple': 'multiple'
         }),
         'meet_comment':
         Textarea(attrs={
             'cols': '30',
             'rows': '7'
         })
     }
Ejemplo n.º 24
0
 class Meta:
     model = Posts
     fields = '__all__'
     exclude = (
         'slug',
         'is_active',
         'pub_date',
         'pub_hour',
     )
     widgets = {
         'title': TextInput(attrs={'class': 'form-control'}),
         'image_link': TextInput(attrs={'class': 'form-control'}),
         'short_description': Textarea(attrs={'class': 'form-control'}),
         'tags': SelectMultiple(attrs={'class': 'form-control'}),
         'category': Select(attrs={'class': 'form-control'}),
     }
Ejemplo n.º 25
0
 class Meta:
     document = ZabbixAgent
     widgets = {
         'servers': TextInput(attrs={'class': 'form-control'}),
         'listeners': SelectMultiple(attrs={'class': 'form-control select2'}),
         'key_length': NumberInput(attrs={'class': 'form-control'}),
         'active_servers': TextInput(attrs={'class': 'form-control'}),
         'hostname': TextInput(attrs={'class': 'form-control'}),
         'tls_accept': Select(attrs={'class': 'form-control'}),
         'tls_connect': Select(attrs={'class': 'form-control'}),
         'tls_cert': Select(attrs={'class': 'form-control'}),
         'tls_server_subject': TextInput(attrs={'class': 'form-control'}),
         'tls_server_issuer': TextInput(attrs={'class': 'form-control'}),
         'psk_identity': TextInput(attrs={'class': 'form-control'}),
         'psk_key': TextInput(attrs={'class': 'form-control'})
     }
Ejemplo n.º 26
0
 class Meta:
     model = ArtObject
     fields = '__all__'
     widgets = {
         'UserRating':
         RadioSelect(attrs={'style': 'margin-right:5px'}),
         'ArtSubTitle':
         Textarea(attrs={'style': 'height:65px'}),
         'UserComment':
         Textarea(attrs={'style': 'height:130px'}),
         'ArtGeners':
         SelectMultiple(
             attrs={'style': 'height:615px'},
             choices=ArtObject.ART_STATUSES,
         ),
     }
Ejemplo n.º 27
0
 class Meta:
     model = Book
     fields = ["title", "text", "genre", "cover"]
     widgets = {
         "title":
         TextInput(attrs={"class": "form-control"}),
         "text":
         Textarea(attrs={
             "class": "form-control",
             "rows": 5,
             "cols": 50
         }),
         "genre":
         SelectMultiple(attrs={"class": "form-control"})
     }
     help_texts = {"title": "", "text": ""}
Ejemplo n.º 28
0
 class Meta:
     model = Advert
     exclude = ['view_counter', 'image_height', 'image_width', 'active']
     widgets = {
         'title':
         TextInput(
             attrs={
                 'class': 'input is-primary',
                 'placeholder': "Make it short and catchy..."
             }),
         'strapline':
         TextInput(attrs={
             'class': 'input',
             'placeholder': "Draw them in..."
         }),
         'text_content':
         Textarea(attrs={
             'class': 'textarea',
             'placeholder': "The detail..."
         }),
         'image':
         FileInput(attrs={
             'class': 'file-input',
             'element': 'upload'
         }),
         'link_url':
         URLInput(
             attrs={
                 'class': 'input',
                 'placeholder': "Remember to use the full https://..."
             }),
         'link_text':
         TextInput(attrs={
             'class': 'input',
             'placeholder': "Keep it short or leave empty"
         }),
         'boards':
         SelectMultiple(attrs={'element': 'select-multiple'}),
         'template':
         RadioSelect(attrs={'element': 'radio'})
     }
     labels = {
         'text_content': "Main Text",
         'link_url': "Link URL (https://...)",
         'link_text': "Link Button Text",
         'boards': "Notice Boards"
     }
Ejemplo n.º 29
0
class LogOMTableForm(Form):
    """ Form used to generate table for log_forwarders """
    """ First condition word """
    condition = ChoiceField(
        label=_("Condition"),
        choices=CONDITION_CHOICES,
        widget=Select(attrs={'class': 'form-control select2'}))
    """ Comparison field name """
    field_name = ChoiceField(
        label=_("Field"),
        choices=FIELD_CHOICES,
        widget=Select(attrs={'class': 'form-control select2'}))
    """ Comparison operator """
    operator = ChoiceField(
        label=_("Operator"),
        choices=OPERATOR_CHOICES,
        widget=Select(attrs={'class': 'form-control select2'}))
    """ Comparison value """
    value = CharField(label=_("Value"),
                      initial='"plop"',
                      widget=TextInput(attrs={'class': 'form-control'}))
    """ Action - log forwarder """
    action = ModelMultipleChoiceField(
        label=_("Action"),
        queryset=LogOM.objects.all().only(*LogOM.str_attrs()),
        widget=SelectMultiple(attrs={'class': 'form-control select2'}))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['action'].empty_label = None

    def as_table_headers(self):
        """ Format field names as table head """
        result = "<tr>\n"
        for field in self:
            result += "<th>{}</th>\n".format(field.label)
        result += "<th>Delete</th></tr>\n"
        return result

    def as_table_td(self):
        """ Format fields as a table with <td></td> """
        result = "<tr>"
        for field in self:
            result += "<td>{}</td>".format(field)
        result += "<td style='text-align:center'><a class='btnDelete'><i style='color:grey' " \
                  "class='fas fa-trash-alt'></i></a></td></tr>\n"
        return result
Ejemplo n.º 30
0
 class Meta:
     model = User
     fields = [
         'username', 'email', 'is_staff', 'is_active', 'groups', 'icon'
     ]
     widgets = {
         'username':
         TextInput(attrs={'class': 'form-control'}),
         'email':
         TextInput(attrs={'class': 'form-control'}),
         'is_staff':
         CheckboxInput(attrs={'class': 'custom-control-input'}),
         'is_active':
         CheckboxInput(attrs={'class': 'custom-control-input'}),
         'groups':
         SelectMultiple(attrs={'class': 'form-control single-select'}),
     }