Example #1
0
 class Meta:
     model = Restaurant
     exclude = ['user', 'id', 'review_score']
     widgets = {
         'logo': FileInput(),
         'menu': FileInput(),
         'place': FileInput()
     }
Example #2
0
 class Meta:
     model = ResumeInfo
     fields = ('resume', 'resume_html', 'pdf', 'tag')
     widgets = {
         'resume':
         Textarea(
             attrs={
                 'autocomplete': 'off',
                 'autofocus': 'autofocus',
                 'onscroll': 'this.rows++;',
                 'placeholder': _('Resume Markdown Content')
             }),
         'resume_html':
         Textarea(
             attrs={
                 'autocomplete': 'off',
                 'autofocus': 'autofocus',
                 'onscroll': 'this.rows++;',
                 'placeholder': _('Resume Html Content')
             }),
         'pdf':
         FileInput(attrs={
             'autocomplete': 'off',
             'placeholder': _('pdf or docx')
         }),
         'tag':
         TextInput(attrs={
             'autocomplete': 'off',
             'placeholder': _('Tags')
         }),
     }
Example #3
0
    def render(self, name, value, attrs=None):
        substitutions = {
            'initial_text': self.initial_text,
            'input_text': self.input_text,
            'clear_template': '',
            'clear_checkbox_label': self.clear_checkbox_label,
        }

        template = u'%(input)s'
        substitutions['input'] = FileInput.render(self, name, value, attrs)

        if value and not isinstance(value, UploadedFile):
            file_obj = File.objects.get(pk=value)
            template = self.template_with_initial
            substitutions['initial'] = (
                u'<a href="%s" target="_blank">%s: %s</a>' %
                (escape(file_obj.url), file_obj.pk, file_obj.hash))
            if not self.is_required:
                checkbox_name = self.clear_checkbox_name(name)
                checkbox_id = self.clear_checkbox_id(checkbox_name)
                substitutions['clear_checkbox_name'] = conditional_escape(
                    checkbox_name)
                substitutions['clear_checkbox_id'] = conditional_escape(
                    checkbox_id)
                substitutions['clear'] = CheckboxInput().render(
                    checkbox_name, False, attrs={'id': checkbox_id})
                substitutions[
                    'clear_template'] = self.template_with_clear % substitutions

        return mark_safe(template % substitutions)
Example #4
0
 class Meta:
     model = UserProfile
     fields = ('phone', 'address', 'city', 'country', 'image')
     widgets = {
         'phone':
         TextInput(attrs={
             'class': 'input',
             'placeholder': 'phone'
         }),
         'address':
         TextInput(attrs={
             'class': 'input',
             'placeholder': 'address'
         }),
         'city':
         Select(attrs={
             'class': 'input',
             'placeholder': 'city'
         },
                choices=CITY),
         'country':
         TextInput(attrs={
             'class': 'input',
             'placeholder': 'country'
         }),
         'image':
         FileInput(attrs={
             'class': 'input',
             'placeholder': 'image',
         }),
     }
Example #5
0
 class Meta:
     model = Customer
     fields = '__all__'
     exclude = ['user', 'id']
     widgets = {
         'profile_pic': FileInput(),
     }
Example #6
0
    class Meta:

        model = post
        fields = ['blog', 'titulo', 'texto_corto', 'texto_largo', 'fecha', 'imagen', 'visible', 'cat']
        labels = {
                    'blog': _('Elija un Blog'),
                    'titulo': _('Título'),
                    'texto_corto': _('Texto descriptivo'),
                    'texto_largo': _('Texto completo'),
                    'fecha': _('Fecha de publicación'),
                    'imagen': _('Seleccione una imagen'),
                    'visible': _('¿Visible?'),
                    'cat': _('Categorías'),
                }
        exclude = ['creado_el', 'modificado_el']
        widgets = {
            'blog': Select,
            'texto_corto': TextInput(),
            'texto_largo': Textarea(attrs={'class': 'materialize-textarea', 'cols': '80', 'rows': '16'}),
            'fecha': DateInput(format='d/m/Y h:i:s'),
            # 'fecha': DateTimeInput(attrs={'class': 'datepicker', 'placeholder': 'dd/mm/aaaa HH:MM:SS'}),
            'imagen': FileInput(),
            'visible': Select(attrs={'label': _('¿Visible?'), 'class': 'input-field'}),
            'cat': SelectMultiple(attrs={'label': _('Categorías'), 'class': 'multiple'}),
        }
Example #7
0
 class Meta:
     fields = [
         'name',
         'status',
         'photo',
         'short_description',
         'information_for_getpet_team',
         'description',
         'gender',
         'age',
         'weight',
         'desexed',
         'properties',
         'special_information',
     ]
     widgets = {
         'photo': FileInput(attrs={
             'data-show-remove': 'false',
         }),
         'information_for_getpet_team': Textarea(attrs={'rows': 2}),
         'description': Textarea(attrs={'rows': 6}),
         'special_information': Textarea(attrs={'rows': 2}),
         'short_description':
         TextInput(attrs={'data-provide': "maxlength"}),
         'properties': CheckboxSelectMultiple(),
         'gender': RadioSelect(),
         'desexed': RadioSelect(),
     }
     labels = {
         'photo': "",
         'information_for_getpet_team': "",
         'properties': "",
     }
Example #8
0
 class Meta:
     model = tUserProfile
     fields = ['avatar']
     # The widget will help us get rid of the default labels
     widgets = {
         'avatar': FileInput()
     }
Example #9
0
class RegistrationAcceptedConfirmedForm(RegistrationAcceptedForm):
    registration_receipt = forms.FileField(
        widget=FileInput(),
        required=False,
        help_text=
        "After paying the registration fee of MK 22,000 - please provide evidence of the the bank deposit slip before October 1st.",
    )

    def clean(self):
        cleaned_data = self.cleaned_data
        participation_fields = [
            "tshirt_size",
            "tshirt_fit",
            "tshirt_color",
            "dietary_restrictions",
        ]
        if not all(cleaned_data[k] for k in participation_fields):
            print(list((k, cleaned_data[k]) for k in participation_fields))
            raise forms.ValidationError("You have to fill in all the fields.")
        return cleaned_data

    class Meta:
        model = models.Registration
        fields = [
            "registration_receipt",
        ] + RegistrationAcceptedForm.Meta.fields
def field_to_widget(field):
    if type(field) is CharField:
        if field.choices:
            return Select(attrs={"class": "form-control"})
        return TextInput(attrs={"class": "form-control", "rows": 1})
    if type(field) is TextField:
        return Textarea(attrs={"class": "form-control", "rows": 1})
    if type(field) is AutoField:
        return HiddenInput(attrs={"class": "form-control", "rows": 1})
    if type(field) is IntegerField or type(field) is FloatField:
        return NumberInput(attrs={"class": "form-control"})
    if type(field) is EmailField:
        return EmailInput(attrs={"class": "form-control"})
    if type(field) is ForeignKey:
        return Select(attrs={"class": "form-control"})
    if type(field) is ManyToManyField:
        return CheckboxSelectMultiple(attrs={"class": ""})
    if type(field) is BooleanField:
        return CheckboxInput(attrs={"class": "form-control"})
    if type(field) is FileField:
        return FileInput(attrs={"class": "form-control"})
    if type(field) is DateField:
        return DateInput(attrs={"class": "form-control date", "type": "date"})
    if type(field) is DateTimeField:
        return DateTimeInput(attrs={"class": "form-control datetimepicker"})

    return TextInput(attrs={"class": "form-control", "rows": 1})
Example #11
0
class TemplateImageForm(Form):
    """ Image insertion form représentation
    """
    name = CharField(label=_("Image name"),
                     widget=TextInput(attrs={"class": "form-control"}))
    content = CharField(label=_("File"),
                        widget=FileInput(attrs={"class": "form-control"}))
Example #12
0
    def __init__(self, *args, **kwargs):
        """
        ImageFieldのフォームに画像クリアのチェックボックスを
        表示させないよう、widgetをFileInputに変更
        """

        super().__init__(*args, **kwargs)
        self.fields['profile_pic'].widget = FileInput()
Example #13
0
 class Meta:
     model = Setting
     fields = ('hidden_note', 'wallpaper', 'theme')
     widgets = {
         'wallpaper': FileInput(),
         'hidden_note': CheckboxInput(attrs={'id': 'hidden_note_id'}),
         'theme': CheckboxInput(attrs={'id': 'theme_id'}),
     }
Example #14
0
class UpdateProfileForm(ModelForm):
    input_field_class = 'bg-gray-700 bg-opacity-0 ml-2 pb-1 outline-none text-white placeholder-gray-600'

    profile_image = ImageField(label='',
                               widget=FileInput(attrs={
                                   'class': 'hidden',
                                   'accept': '.jpg,.png'
                               }))

    background_image = ImageField(widget=FileInput(attrs={
        'class': 'hidden',
        'accept': '.jpg,.png'
    }))

    bio = CharField(required=False,
                    widget=Textarea(
                        attrs={
                            'class': input_field_class + ' resize-none',
                            'placeholder': 'Add your bio',
                            'rows': 3
                        }))

    location = CharField(
        required=False,
        widget=TextInput(attrs={
            'class': input_field_class,
            'placeholder': 'Add your location'
        }))

    website = URLField(
        required=False,
        max_length=100,
        widget=URLInput(attrs={
            'class': input_field_class,
            'placeholder': 'Add your website'
        }))

    class Meta:
        model = Profile
        fields = [
            'profile_image', 'background_image', 'bio', 'location', 'website'
        ]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
Example #15
0
 class Meta:
     model = UserProfile
     fields = ('profile_pic', 'user_bio')
     widgets = {
         'profile_pic': FileInput(attrs={
             'name': 'image',
             'accept': 'image/*'
         })
     }
Example #16
0
    class Meta:
        model = Dados_Mapeamento_empresa
        fields = '__all__'

        widgets = {

            ##Dados cadastrais
            'nome':
            TextInput(attrs={'placeholder': 'Nome da Empresa'}),
            'pessoas':
            CheckboxSelectMultiple(),
            'logo':
            FileInput(attrs={'class': 'label'}),

            #Endereço institucional
            'cep':
            TextInput(
                attrs={
                    'placeholder': 'xxxxx-xxx',
                    'id': 'cep',
                    'onblur': 'pesquisacep(this.value);'
                }),  ####### fazer Auto preenchimento com CEP
            'rua':
            TextInput(attrs={'id': 'rua'}),
            'bairro':
            TextInput(attrs={'id': 'bairro'}),
            'cidade':
            TextInput(attrs={'id': 'cidade'}),
            'estado':
            Select(attrs={'id': 'uf'}),
            'site':
            TextInput(attrs={'placeholder': 'http://www.seuwebsite.com'}),
            'email':
            TextInput(attrs={'placeholder': '*****@*****.**'}),

            #Dados do Representante
            'telefone':
            PhoneNumberPrefixWidget(attrs={'placeholder': 'xxxxxxx-xxxx'
                                           }),  ## arrumar aqui depois 
            'email_representante':
            TextInput(attrs={'placeholder': '*****@*****.**'}),

            #Campo de Abrangência da Instituição Cadastrada
            'em_qual_destes_itens_abaixo_seu_cadastro_se_enquadra':
            CheckboxSelectMultiple(),
            'em_qual_destes_setores_a_instituicao_se_enquadra':
            Select(attrs={'onchange': "sumir(this.value);"
                          }),  #pegando função do js

            #Sobre Projetos, Iniciativas, parcerias e infraestrutura :
            'programas_iniciativas_movimentos_de_empreendedorismo_e_inovacao_que_executa':
            Textarea(attrs={'id': 'Textarea'}),
            'programas_iniciativas_movimentos_de_empreendedorismo_e_inovacao_que_participa':
            Textarea(attrs={'id': 'Textarea'}),
            'equipamentos_disponiveis_para_uso_compartilhado_prestacao_de_servico_no_Ecossistema_Regional':
            Textarea(attrs={'id': 'Textarea'}),
        }
Example #17
0
 class Meta:
     model = ImageModel
     fields = [
         'title',
         'file_url',
     ]
     widgets = {
         'title': TextInput(attrs={'class': 'form-control', 'placeholder': 'Введите низвание фотографии'}),
         'file_url': FileInput(attrs={'class': 'form-control', 'placeholder': 'Загрузить фото'}),
     }
Example #18
0
    class Meta:
        model = Dados_Mapeamento_startup
        fields = '__all__'
        #     #Dados Cadastrais
        #     'nome','site','email','cnpj',
        #     #Endereço
        #    'cep','rua','bairro','cidade','estado',
        #     #Dados do Representante
        #    'nome_representante','cargo','telefone','email_representante',
        #     #Característica da Empresa/Startup
        #    'setor_de_atuacao', 'area_de_atuacao_da_empresa_ou_startup','segmento_area','detalhes_de_area_de_atuacao','segmento_de_atuacao', 'tipo_de_cliente',
        #    #questionario
        #    'possui_mercado_Global','possui_Influencia_ou_interesse_militar', 'qual_estrategia_de_saida_ou_idealizada_para_o_negocio',
        #    ]
        #

        #validar CNPJ e Email
        widgets = {
            #Dados Cadastrais
            'nome':
            TextInput(attrs={'placeholder': 'Nome da Startup'}),
            'cnpj':
            TextInput(attrs={'placeholder': ' xx.xxx.xxx/xxxx-xx'}),
            'site':
            TextInput(attrs={'placeholder': 'http://www.seuwebsite.com'}),
            'email':
            TextInput(attrs={'placeholder': '*****@*****.**'}),
            'logo':
            FileInput(attrs={'class': 'label'}),
            #Endereço
            'cep':
            TextInput(attrs={'placeholder': 'xxxxx-xxx'
                             }),  ####### fazer Auto preenchimento com CEP

            #dados representante
            'telefone':
            PhoneNumberPrefixWidget(attrs={'placeholder': 'xxxxxxx-xxxx'
                                           }),  ## arrumar aqui depois 
            'email_representante':
            TextInput(attrs={'placeholder': '*****@*****.**'}),

            #caracteristicas da startup
            'setor_de_atuacao':
            CheckboxSelectMultiple(),  #arrumar depois as tag

            #Questionário
            'qual_estrategia_de_saida_ou_idealizada_para_o_negocio':
            CheckboxSelectMultiple(),  #arrumar depois as tag
            'sua_startup_possui_conhecimento_ou_e_treinada_nas_metodologias_descritas_abaixo':
            CheckboxSelectMultiple(),  #arrumar depois as tag
            'quais_programas_iniciativas_movimentos_de_empreendedorismo_e_inovacao_que_participa':
            Textarea(attrs={'id': 'Textarea'}),
            'com_quais_entidades_do_ecossistema_tem_conexao_interacao_frequente_projetos_em_parceria_colaboracao_que_contribuiram_e_contribuem_para_as_inovacoes_e_aperfeicoamento_da_empresa':
            Textarea(attrs={'id': 'Textarea'}),
        }
Example #19
0
 class Meta:
     model = File
     fields = ('name', 'description', 'attachment')
     widgets = {
         'name': TextInput(attrs={'class': 'span11'}),
         'description': Textarea(attrs={
             'class': 'span11',
             'rows': '10'
         }),
         'attachment': FileInput(attrs={'class': 'span11'})
     }
Example #20
0
    class Meta:
        model = Student
        fields = ('profile_pic',)

        labels = {
            'profile_pic': _('Profile image:'),
        }

        widgets = {
            'profile_pic': FileInput(),
        }
Example #21
0
 class Meta:
     model = Post
     exclude = (
         'author',
         'publish',
         'created_at',
     )
     widgets = {
         'newsletters': CheckboxSelectMultiple(),
         'title': TextInput(attrs={'onkeyup': 'updateslug()'}),
         'image': FileInput()
     }
Example #22
0
    class Meta:
        model = Article

        fields = [
            'title', 'sw_title', 'cover_photo', 'content', 'sw_content',
            'category', 'belong_to', 'active',
            'display_cover_photo_on_view_article'
        ]
        widgets = {
            'title':
            TextInput(attrs={
                'class': 'form-control',
                'placeholder': 'enter title'
            }),
            'sw_title':
            TextInput(
                attrs={
                    'class': 'form-control',
                    'placeholder': 'ingiza kichwa cha makala',
                    'required': 'true'
                }),
            'cover_photo':
            FileInput(attrs={
                'class': 'form-control',
                'placeholder': 'enter cover photo'
            }),
            'content':
            Textarea(
                attrs={
                    'class': 'form-control no-resize summernote',
                    'placeholder': 'Please type what you want...',
                    'rows': 40,
                    'style': 'display: none;'
                }),
            'sw_content':
            Textarea(
                attrs={
                    'class': 'form-control no-resize summernote',
                    'placeholder': 'Tafadhali andika unachotaka...',
                    'rows': 40,
                    'style': 'display: none;',
                    'required': 'true'
                }),
            'belong_to':
            Select(attrs={'class': 'form-control show-tick'}),
            'category':
            Select(attrs={'class': 'form-control show-tick'}),
            'active':
            CheckboxInput(attrs={'id': 'checkbox'}),
            'display_cover_photo_on_view_article':
            CheckboxInput(attrs={'id': 'checkbox1'}),
        }
 class Meta:
     model = Blog
     fields = ['type','category' ,'title', 'slug', 'keywords',
               'description', 'image', 'detail']
     widgets = {
         'title': TextInput(attrs={'class': 'input', 'placeholder': 'title'}),
         'slug': TextInput(attrs={'class': 'input', 'placeholder': 'slug'}),
         'keywords': TextInput(attrs={'class': 'input', 'placeholder': 'keywords'}),
         'description': TextInput(attrs={'class': 'input', 'placeholder': 'description'}),
         'type': Select(attrs={'class': 'input', 'placeholder': 'city'}, choices=TYPE),
         'image': FileInput(attrs={'class': 'input', 'placeholder': 'image', }),
         'detail': CKEditorWidget(),
     }
Example #24
0
 class Meta:  # 元类
     model = News
     fields = ['img']
     labels = {
         'img': '',
     }
     widgets = {
         'img': FileInput(attrs={
             'class': '_sub_file',
             'onchange': 'lookImg(this)',
             'accept': 'image/*',
             'multiple': 'multiple'
         })
     }
Example #25
0
 class Meta:
     model = Company
     fields = ('name', 'location', 'logo', 'description', 'employee_count')
     labels = {
         'name': _('Название компании'),
         'location': 'География',
         'logo': '',
         'description': _('Информация о компании'),
         'employee_count': _('Количество человек в компании'),
     }
     widgets = {
         'description': Textarea(attrs={'rows': 4}),
         'logo': FileInput(attrs={'class': 'custom-file-input'}),
         # TODO Доработать (сделать пользовательский) виджет, чтобы из поля передавалось в html tag img<> адрес
     }
class FacebookChatForm(forms.Form):
    chat_file = forms.FileField(widget=FileInput(
        attrs={
            'onchange': 'file = true;',
            'multiple': 'multiple'
        }))

    def clean_chat_file(self):
        data = self.cleaned_data.get("chat_file")

        if data.content_type == "application/json":
            return data
        else:
            raise forms.ValidationError(
                "Your file is not JSON file. Let's try with another file.")
Example #27
0
class EditProfileForm(forms.Form):
    '''Form for edit profile view'''
    profile_name = forms.CharField(
        label="Profile Name",
        max_length=80,
        widget=TextInput(attrs={'class': 'form-control'}))
    profile_pic = forms.ImageField(
        label="Profile Picture",
        required=False,
        widget=FileInput(attrs={'class': 'form-control-file'}))
    description = forms.CharField(
        label="Description",
        max_length=300,
        required=False,
        widget=TextInput(attrs={'class': 'form-control'}))
Example #28
0
    class Meta:
        model = Visitor
        fields = '__all__'
        exclude = ['user', 'role', 'email', 'username']

        labels = {
            'username': _('Usename:'),
            'first_name': _('Name:'),
            'last_name': _('Surname:'),
            'profile_pic': _('Profile image:'),
        }

        widgets = {
            'profile_pic': FileInput(),
        }
Example #29
0
    def render(self, name, value, attrs=None, renderer=None):
        substitutions = {
            'input_text': self.input_text,
            'clear_template': '',
            'clear_checkbox_label': self.clear_checkbox_label,
        }
        template = u'%(input)s'
        substitutions['input'] = FileInput().render(name, value, attrs)

        if value and hasattr(value, "url"):
            template = self.template_with_initial
            substitutions['initial'] = (
                u'<a href="%s" width="60" target="_blank" height="60">%s</a>' %
                (escape(value.url), (escape(value.url.split('/')[3]))))

        return mark_safe(template % substitutions)
Example #30
0
 class Meta:
     model = Report
     fields = ('name', 'description', 'report', 'model', 'jsonql_query',
               'user', 'groups')
     widgets = {
         'report':
         FileInput(),
         'model':
         CheckboxSelectMultiple(
             attrs={'class': 'mdc-checkbox__native-control'}),
         'user':
         CheckboxSelectMultiple(
             attrs={'class': 'mdc-checkbox__native-control'}),
         'groups':
         CheckboxSelectMultiple(
             attrs={'class': 'mdc-checkbox__native-control'})
     }
Example #31
0
 def __init__(self, *args, **kwargs):
     self.db_field = kwargs.pop('db_field', None)
     FileInput.__init__(self, *args, **kwargs)