def __init__(self, *args, **kwargs): super(Word.ComponentForm, self).__init__(*args, **kwargs) self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5}) self.fields['max_size'].label=mark_safe("Max size")
class Meta: # When used inside djangocms-text-ckeditor # this causes the label field to be prefilled with the selected text. widgets = { 'code': Textarea(attrs={'class': 'js-ckeditor-use-selected-text'}), }
def as_textarea(self, attrs=None, **kwargs): "Returns a string of HTML for representing this as a <textarea>." return self.as_widget(Textarea(), attrs, **kwargs)
def __init__(self, *args, **kwargs): kwargs['required'] = False kwargs['widget'] = Textarea() EmailListField.__init__(self, *args, **kwargs)
class ProjectForm(forms.ModelForm): def _init_file_field(self, field_name): new_values = [x.name for x in self.files.getlist(field_name) ] if self.files else [] deleted_values = self.data.getlist('deleted_%s' % field_name) if self.data else [] prev_values = self.data.getlist('prev_%s' % field_name) if self.data else [] self.file_fields[field_name] = {} self.file_fields[field_name]['new_values'] = new_values self.file_fields[field_name]['deleted_values'] = deleted_values self.file_fields[field_name]['prev_values'] = prev_values def __init__(self, *args, **kwargs): super(forms.ModelForm, self).__init__(*args, **kwargs) if args and u'links_title' in args[0].keys(): self.resources_title = args[0].getlist('links_title') if args and u'links_url' in args[0].keys(): self.resources_url = args[0].getlist('links_url') if 'instance' in kwargs: instance = kwargs['instance'] if instance.category: self.fields['category'].initial = instance.category.id file_fields_aux = [ 'main_image', 'fritzing_files', 'code', 'examples', 'other_images' ] for ff in file_fields_aux: self._init_file_field(ff) file_fields = {} title = forms.CharField(help_text=_('The title of your project'), label=_('Title')) id = forms.IntegerField(widget=forms.HiddenInput(), required=False) description = forms.CharField( label=_('Description'), help_text=_( 'A very short description/subheadline of what your project is about' ), widget=Textarea(attrs={'rows': '3'})) instructions = forms.CharField( label=_('Body'), help_text= _('Give a detailed description of your project, including instructions on how to build it' ), widget=MarkItUpWidget(markitup_set='projects/sets')) main_image = forms.ImageField( required=False, label=_('Header Image'), help_text=_( 'A representative screenshot or photograph of your project'), widget=forms.FileInput(attrs={'size': '35'})) fritzing_files = forms.FileField( required=False, help_text=_( 'Upload your Fritzing sketch (.fz) and other Fritzing files here'), widget=forms.FileInput(attrs={'size': '35'})) code = forms.FileField( required=False, help_text=_( 'Add any code that is part of your project (e.g., for the Arduino)' ), ) examples = forms.FileField( label=_('Other Files'), required=False, help_text=_('Add any other files that help documenting your project'), ) other_images = forms.ImageField( required=False, label=_('Image Gallery'), help_text=_('Add a set of images and photos')) resource = ResourceField( required=False, label=_('External links'), help_text=_('Some links to external websites related to your project')) resources_title = [] resources_url = [] license = forms.ModelChoiceField( empty_label=None, initial=_get_default_license(), queryset=License.objects.filter(is_active=True), help_text=_(""" Pick a license for your documentation (<a target="_blank" href="http://creativecommons.org/licenses/">More about CC licenses</a>)<br/> <ul> <li><a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/"> Creative Commons Attribution Share-Alike (default) </a></li> <li><a target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"> Creative Commons Attribution Non-Commercial Share-Alike </a></li> </ul> """)) ''' HELP FUNCTIONS TO DEAL WITH FILES ''' def _eq_lists(self, list1, list2): if len(list1) != len(list2): return False else: for l1 in list1: if l1 not in list2: return False return True def _is_empty(self, list): return not list def _something_changed(self, new_values, deleted_values): return not self._is_empty(new_values) \ or not self._is_empty(deleted_values) def something_changed(self, field): return self._something_changed( self.file_fields[field]['new_values'], self.file_fields[field]['deleted_values']) def _all_removed(self, prev_values, deleted_values): return self._eq_lists(prev_values, deleted_values) def all_removed(self, field): return self._all_removed(self.file_fields[field]['prev_values'], self.file_fields[field]['deleted_values']) def _something_added(self, new_values): return not self._is_empty(new_values) def removed(self, field): return self.file_fields[field]['deleted_values'] def non_deleted_previous_files(self, field): list1 = self.file_fields[field]['prev_values'] list2 = self.file_fields[field]['deleted_values'] return [item for item in list1 if not item in list2] def _clean_file_aux(self, field_name, required=False): data = self.cleaned_data[field_name] new_values = self.file_fields[field_name]['new_values'] deleted_values = self.file_fields[field_name]['deleted_values'] prev_values = self.file_fields[field_name]['prev_values'] if self._all_removed(prev_values, deleted_values) \ and not self._something_added(new_values) \ and required: raise ValidationError( self.fields[field_name].error_messages['required']) return data def clean_main_image(self): return self._clean_file_aux('main_image') def clean_fritzing_files(self): return self._clean_file_aux('fritzing_files', required=True) def clean_code(self): return self._clean_file_aux('code') def clean_examples(self): return self._clean_file_aux('examples') def clean_other_images(self): return self._clean_file_aux('other_images') def clean_title(self): title = self.cleaned_data['title'] proys = Project.objects.filter(title=title) for proy in proys: if not self.data['id'] or proy.id != int(self.data['id']): raise ValidationError( _('There\'s already a project with that title, please choose a new one' )) return title def clean_id(self): # don't want this value to populate the project instance return None def clean_tags(self): return self.cleaned_data['tags'].lower() def clean_resource(self): indexes_to_remove = [] print self.resources_title # if the whole field was not binded, just remove it from the data to validate for i in range(len(self.resources_url)): if self.resources_url[i].strip() == u'': if self.resources_title[i].strip() != u'': raise ValidationError( _('If the title is defined, the url must be defined as well' )) else: indexes_to_remove.append(i) for i in indexes_to_remove: del self.resources_title[i] del self.resources_url[i] # now, let's validate the urls final_urls = [] for url in self.resources_url: #url = URLField(required=True,verify_exists=True).clean(url) final_urls.append(URLField().clean(url)) # if a title was not provided, but its url was, populate it whit the same value as the url final_titles = [] idx = 0 for title in self.resources_title: final_titles.append(final_urls[idx] if title.strip() == u'' else title) idx = idx + 1 self.resources = [(final_titles[i], final_urls[i]) for i in range(len(final_titles))] print self.resources return '' class Meta: model = Project fields = ( 'id', 'title', 'description', 'instructions', 'difficulty', 'tags', 'license', 'category', )
'Custom CSS', "Define some custom css you can use to override the default css.", 2000, can_preview=True) USE_CUSTOM_CSS = Setting( 'USE_CUSTOM_CSS', False, CSS_SET, dict(label=_("Use custom CSS"), help_text=_("Do you want to use custom CSS."), required=False)) CUSTOM_CSS = Setting( 'CUSTOM_CSS', '', CSS_SET, dict(label=_("Custom CSS"), help_text=_("Your custom CSS."), widget=Textarea(attrs={'rows': '25'}), required=False)) HEAD_AND_FOOT_SET = SettingSet( 'headandfoot', 'Header and Footer', "Adds a custom header and/or footer to your page", 2000, can_preview=True) USE_CUSTOM_HEADER = Setting( 'USE_CUSTOM_HEADER', False, HEAD_AND_FOOT_SET, dict(label=_("Use custom header"), help_text=_("Do you want to use a custom header."), required=False))
class AbstractJobOfferForm(forms.ModelForm): joboffer_position = forms.CharField( label=FieldJobOffer.POSITION, widget=CKEditorWidget(config_name='titles')) joboffer_lead = forms.CharField(label=FieldJobOffer.LEAD, widget=CKEditorWidget(config_name='leads')) joboffer_image_copyright = forms.CharField( label=FieldJobOffer.IMAGE_COPYRIGHT, widget=Textarea(attrs={ 'style': 'height : auto', 'rows': 2 }), required=False) joboffer_description = forms.CharField(label=FieldJobOffer.DESCRIPTION, widget=CKEditorUploadingWidget()) joboffer_keywords = HistoryTagField(label=FieldJobOffer.KEYWORDS) joboffer_connected_projects = forms.ModelMultipleChoiceField( label=FieldJobOffer.CONNECTED_PROJECTS, required=False, queryset=Project.objects.all(), widget=autocomplete.ModelSelect2Multiple(url='project-autocomplete') ) # related_name field has to be defined in the form def __init__(self, *args, **kwargs): if kwargs.get('instance'): initial = kwargs.setdefault('initial', {}) # the widget for a ModelMultipleChoiceField expects a list of primary key for the selected data initial['joboffer_connected_projects'] = [ project.project_id for project in kwargs['instance'].joboffer_connected_projects.all() ] super(AbstractJobOfferForm, self).__init__(*args, **kwargs) def clean_joboffer_date_end(self): try: dateFrom = self.cleaned_data.get('joboffer_date_start', None) dateTo = self.cleaned_data.get('joboffer_date_end', None) except: raise forms.ValidationError(MessageJobOffer.INCORRECT_DATE) if dateFrom is not None and dateTo is not None: if dateFrom > dateTo: raise forms.ValidationError(MessageJobOffer.INCORRECT_PERIOD) return dateTo def _save_m2m(self): instance = self.instance instance.joboffer_connected_projects.clear() for project in self.cleaned_data['joboffer_connected_projects']: instance.joboffer_connected_projects.add(project) super(AbstractJobOfferForm, self)._save_m2m() class Meta: abstract = True model = JobOffer fields = ('__all__') widgets = { 'joboffer_institution': autocomplete.ModelSelect2(url='institution-autocomplete'), 'joboffer_type': autocomplete.ModelSelect2(url='joboffertype-autocomplete'), 'joboffer_disciplines': autocomplete.ModelSelect2Multiple( url='jobofferdiscipline-autocomplete'), 'joboffer_cities': autocomplete.ModelSelect2Multiple(url='city-autocomplete'), } exclude = ('joboffer_position_text', 'joboffer_position_slug', 'joboffer_date_add', 'joboffer_date_edit', 'joboffer_added_by', 'joboffer_modified_by', 'joboffer_authorizations')
class AnswerForm(ModelForm): text = forms.CharField(label='Your answer', widget=Textarea()) class Meta: model = Answer fields = ('text', )
class MessageForm(forms.Form): subject = CharField(max_length=100) body = CharField(max_length=1500, widget=Textarea())
def formfield_for_dbfield(self, db_field, **kwargs): """ Renvoyer le champ utilisé pour un formulaire du champ """ if db_field.name == 'text': kwargs['widget'] = Textarea() return super(MessageAdmin, self).formfield_for_dbfield(db_field, **kwargs)
class Meta: model = Merchant fields = [ 'company', 'salutation', 'f_name', 'l_name', 'email', 'mobile', 'website', 'street', 'state', 'city', 'zip_code', 'industry', 'salay', 'description', 'bank', 'lead_source', 'contact_method', ] widgets = { 'company': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Company', }), 'salutation': Select(attrs={ 'class': 'form-control', 'placeholder': 'Salutation', }), 'f_name': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name', }), 'l_name': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Last Name', }), 'email': EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email', }), 'mobile': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Mobile', }), 'website': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Website', }), 'street': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Street', }), 'state': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'State', }), 'zip_code': NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'Zip Code', }), 'city': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'City', }), 'industry': Select(attrs={ 'class': 'form-control', 'placeholder': 'Industry', }), 'salay': NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'Monthly Sales (MYR)', }), 'description': Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Description', 'rows': 3, }), 'bank': Select(attrs={ 'class': 'form-control', 'placeholder': 'Bank', }), 'lead_source': Select(attrs={ 'class': 'form-control', 'placeholder': 'Lead Source', }), 'contact_method': Select( attrs={ 'class': 'form-control', 'placeholder': 'Prefered Method of Contact', }), }
def __init__(self, question, *args, **kwargs): super(EssayForm, self).__init__(*args, **kwargs) self.fields["answers"] = forms.CharField(widget=Textarea( attrs={'style': 'width:100%'}))
def formfield_for_dbfield(self, db_field, **kwargs): formfield = super(ApplicationAdmin, self).formfield_for_dbfield(db_field, **kwargs) if db_field.max_length > 255: formfield.widget = Textarea(attrs=formfield.widget.attrs) return formfield
def _create_field(self): field = super()._create_field() field.widget = Textarea() return field
}, models.CharField: { 'widget': TextInput(attrs={ 'width': '300px', 'style': 'width:300px' }) }, models.URLField: { 'widget': TextInput(attrs={ 'width': '300px', 'style': 'width:300px' }) }, models.TextField: { 'widget': Textarea(attrs={ 'rows': 2, 'cols': 60 }) }, } formfields_small = { models.ForeignKey: { 'widget': Select(attrs={ 'width': '200px', 'style': 'width:200px' }) }, models.ManyToManyField: { 'widget': SelectMultiple(attrs={ 'size': '3',
class BaseADMDocumentForm(BaseAdminCRUDForm): slug = forms.SlugField(label="Slug") domain = forms.CharField(label="Project Name (blank applies to all projects)", required=False) name = forms.CharField(label="Name") description = forms.CharField(label="Description", required=False, widget=Textarea(attrs=dict(style="height:80px;width:340px;")))
class Meta: model = Oportunidad fields = ('titulo', 'carga_horaria', 'remuneracion', 'remuneracion_min', 'remuneracion_max', 'ciudad', 'pais', 'distrito', 'fecha_cese', 'resumen', 'edad_desde', 'edad_hasta', 'genero', 'carga_horaria', 'tipo_puesto', 'estado', 'estado_oportunidad', 'grado_estudio', 'idioma', 'conocimiento', 'carrera', 'direccion_map', 'longitud', 'latitud', 'tipo_carrera', 'rama_carrera', 'area_experiencia', 'tiempo_experiencia', 'numero_vacantes', 'beneficio', 'nivel_academico') widgets = { 'titulo': TextInput( attrs={ 'placeholder': 'Escriba el título de su vacante', 'class': 'form-control' }), 'carga_horaria': RadioSelect(attrs={'class': 'form-check-input'}), 'tipo_puesto': RadioSelect(attrs={ 'class': 'form-check-input', 'required': 'required' }), 'remuneracion': RadioSelect(attrs={'class': 'form-check-input'}), 'resumen': Textarea(attrs={ 'class': 'form-control', 'required': 'required' }), 'remuneracion_min': TextInput(attrs={ 'placeholder': 'Valor mínimo', 'class': 'form-control' }), 'remuneracion_max': TextInput(attrs={ 'placeholder': 'Valor máximo', 'class': 'form-control' }), 'fecha_cese': Input(attrs={ 'type': 'date', 'class': 'form-control' }), 'direccion_map': TextInput(attrs={ 'placeholder': 'Dirección', 'class': 'form-control' }), 'distrito': Select(attrs={'class': 'form-control'}), 'pais': Select(attrs={'class': 'form-control'}), 'ciudad': Select(attrs={'class': 'form-control'}), 'rama_carrera': SelectMultiple( attrs={ 'class': 'select2 m-b-10 select2-multiple', 'style': 'width:100%;', 'multiple': 'multiple', 'required': 'required', 'data-placeholder': 'Seleccione una o más opciones' }), 'idioma': SelectMultiple( attrs={ 'class': 'select2 m-b-10 select2-multiple', 'style': 'width:100%;', 'multiple': 'multiple', 'data-placeholder': 'Seleccione una o más opciones' }), 'grado_estudio': CheckboxSelectMultiple(attrs={ 'class': 'form-check-input', 'required': 'required' }), 'nivel_academico': CheckboxSelectMultiple(attrs={'class': 'form-control'}), 'conocimiento': SelectMultiple( attrs={ 'class': 'select2 m-b-10 select2-multiple', 'style': 'width:100%;', 'multiple': 'multiple', 'data-placeholder': 'Seleccione una o más opciones' }), 'estado_oportunidad': Select(attrs={ 'class': 'form-control', 'disabled': 'disabled' }), 'edad_desde': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Desde', 'type': 'number' }), 'edad_hasta': TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Hasta', 'type': 'number' }), 'numero_vacantes': TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Número de vacantes', 'type': 'number', 'value': '0' }), 'genero': Select(attrs={'class': 'form-control'}), 'division': Select(attrs={'class': 'form-control'}), 'area_experiencia': Select(attrs={'class': 'form-control'}), 'tiempo_experiencia': Select(attrs={'class': 'form-control'}), 'beneficio': CheckboxSelectMultiple(attrs={'class': 'form-check-input'}), }
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['description'].widget = Textarea(attrs={ 'cols': '80', 'rows': '5' })
class BasePleaForm(SplitStageForm): PLEA_CHOICES = ( ('guilty', _('Guilty')), ('not_guilty', _('Not guilty')), ) split_form_options = {"trigger": "guilty", "nojs_only": True} guilty = forms.ChoiceField( choices=PLEA_CHOICES, widget=RadioSelect(), required=True, error_messages={"required": ERROR_MESSAGES["PLEA_REQUIRED"]}) guilty_extra = forms.CharField( label=_("Mitigation"), widget=Textarea(attrs={ "class": "form-control", "rows": "4" }), help_text=_( "Is there something you would like the court to consider?"), required=False, max_length=5000) not_guilty_extra = forms.CharField( label=_("Not guilty because?"), widget=Textarea(attrs={ "class": "form-control", "rows": "4" }), help_text=_("Why do you believe you are not guilty?"), max_length=5000, error_messages={"required": ERROR_MESSAGES["NOT_GUILTY_REQUIRED"]}) interpreter_needed = forms.TypedChoiceField( widget=RadioSelect(renderer=DSRadioFieldRenderer), required=True, choices=YESNO_CHOICES["Oes/Nac oes"], coerce=to_bool, label=_("Do you need an interpreter in court?"), error_messages={ "required": ERROR_MESSAGES["INTERPRETER_NEEDED_REQUIRED"] }) interpreter_language = forms.CharField( widget=forms.TextInput(attrs={"class": "form-control"}), max_length=100, required=True, label="", help_text=_("If yes, tell us which language (include sign language):"), error_messages={ "required": ERROR_MESSAGES["INTERPRETER_LANGUAGE_REQUIRED"] }) disagree_with_evidence = forms.TypedChoiceField( widget=RadioSelect(renderer=DSRadioFieldRenderer), required=True, choices=YESNO_CHOICES["Ydw/Nac ydw"], coerce=to_bool, label= _("Do you disagree with any evidence from a witness statement in the notice we sent to you?" ), error_messages={ "required": ERROR_MESSAGES["DISAGREE_WITH_EVIDENCE_REQUIRED"] }) disagree_with_evidence_details = forms.CharField( label="", widget=Textarea(attrs={ "class": "form-control", "rows": "3" }), help_text= _("If yes, tell us the name of the witness (on the top left of the statement) and what you disagree with:" ), max_length=5000, error_messages={ "required": ERROR_MESSAGES["DISAGREE_WITH_EVIDENCE_DETAILS_REQUIRED"] }) witness_needed = forms.TypedChoiceField( widget=RadioSelect(renderer=DSRadioFieldRenderer), required=True, choices=YESNO_CHOICES["Hoffwn/Na hoffwn"], coerce=to_bool, label=_("Do you want to call a defence witness?"), help_text=_( "Someone who can give evidence in court supporting your case."), error_messages={"required": ERROR_MESSAGES["WITNESS_NEEDED_REQUIRED"]}) witness_details = forms.CharField( label="", widget=Textarea(attrs={ "class": "form-control", "rows": "3" }), help_text= _("If yes, tell us the name, address and date of birth of any witnesses you want to call to support your case:" ), max_length=5000, error_messages={ "required": ERROR_MESSAGES["WITNESS_DETAILS_REQUIRED"] }) witness_interpreter_needed = forms.TypedChoiceField( widget=RadioSelect(renderer=DSRadioFieldRenderer), required=True, choices=YESNO_CHOICES["Oes/Nac oes"], coerce=to_bool, label=_("Does your witness need an interpreter in court?"), error_messages={ "required": ERROR_MESSAGES["WITNESS_INTERPRETER_NEEDED_REQUIRED"] }) witness_interpreter_language = forms.CharField( widget=forms.TextInput(attrs={"class": "form-control"}), max_length=100, required=True, label="", help_text=_("If yes, tell us which language (include sign language):"), error_messages={ "required": ERROR_MESSAGES["WITNESS_INTERPRETER_LANGUAGE_REQUIRED"] })
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['css'].widget = Textarea(attrs={ 'cols': '80', 'rows': '30' })
def __init__(self, *args, **kwargs): super(Image.ComponentForm, self).__init__(*args, **kwargs) self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5})
class Meta: model = models.Claim fields = ('reception_mean', 'type', 'cause', 'description', 'inmediate_solution') widgets = {'description': Textarea(attrs={'cols': 80, 'rows': 20})}
class Meta: model = Blog fields = ['title', 'content', "category"] widgets = {'content': Textarea({'cols': 80, 'rows': 15})}
class AbstractCompetitionForm(forms.ModelForm): competition_title = forms.CharField(label=FieldCompetition.TITLE, widget=CKEditorWidget(config_name='titles')) competition_lead = forms.CharField(label=FieldCompetition.LEAD, widget=CKEditorWidget(config_name='leads')) competition_image_copyright = forms.CharField(label=FieldCompetition.IMAGE_COPYRIGHT, widget=Textarea(attrs={'style' : 'height : auto', 'rows': 2}), required=False) competition_description = forms.CharField(label=FieldCompetition.DESCRIPTION, widget=CKEditorUploadingWidget()) competition_keywords = HistoryTagField(label=FieldCompetition.KEYWORDS) competition_connected_projects = forms.ModelMultipleChoiceField(label=FieldCompetition.CONNECTED_PROJECTS, required=False, queryset=Project.objects.all(), widget=autocomplete.ModelSelect2Multiple(url='project-autocomplete')) # related_name field has to be defined in the form def __init__(self, *args, **kwargs): if kwargs.get('instance'): initial = kwargs.setdefault('initial', {}) # the widget for a ModelMultipleChoiceField expects a list of primary key for the selected data initial['competition_connected_projects'] = [project.project_id for project in kwargs['instance'].competition_connected_projects.all()] super(AbstractCompetitionForm, self).__init__(*args, **kwargs) def _save_m2m(self): instance = self.instance instance.competition_connected_projects.clear() for project in self.cleaned_data['competition_connected_projects']: instance.competition_connected_projects.add(project) super(AbstractCompetitionForm, self)._save_m2m() class Meta: abstract = True model = Competition fields = ('__all__') widgets = { 'competition_institutions': autocomplete.ModelSelect2Multiple(url='institution-autocomplete'), 'competition_targets': autocomplete.ModelSelect2Multiple(url='targetgroup-autocomplete'), 'competition_connected_events' : autocomplete.ModelSelect2Multiple(url='event-autocomplete'), 'competition_city' : autocomplete.ModelSelect2(url='city-autocomplete'), } exclude=('competition_title_text', 'competition_title_slug', 'competition_date_add', 'competition_date_edit', 'competition_added_by', 'competition_modified_by', 'competition_authorizations')
class TaskUpdateForm(forms.Form): status = forms.ChoiceField(required=True, choices=TASK_STATUS_CHOICES) text = forms.CharField(widget=Textarea())
class PostForm_0(forms.Form): title = forms.CharField(required=True, help_text="Help text here") content = Textarea(attrs={'cols': 60, 'rows': 15})
class AppraisalForm(forms.ModelForm): def __init__(self, *args, **kwargs): reviewer = kwargs.pop('reviewer') super(AppraisalForm, self).__init__(*args, **kwargs) self.reviewer = reviewer class Meta: model = Appraisal exclude = () widgets = { 'start_date': JQueryUIDatepickerWidget, 'end_date': JQueryUIDatepickerWidget, 'due_date': JQueryUIDatepickerWidget, } # service_line = HrpModelMultipleChoiceField( # queryset=ServiceLine.objects.all(), # empty_label='-- All --', # required=False # ) employee_profile = EmployeeModelChoiceField( queryset=EmployeeProfile.objects.all(), empty_label='-- All --', required=False) comment = forms.CharField(widget=Textarea(attrs={'rows': 4})) def save(self, commit=True): instance = super(AppraisalForm, self).save(commit=False) edit = False if instance.id: edit = True if commit: # Check that measures/qns were uploaded first # if not AppraisalMeasure.objects.exists(): # raise ValidationError( # _('Measures/questions have not yet been setup.'), # code='no_measures' # ) instance.save() if edit is False: if instance.service_line: profiles = instance.service_line.employee_profiles.all() elif instance.employee_profile: profiles = profiles.filter( id__in=[instance.employee_profile.id]) else: profiles = EmployeeProfile.objects.all() for profile in profiles: if profile.reports_to: employee_appraisal = profile.appraisals.create( appraisal=instance, on_open_remarks=self.cleaned_data['comment']) flow = employee_appraisal.flows.create( from_reviewer=self.reviewer.profile, to_reviewer=profile) for measure in profile.position.measure_definitions.all( ): employee_appraisal.measures.create( measure=measure, reviewer=profile) return instance
class Meta: model = Post fields = ('title', 'content') widgets = { 'content': Textarea(attrs={'cols': 60, 'rows': 15}), }
dict( label="Show Upper Block", help_text="Check if your pages should display the upper sidebar block.", required=False)) SIDEBAR_UPPER_DONT_WRAP = Setting( 'SIDEBAR_UPPER_DONT_WRAP', False, SIDEBAR_SET, dict(label="Don't Wrap Upper Block", help_text="Don't wrap upper block with the standard style.", required=False)) SIDEBAR_UPPER_TEXT = Setting( 'SIDEBAR_UPPER_TEXT', u""" """, SIDEBAR_SET, dict(label="Upper Block Content", help_text=" The upper sidebar block. ", widget=Textarea(attrs={'rows': '10'}))) SIDEBAR_UPPER_RENDER_MODE = Setting( 'SIDEBAR_UPPER_RENDER_MODE', 'markdown', SIDEBAR_SET, dict(label=_("Upper block rendering mode"), help_text=_("How to render your upper block code."), widget=Select(choices=RENDER_CHOICES), required=False)) SIDEBAR_LOWER_SHOW = Setting( 'SIDEBAR_LOWER_SHOW', True, SIDEBAR_SET, dict( label="Show Lower Block", help_text="Check if your pages should display the lower sidebar block.", required=False))
class PublishForm(forms.Form): title = forms.CharField(max_length=64, required=True) synopsis = forms.CharField(max_length=312, required=True) content = forms.CharField(widget=Textarea(), required=True)