class Meta: model = SiteInfo fields = ['user_idle_timeout'] widgets = {'user_idle_timeout': TextInput(attrs={'size': 50})}
class Meta: model = SpcImages rank = forms.IntegerField(initial=5) fields = ( 'author', 'source_url', 'image_url', 'source_file_name', 'name', 'awards', 'variation', 'form', 'text_data', 'description', 'certainty', 'rank', 'credit_to', 'is_private', 'image_file', 'quality') labels = { 'author': "Name that has been used to credit your photos. Warning: Your account will be removed if you select a name that is not yours!", 'credit_to': 'or credit name. Enter only when name does not exist in Author list', 'source_url': 'Link to source', 'image_url': 'Image URL', 'source_file_name': 'Alternate name, e.g. a synonym', 'name': 'Clonal name', 'awards': 'Awards', 'quality': 'Quality', 'variation': 'Varieties', 'form': 'Form', 'certainty': 'Certainty', 'rank': 'Rank', 'text_data': 'Comment', 'description': 'Tags', 'is_private': 'Private photo', } widgets = { # 'author':TextInput(attrs={'size': 35}), 'source_url': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', 'autocomplete': 'off', }), 'credit_to': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'image_url': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', 'autocomplete': 'off', }), 'source_file_name': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'name': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'awards': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'variation': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'certainty': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'form': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), 'text_data': Textarea(attrs={'cols': 47, 'rows': 4, 'style': 'font-size: 13px', }), 'description': TextInput(attrs={'size': 45, 'style': 'font-size: 13px', }), # 'is_private': CheckboxInput(attrs={'class': 'required checkbox form-control'}), } choices = { 'rank': CHOICES, 'quality': QUALITY, 'is_private': PRIVATE, } # help_texts = { # # 'author': 'The name for credit attribution', # 'credit_to': 'Enter the photo owner neme here if it is not listed under author', # 'source_url': 'The URL from address bar of the browser', # 'image_url': "Right click on the image and select 'copy image address'", # 'source_file_name': 'The name you prefer, if different from accepted name for the species, e.g. a synonym, an undescribed or unregistered name. (Place infraspecific in Variety box below.', # 'name': 'Clonal name of the plant', # 'awards': 'Awards received, comma separated', # 'variation': 'Informal variations (unpublished), or infra specific of synonym.', # 'certainty': 'Put one or more ? to show level of certainty', # 'form': 'E.g. color forms, peloric, region...', # 'text_data': 'Any comment you may have about this photo. When, where or month it was taken, history of this plant, etc.', # 'description': 'Short description of the plant. E.g. aroma, color, pattern, shape...', # 'rank': 'Range from 9 (highest quality to 1 (lowest). Set rank = 0 if you reject the identity of the photo', # } error_messages = { # 'author': { # 'required': _("Please select a name for credit attribution."), # }, 'image_url': { 'required': _("Please enter, the url of the image (right click and select 'copy image address'."), }, } # A work around for non curator user. Form will post empty rank. def clean_rank(self): data = self.cleaned_data['rank'] if not data: return 5 return data def clean_author(self): data = self.cleaned_data['author'] if not Photographer.objects.filter(pk=data): raise forms.ValidationError('Invalid Author') return data
class Meta: model=City fields=['name'] widgets={'name' : TextInput(attrs={'class':'input','placeholder':'City Name'})}
class Meta: model = seekersdetails widgets = { 'name': TextInput(attrs={'placeholder': 'Full Name'}), 'City': TextInput(attrs={'placeholder': 'City'}), 'Birth_date': TextInput(attrs={'placeholder': 'Birth date '}), 'address': TextInput(attrs={'placeholder': 'Address '}), 'State': TextInput(attrs={'placeholder': 'State '}), 'Mobile_Number': TextInput(attrs={'placeholder': 'Mobile No'}), 'secondary_school': TextInput(attrs={'placeholder': 'Secondary School'}), 'secondary_percent': TextInput(attrs={'placeholder': 'Secondary Percentage'}), 'senior_school': TextInput(attrs={'placeholder': 'Senior Secondary School'}), 'senior_percent': TextInput(attrs={'placeholder': 'Senior Secondary Percentage'}), 'College_name': TextInput(attrs={'placeholder': 'College Name'}), 'Stream': TextInput(attrs={'placeholder': 'Branch'}), 'Graduation_percent': TextInput(attrs={'placeholder': 'Graduation Percent'}), 'Skills': TextInput(attrs={'placeholder': 'Skills'}), 'exp_1': TextInput(attrs={'placeholder': 'Training organization'}), 'exp_1_about': TextInput(attrs={'placeholder': 'Project'}), } exclude = ('Id', )
class Meta: model = Formulario fields = [ 'id_comercio', 'nombre_sucursal', 'id_depto', 'id_muni', 'direccion', 'zona', 'referencia', 'telefono', 'factura', 'fecha_incidente', 'detalle_queja', 'solicitud', 'nombre_cliente', 'apellido_cliente', ] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['id_muni'].queryset = Municipio.objects.none() if 'id_depto' in self.data: try: depto_id = int(self.data.get('id_depto')) self.fields['id_muni'].queryset = Municipio.objects.filter( depto_id=depto_id).order_by('nombre_depto') except (ValueError, TypeError): pass # invalid input from the client; ignore and fallback to empty City queryset elif self.instance.pk: self.fields[ 'id_muni'].queryset = self.instance.id_depto.id_muni_set.order_by( 'nombre_muni') widgets = { 'id_comercio': Select(attrs={'placeholder': 'Seleccione Comercio'}), 'nombre_sucursal': TextInput(attrs={'placeholder': 'Ingrese Sucursal'}), 'id_depto': Select(attrs={'placeholder': 'Seleccione Departamento'}), 'id_muni': Select(attrs={'placeholder': 'Seleccione Municipio'}), 'factura': TextInput(attrs={'placeholder': 'Número de factura'}), 'fecha_incidente': DateInput(format=('%d/%m/%Y')), 'detalle_queja': Textarea(attrs={'placeholder': 'Describa aquí su queja'}), 'solicitud': Textarea( attrs={ 'placeholder': 'En este espacio puede indicar si tiene una sugerencia para ' 'solucionar el problema' }), 'nombre_cliente': TextInput(attrs={'placeholder': 'Este campo es opcional'}), 'apellido_cliente': TextInput(attrs={'placeholder': 'Este campo es opcional'}), 'direccion': TextInput(attrs={'placeholder': 'Ingrese la dirección'}), 'zona': TextInput(attrs={'placeholder': 'Ingrese la zona'}), 'referencia': TextInput(attrs={ 'placeholder': 'Ingrese una referencia para la dirección' }), 'telefono': TextInput(attrs={'placeholder': 'Ingrese un número de telefono'}), }
class Meta: model = Audiogram fields = '__all__' widgets = { '__all__': TextInput(standardreq), }
class Meta: model = DownLink fields = ['old_link'] widgets = {'old_link': TextInput(attrs={'type': "text", 'id': "link"})}
class Meta: model = models.ApiKey fields = '__all__' widgets = {"api_key": PasswordInput(), "name": TextInput()}
def __init__(self, attrs=None, initial=None): widgets = (PhonePrefixSelect(initial), TextInput(),) super(PhoneNumberPrefixWidget, self).__init__(widgets, attrs)
class Meta: model = Alumno fields = ('Nombre', 'Apellido', 'FechaNacimiento', 'Ciudad', 'Direccion', 'Celular', 'mail', 'FechaInicio', 'FechaFin', 'NumeroLibreta', 'Categoria', 'Instructor', 'Observacion') widgets = { 'Nombre': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Nombre', }), 'Apellido': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Apellido', }), 'FechaNacimiento': DateInput( attrs={ 'class': 'form-control', 'placeholder': 'Fecha de Nacimiento', 'type': 'date', }), 'Ciudad': Select(attrs={ 'class': 'form-control', }), 'Direccion': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Direccion', }), 'Celular': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Celular', }), 'mail': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Email', }), 'FechaInicio': DateInput( attrs={ 'class': 'form-control', 'placeholder': 'Fecha de Inicio', 'type': 'date', }), 'FechaFin': DateInput( attrs={ 'class': 'form-control', 'placeholder': 'Fecha de Fin', 'type': 'date', }), 'NumeroLibreta': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Número Libreta', }), 'Categoria': Select(attrs={ 'class': 'form-control', }), 'Instructor': Select(attrs={ 'class': 'form-control', }), 'Observaciones': Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Observaciones', }) }
class Meta: model = CustomUser fields = ['username'] widgets = {'username': TextInput(attrs={'placeholder': 'Username'})}
class Meta: model = Instructor fields = ('Nombre', 'Apellido', 'Ciudad', 'Categoria', 'FechaInicio', 'FechaFin', 'CodigoAR', 'FechaCodigoAR', 'CodigoID', 'Licencia', 'EscuelaAnterior') widgets = { 'Nombre': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Nombre', }), 'Apellido': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Apellido', }), 'Ciudad': Select(attrs={ 'class': 'form-control', }), 'Categoria': Select(attrs={ 'class': 'form-control', }), 'FechaInicio': DateInput(attrs={ 'class': 'form-control', 'type': 'date', }), 'FechaFin': DateInput( attrs={ 'class': 'form-control', 'placeholder': 'Fecha de Fin', 'type': 'date', }), 'CodigoAR': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Código AR', }), 'FechaCodigoAR': DateInput(attrs={ 'class': 'form-control', 'type': 'date', }), 'CodigoID': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Código ID', }), 'Licencia': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Número licencia', }), 'EscuelaAnterior': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Escuela Anterior', }) }
class Meta: model = Dummy fields = ('tag', ) widgets = { 'tag': TextInput(attrs={'class': 'form-control'}), }
class IntegrationScaffoldingForm(Form): name = CharField(max_length=80, label=_('Integration name'), widget=TextInput()) author_homepage = URLField(label=_('Author\'s homepage'), required=False) issue_tracker = URLField(label=_('Issue tracker URL'), required=False, help_text=_('Bug reports and feature requests')) categories = MultipleChoiceField(widget=HiddenInput(), disabled=True, required=True, label=_('Categories'), choices=lazy(get_categories, list), help_text=_('Hold down Ctrl and click to ' 'select multiple entries')) summary = CharField( max_length=256, label=_('Summary'), help_text= _('Short description of your app that will be rendered as short teaser' )) screenshot = URLField(max_length=256, label=_('Screenshot URL'), required=False, help_text=_('URL for integration screenshot')) screenshot_thumbnail = URLField(max_length=256, label=_('Screenshot ' 'thumbnail URL'), required=False, help_text=_('URL for integration ' 'screenshot in ' 'smaller dimensions. ' 'Must be used in combination ' 'with a larger screenshot.')) description = CharField(widget=Textarea, label=_('Description'), help_text=_('Full description of what your' ' integration ' 'does. Can contain Markdown.')) def save(self, user, app_id, action): if app_id is None: app_id = self.cleaned_data['name'].lower().replace(" ", "_") try: app = App.objects.get(id=app_id) if app.can_update(user) or user.is_superuser: if action == "reject" and user.is_superuser: '''Not optimal but works''' Screenshot.objects.filter(app=app).delete() app.delete() elif action == "approve" and user.is_superuser: app.approved = True if settings.DISCOURSE_TOKEN: self._create_discourse_category(app_id) app.save() return app_id else: '''Not optimal but works''' Screenshot.objects.filter(app=app).delete() if self.data['screenshot']: screenshot = Screenshot.objects.create( url=self.cleaned_data['screenshot'], small_thumbnail=self. cleaned_data['screenshot_thumbnail'], ordering=1, app=app) screenshot.save() app.description = self.cleaned_data['description'] app.name = self.cleaned_data['name'] app.summary = self.cleaned_data['summary'] app.website = self.cleaned_data['author_homepage'] app.issue_tracker = self.cleaned_data['issue_tracker'] app.save() return app_id except App.DoesNotExist: app = App.objects.create(id=app_id, owner=user, certificate=uuid.uuid1().urn) app.set_current_language('en') app.categories.set(self.cleaned_data['categories']) app.description = self.cleaned_data['description'] app.name = self.cleaned_data['name'] app.summary = self.cleaned_data['summary'] app.website = self.cleaned_data['author_homepage'] app.issue_tracker = self.cleaned_data['issue_tracker'] app.save() p = App.objects.get(id=app_id) p.is_integration = True if user.is_superuser: p.approved = True if settings.DISCOURSE_TOKEN: self._create_discourse_category(app_id) else: send_mail( "New integration submitted", "Please review the " "integration to make " "sure it fits the " "guidelines.", settings.NEXTCLOUD_FROM_EMAIL, settings.NEXTCLOUD_INTEGRATIONS_APPROVAL_EMAILS) p.save() if self.data['screenshot']: screenshot = Screenshot.objects.create( url=self.cleaned_data['screenshot'], small_thumbnail=self.cleaned_data['screenshot_thumbnail'], ordering=1, app=p) screenshot.save() if not p.is_integration or p.approved or user.is_superuser: return app_id
def __init__(self, attrs=None): TextInput.__init__(self, attrs)
def __init__(self, attrs=None): widgets = (Select(attrs=attrs, choices=phone_prefixes), TextInput()) # pylint: disable=bad-super-call super(PhoneNumberPrefixWidget, self).__init__(widgets, attrs)
class Meta: model = City #only one field we want to use fields = ['name'] widgets = {'name' : TextInput(attrs={'class' : 'input', 'placeholder' : 'City Name'})}
class Meta: model = PsychiatricInfo fields = '__all__' widgets = { 'guardian_name': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 80, required: true' }), 'guardian_relation': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 120, required: true' }), 'guardian_address': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 180, required: true' }), 'guardian_phone': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 120, required: true' }), 'community_contact_name': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 80, required: true' }), 'community_contact_phone': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 120, required: true' }), 'assent': RadioSelect, 'signature_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter, ' 'parser: myparser, ' 'required: true, ' 'editable: false, ' 'width: 110' }), 'disease_begin_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser, ' 'required: true, ' 'editable: false,' 'width: 110' }), 'symptom': CheckboxSelectMultiple, 'symptom_other': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 80' }), 'cure_outpatient': RadioSelect, 'drug_first_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser, ' 'required: true, ' 'editable: false,' 'width: 110' }), 'cure_hospital': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'diagnose': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 120, required: true' }), 'diagnose_hospital': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 120, required: true' }), 'diagnose_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser, ' 'required: true, ' 'editable: false,' 'width: 110' }), 'cure_effect': RadioSelect, 'social_effect_minor': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'social_effect_trouble': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'social_effect_disaster': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'social_effect_self_injury': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'social_effect_suicide': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'lock': RadioSelect, 'economy': RadioSelect, 'doctor_advice': Textarea( attrs={ 'class': 'easyui-textbox', 'data-options': 'multiline:true, width: 500, height: 100' }), 'fill_table_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser, ' 'required: true, ' 'editable: false,' 'width: 110' }), 'doctor_signature': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 80, required: true' }), }
class URLAdminInline(admin.TabularInline): model = URL extra = 1 formfield_overrides = { models.CharField: {'widget': TextInput(attrs={'size': '100'})} }
class Meta: model = Aftercare fields = '__all__' widgets = { 'visit_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser,' 'width: 100,' 'required: true, editable: false' }), 'dangerousness': RadioSelect, 'now_symptom': CheckboxSelectMultiple, 'now_symptom_extra': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 128' }, ), 'insight': RadioSelect, 'sleep_situation': RadioSelect, 'diet_situation': RadioSelect, 'society_function_individual_life_care': RadioSelect, 'society_function_housework': RadioSelect, 'society_function_productive_work': RadioSelect, 'society_function_learn_ability': RadioSelect, 'society_function_social_interpersonal': RadioSelect, 'disease_family_society_effect_mild_disturbance': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'required: true, ' 'width: 40' }), 'disease_family_society_effect_disturbance': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'disease_family_society_effect_accident': TextInput(attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }, ), 'disease_family_society_effect_autolesion': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'disease_family_society_effect_attempted_suicide': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'disease_family_society_effect_nothing': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, required: true' }), 'lock_situation': RadioSelect, 'hospitalized_situation': RadioSelect, 'last_hospitalized_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser,' 'width: 100, editable: false' }), 'laboratory_examination': RadioSelect, 'laboratory_examination_yes': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 200' }, ), 'take_medicine_compliance': RadioSelect, 'medicine_untoward_effect': RadioSelect, 'medicine_untoward_effect_yes': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 200' }, ), 'treatment_effect': RadioSelect, 'transfer_treatment': RadioSelect, 'transfer_treatment_reason': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 200' }, ), 'transfer_treatment_institution': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 200' }, ), 'take_medicine_1': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 100' }), 'take_medicine_1_per': RadioSelect, 'take_medicine_1_time': TextInput(attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40' }, ), 'take_medicine_1_mg': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, precision: 1' }), 'take_medicine_2': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 100' }), 'take_medicine_2_per': RadioSelect, 'take_medicine_2_time': TextInput(attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40' }, ), 'take_medicine_2_mg': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, precision: 1' }), 'take_medicine_3': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 100' }), 'take_medicine_3_per': RadioSelect, 'take_medicine_3_time': TextInput(attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40' }), 'take_medicine_3_mg': TextInput( attrs={ 'class': 'easyui-numberbox', 'data-options': 'width: 40, precision: 1' }), 'recovery_measure': CheckboxSelectMultiple, 'recovery_measure_extra': TextInput(attrs={ 'class': 'easyui-textbox', 'data-options': 'width: 100' }, ), 'visit_classification': RadioSelect, 'next_visit_date': TextInput( attrs={ 'class': 'easyui-datebox', 'data-options': 'formatter: myformatter,' 'parser: myparser,' 'require: true,' 'width: 100, editable: false' }), 'doctor_signature': TextInput( attrs={ 'class': 'easyui-textbox', 'data-options': 'required: true, width: 100, required: true' }), }
class Meta: model = Post fields = ('text', ) widgets = { 'text': TextInput(attrs={'id': 'input_post'}), }
class Meta: model = TaskParameter fields = ['name', 'description'] widgets = {'description': TextInput()}
class Meta: model = Accepted fields = ('description', 'comment', 'history', 'etymology', 'culture', 'url', 'url_name', 'common_name', 'local_name', 'bloom_month', 'fragrance', 'altitude') labels = { 'description': 'Description', 'comment': 'Comment', 'history': 'History', 'etymology': 'Etymology', 'culture': 'Culture', 'url': 'Link to an online publication', 'url_name': 'Name of source', 'common_name': 'Common name', 'local_name': 'Local name', 'bloom_month': 'Bloom month', 'fragrance': 'Fragrance', 'altitude': 'Altitude', } widgets = { 'common_name': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px', }), 'local_name': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px', }), 'bloom_month': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px', }), 'fragrance': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px' }), 'altitude': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px' }), 'description': Textarea(attrs={ 'cols': 52, 'rows': 3, 'style': 'font-size: 13px' }), 'comment': Textarea(attrs={ 'cols': 52, 'rows': 3, 'style': 'font-size: 13px' }), 'history': Textarea(attrs={ 'cols': 52, 'rows': 3, 'style': 'font-size: 13px' }), 'etymology': Textarea(attrs={ 'cols': 52, 'rows': 3, 'style': 'font-size: 13px' }), 'culture': Textarea(attrs={ 'cols': 52, 'rows': 3, 'style': 'font-size: 13px' }), 'url': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px' }), 'url_name': TextInput(attrs={ 'size': 50, 'style': 'font-size: 13px', }), } # help_texts = { # 'common_name': 'Common name', # 'local_name': 'Native name', # 'bloom_month': 'Months bloomed in the wild, comma separated', # 'fragrance': 'Fragrance', # 'altitude':'Altitude above sea level in feet', # 'description':'Description', # 'comment':'Any comment related to this species', # 'history':'History', # 'etymology':'Etymology', # 'url':'Link to a useful information', # 'urlname':'Name of URL', # 'culture':'Culture and growing condition, light level, temperature, relative huimidity, winter rest, etc', # } error_messages = {}
class Meta: model = User fields=['username','password1','password2'] widgets = { 'username': TextInput(attrs={'class':'form-control'}), }
class Meta: model = SpcImages rank = forms.IntegerField(initial=5) fields = ( 'author', 'source_url', 'image_url', 'source_file_name', 'name', 'awards', 'variation', 'form', 'text_data', 'description', 'certainty', 'rank', 'credit_to', 'is_private', 'image_file', 'quality') labels = { 'author': "Name that has been used to credit your photos. Warning: Your account will be removed if you select a name that is not yours!", # 'author':'Your name for credit: select a name, if not exists, see next box', 'source_url': 'Link to source', 'credit_to': 'or, credit name. Enter only when author does not exist in the dropdown list.', 'image_url': 'Image URL', 'source_file_name': 'Alternate name, e.g. a synonym', 'name': 'Clonal name', 'awards': 'Awards', 'quality': 'Quality', 'variation': 'Varieties', 'form': 'Form', 'certainty': 'Certainty', 'rank': 'Rank', 'text_data': 'Comment', 'description': 'Tags', 'is_private': 'Private photo', } widgets = { 'source_url': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', 'autocomplete': 'off', }), 'credit_to': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'image_url': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', 'autocomplete': 'off', }), 'source_file_name': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'name': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'awards': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'variation': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'form': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'text_data': Textarea(attrs={'cols': 37, 'rows': 4}), 'description': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), 'certainty': TextInput(attrs={'size': 35, 'style': 'font-size: 13px', }), # 'is_private': CheckboxInput(attrs={'class': 'required checkbox form-control'}), } choices = { 'rank': CHOICES, 'quality': QUALITY, 'is_private': PRIVATE, } # help_texts = { # # 'author': 'The name for credit attribution', # 'credit_to': 'Enter the photo owner neme here if it is not listed under author', # 'source_url': 'The URL where the photo is uploaded from, eg Facebook post', # 'image_url': "Right click on the image and select 'copy image address'", # 'source_file_name': 'Identified name if differs from the accepted name for the species, e.g. a synonym or undescribed/unpublished or unregistered name. (Put infra specific if exists in Variety box below.', # 'name': 'Clonal name of the plant', # 'awards': 'Awards received, comma separated', # 'variation': 'Informal variations (unpublished), or infra specific of synonym.', # 'form': 'E.g. color forms, peloric, region...', # 'text_data': 'Any comment you may have about this photo. When, where or month it was taken, history of this plant, etc.', # 'description': 'Short description of the plant. E.g. aroma, color, pattern, shape...', # 'certainty': 'Put one or more ? to show level of certainty', # 'rank': 'Range from 9 (highest quality to 1 (lowest). Set rank = 0 if you reject the identity of the photo', # } error_messages = { # 'author': { # 'required': _("Please select a name for credit attribution."), # }, 'image_url': { 'required': _("Please enter, the url of the image (right click and select 'copy image address'."), }, }
class Meta: model = BillModel fields = [ 'vendor', 'xref', 'date', 'terms', 'cash_account', 'prepaid_account', 'unearned_account', ] widgets = { 'date': DateInput( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'placeholder': _('Bill Date (YYYY-MM-DD)...'), 'id': 'djl-bill-date-input' }), 'amount_due': TextInput( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'placeholder': '$$$', 'id': 'djl-bill-amount-due-input' }), 'xref': TextInput( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES + ' is-large', 'placeholder': 'External Reference Number...', 'id': 'djl-bill-xref-input' }), 'terms': Select( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES + ' is-small', 'id': 'djl-bill-create-terms-select-input' }), 'vendor': Select( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'id': 'djl-bill-create-vendor-select-input' }), 'cash_account': Select( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'id': 'djl-bill-cash-account-input' }), 'prepaid_account': Select( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'id': 'djl-bill-prepaid-account-input' }), 'unearned_account': Select( attrs={ 'class': DJANGO_LEDGER_FORM_INPUT_CLASSES, 'id': 'djl-bill-unearned-account-input' }), }
class Meta: model = ProfileUser fields = ('medical_specialty', 'medical_emphasis', 'professional_abstract', 'patient_abstract', 'blood_group', 'sex', 'nationality', 'whatsapp', 'date_birth', 'country', 'city', 'image', 'professional_register', 'blog', 'twitter', 'facebook', 'linkedin', 'you_tube', 'google_plus', 'instagram') widgets = { 'medical_specialty': forms.Select(attrs={ 'class': 'form-control', 'style': 'width:50%' }), 'medical_emphasis': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:50%', 'placeholder': _(u"ej: educación") }), 'professional_abstract': Textarea( attrs={ 'cols': 50, 'rows': 6, 'class': 'form-control', 'style': 'width:100%', 'placeholder': _(u"escribe aquí un resumen de tu experiencia profesional") }), 'patient_abstract': Textarea( attrs={ 'cols': 50, 'rows': 6, 'class': 'form-control', 'style': 'width:100%', 'placeholder': _(u"escribe aquí un resumen de tu historial médico") }), 'blood_group': forms.Select(attrs={ 'class': 'form-control', 'style': 'width:30%' }), 'sex': forms.Select(attrs={ 'class': 'form-control', 'style': 'width:30%' }), 'nationality': TextInput(attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:30%' }), 'date_birth': DateInput(format='%d/%m/%Y', attrs={ 'class': 'form-control', 'id': 'datePickerinit', 'style': 'width:50%' }), 'whatsapp': TextInput(attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:60%' }), 'country': forms.Select(attrs={'style': 'width:60%'}), 'city': forms.Select(attrs={'style': 'width:60%'}), 'image': FileInput(attrs={ 'maxlength': 50, 'style': 'width:90%' }), 'professional_register': TextInput(attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:48%' }), 'blog': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _(u"tublog.com") }), 'twitter': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _(u"twitter.com/tucuenta") }), 'facebook': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _(u"facebook.com/tucuenta") }), 'linkedin': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _(u"linkedin.com/tucuenta") }), 'you_tube': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _(u"youtube.com/tucuenta") }), 'google_plus': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _("") }), 'instagram': TextInput( attrs={ 'maxlength': 125, 'class': 'form-control', 'style': 'width:57%', 'placeholder': _("") }), }
class DocumentCreateForm(TranslationModelForm): """ The document upload form. """ permissions = forms.CharField(widget=HiddenInput(attrs={ 'name': 'permissions', 'id': 'permissions' }), required=True) resource = forms.CharField(required=False, label=_("Link to"), widget=TextInput(attrs={ 'name': 'title__contains', 'id': 'resource' })) class Meta: model = Document fields = ['title', 'doc_file', 'doc_url'] widgets = { 'name': HiddenInput(attrs={ 'cols': 80, 'rows': 20 }), } def clean_permissions(self): """ Ensures the JSON field is JSON. """ permissions = self.cleaned_data['permissions'] try: return json.loads(permissions) except ValueError: raise forms.ValidationError(_("Permissions must be valid JSON.")) def clean(self): """ Ensures the doc_file or the doc_url field is populated. """ cleaned_data = super(DocumentCreateForm, self).clean() doc_file = self.cleaned_data.get('doc_file') doc_url = self.cleaned_data.get('doc_url') if not doc_file and not doc_url: raise forms.ValidationError(_("Document must be a file or url.")) if doc_file and doc_url: raise forms.ValidationError( _("A document cannot have both a file and a url.")) return cleaned_data def clean_doc_file(self): """ Ensures the doc_file is valid. """ doc_file = self.cleaned_data.get('doc_file') if doc_file and not os.path.splitext(doc_file.name)[1].lower( )[1:] in settings.ALLOWED_DOCUMENT_TYPES: raise forms.ValidationError(_("This file type is not allowed")) return doc_file
def create_model(name,parent_model_name=None,fields=None,inherit=models.Model,app_label=None,module='',options=None,admin_parent=None,admin_opts=None): class Meta: pass if app_label: # app_label must be set using the Meta inner class setattr(Meta, 'app_label', app_label) # Update Meta with any options that were provided if options is not None: for key, value in options.items(): setattr(Meta, key, value) # Set up a dictionary to simulate declarations within a class attrs = {'__module__': module, 'Meta': Meta} # Add in any fields that were provided if fields: attrs.update(fields) # Create the class, which automatically triggers ModelBase processing model = type(name, (inherit,), attrs) # Create an Admin class if admin options were provided FORMFIELD_OVERRIDES = { models.CharField: {'widget': TextInput(attrs={'size':'63'})}, models.TextField: {'widget': Textarea(attrs={'rows':2, 'cols':61})}, jsonfield.JSONField: {'widget': Textarea(attrs={'rows':2, 'cols':61})}, } if admin_opts is not None: # attrs = { # 'formfield_overrides' : FORMFIELD_OVERRIDES, # 'model': model, # 'extra': 0, # '__module__': 'apps.' + app_label + '.admin', # 'sortable_options' : 'parent' # } admin_model_inline = type(parent_model_name + "TranslationInline", (admin.StackedInline,), { 'formfield_overrides' : FORMFIELD_OVERRIDES, 'model': model, 'readonly_fields' : ['parent','language'], 'extra': 0, '__module__': 'apps.' + app_label + '.admin', 'sortable_options' : 'parent' }) # Class for hidding model in main list class HiddenModelAdmin(admin.ModelAdmin): def has_module_permission(self, request): return False admin_model = type(parent_model_name + "TranslationAdmin", (HiddenModelAdmin,), { '__module__': 'apps.' + app_label + '.admin', 'formfield_overrides' : FORMFIELD_OVERRIDES, }) admin.site.register(model, admin_model) # AdminModelOfInline = type(parent_model_name + "TranslationInline", (inherit,), attrs) def edit(self, obj=None): if obj.pk: url = reverse('admin:%s_%s_change' % (obj._meta.app_label, obj._meta.model_name), args=[force_text(obj.pk)]) url = '<a href="{url}">{text}</a>'.format(url=url,text='Редактировать',) return mark_safe(url) return _("Нажмите сохранить и продолжить, для получения ссылки редактирования") readonly_fields = ['edit',] fields = ['edit'] setattr(admin_model_inline, 'edit', edit) setattr(admin_model_inline, 'readonly_fields', readonly_fields) setattr(admin_model_inline, 'fields', fields) if admin_parent != None: if len(admin_parent.inlines) == 0: admin_parent.inlines = [] admin_parent.inlines.append(admin_model_inline) for key, value in admin_opts: setattr(admin_model_inline, key, value) return model
class Meta: model = Post fields = ('header', ) widgets = {'header': TextInput(attrs={'class': 'form-control'})}
def test_sub_widget_html_safe(self): widget = TextInput() subwidget = next(widget.subwidgets("username", "John Doe")) self.assertTrue(hasattr(subwidget, "__html__")) self.assertEqual(force_text(subwidget), subwidget.__html__())
class Meta: model = Patient fields = [ 'fname', 'lname', 'gender', 'birthday', 'phone', 'email', 'street', 'city', 'state', 'zipcode', 'notes', ] widgets = { 'fname': TextInput(attrs=standardreq), 'lname': TextInput(attrs=standardreq), 'gender': Select(attrs=standardreq), 'birthday': DateInput(attrs={ 'class': 'form-control', 'required': "", 'autocomplete': "off" }), 'email': EmailInput(attrs=standard), 'street': TextInput(attrs=standard), 'phone': TextInput( attrs={ 'class': 'form-control', 'number': 'true', 'minlength': '10', 'maxlength': '10' }), 'city': TextInput(attrs=standard), 'state': TextInput(attrs={ 'class': 'form-control', 'minlength': '2', 'maxlength': '2' }), 'zipcode': TextInput( attrs={ 'class': 'form-control', 'minlength': '5', 'maxlength': '5', 'number': 'true' }), 'notes': Textarea( attrs={ 'class': 'form-control autoExpand', 'rows': '2', 'data-min-rows': '2' }), }
def test_sub_widget_html_safe(self): widget = TextInput() subwidget = next(widget.subwidgets('username', 'John Doe')) self.assertTrue(hasattr(subwidget, '__html__')) self.assertEqual(force_text(subwidget), subwidget.__html__())
def antibot_field(): field = TextInput(attrs={ 'hidden': '' }) return field.render("antibot_field", "")