class UploadFileForm(forms.Form): title = forms.CharField(max_length=50) file = forms.ImageField()
class Meta: fields = "__all__" model = ImageLabel widgets = {'overlayed_image': forms.ImageField()}
class FrontpageForm(BaseControlForm, forms.Form): description = forms.CharField(label=_('Welcome message'), required=False, widget=forms.Textarea(attrs={ 'rows': 20, 'cols': 40 })) show_changes = forms.BooleanField(label=_('Show activity'), required=False) use_anonymous_page = forms.BooleanField( label=_('Use anonymous page'), required=False, help_text=_('Use separate page for anonymous users without books, ' 'people, groups and recent activity blocks.')) anonymous_message = forms.CharField( label=_('Anonymous page message'), required=False, widget=forms.Textarea(attrs={ 'rows': 8, 'cols': 40 }), help_text=_('Message for displaying on anonymous page.')) anonymous_email = forms.EmailField( label=_('Anonymous page email'), required=False, help_text=_('Email for displaying on anonymous page.')) anonymous_image = forms.ImageField( label=_("Anonymous page image"), required=False, help_text=_("Use image/png files."), widget=RemovableImageWidget( attrs={ 'label_class': 'checkbox-inline', 'input_class': 'group-image-removable' })) def clean_anonymous_image(self): data = self.cleaned_data['anonymous_image'] if data and data.content_type not in ['image/png']: raise forms.ValidationError("Wrong file content type.") return data @classmethod def initial_data(cls): _dict = {} try: f = open( '%s/templates/portal/welcome_message.html' % settings.BOOKTYPE_ROOT, 'r') _dict['description'] = unicode(f.read(), 'utf8') f.close() except IOError: _dict['description'] = '' _dict['show_changes'] = config.get_configuration( 'BOOKTYPE_FRONTPAGE_HISTORY', True) _dict['use_anonymous_page'] = config.get_configuration( 'BOOKTYPE_FRONTPAGE_USE_ANONYMOUS_PAGE') _dict['anonymous_message'] = config.get_configuration( 'BOOKTYPE_FRONTPAGE_ANONYMOUS_MESSAGE') _dict['anonymous_email'] = config.get_configuration( 'BOOKTYPE_FRONTPAGE_ANONYMOUS_EMAIL') _dict['anonymous_image'] = config.get_configuration( 'BOOKTYPE_FRONTPAGE_ANONYMOUS_IMAGE') return _dict def save_settings(self, request): static_root = settings.BOOKTYPE_ROOT config.set_configuration('BOOKTYPE_FRONTPAGE_HISTORY', self.cleaned_data['show_changes']) config.set_configuration('BOOKTYPE_FRONTPAGE_USE_ANONYMOUS_PAGE', self.cleaned_data['use_anonymous_page']) config.set_configuration('BOOKTYPE_FRONTPAGE_ANONYMOUS_MESSAGE', self.cleaned_data['anonymous_message']) config.set_configuration('BOOKTYPE_FRONTPAGE_ANONYMOUS_EMAIL', self.cleaned_data['anonymous_email']) # anonymous page image destination_filename = 'anonymous_image.png' destination_dir = '{0}/portal/frontpage/'.format(settings.MEDIA_ROOT) destination_file_path = '{dir}{filename}'.format( dir=destination_dir, filename=destination_filename) if 'anonymous_image_remove' in request.POST: os.remove(destination_file_path) config.del_configuration('BOOKTYPE_FRONTPAGE_ANONYMOUS_IMAGE') elif 'anonymous_image' in self.files: try: fh, fname = misc.save_uploaded_as_file( self.files['anonymous_image']) if not os.path.exists(destination_dir): os.makedirs(destination_dir) shutil.move(fname, destination_file_path) config.set_configuration( 'BOOKTYPE_FRONTPAGE_ANONYMOUS_IMAGE', '{0}portal/frontpage/anonymous_image.png'.format( settings.MEDIA_URL)) except: pass # welcome message if not os.path.exists('%s/templates/portal/' % static_root): os.makedirs('%s/templates/portal/' % static_root) try: f = open('%s/templates/portal/welcome_message.html' % static_root, 'w') text_data = self.cleaned_data.get('description', '') for ch in ['{%', '%}', '{{', '}}']: text_data = text_data.replace(ch, '') f.write(text_data.encode('utf8')) f.close() config.save_configuration() except IOError as err: raise err except config.ConfigurationError as err: raise err
class UploadFileForm(forms.Form): historico = forms.FileField() curriculum = forms.FileField() foto = forms.ImageField()
class UploadImageFormUni(forms.Form): image_uni = forms.ImageField()
class JobPostForm(ModelForm): min_salary = forms.IntegerField(required=False) max_salary = forms.IntegerField(required=False) published_date = forms.DateTimeField(input_formats=("%m/%d/%Y %H:%M:%S", ), required=False) walkin_contactinfo = forms.CharField(max_length=10000, required=False) walkin_from_date = forms.DateField(required=False, input_formats=("%m/%d/%Y", )) walkin_to_date = forms.DateField(required=False, input_formats=("%m/%d/%Y", )) walkin_time = forms.TimeField(required=False, input_formats=valid_time_formats) vacancies = forms.IntegerField(required=False) company_description = forms.CharField(max_length=10000) application_fee = forms.IntegerField(required=False) selection_process = forms.CharField( widget=forms.Textarea( attrs={"placeholder": "Please enter the selection process"}), required=False, ) how_to_apply = forms.CharField( widget=forms.Textarea( attrs={"placeholder": "Please enter the selection process"}), required=False, ) important_dates = forms.CharField( widget=forms.Textarea( attrs={"placeholder": "Please enter the selection process"}), required=False, ) govt_from_date = forms.DateField(required=False, input_formats=("%m/%d/%Y", )) govt_to_date = forms.DateField(required=False, input_formats=("%m/%d/%Y", )) govt_exam_date = forms.DateField(required=False, input_formats=("%m/%d/%Y", )) age_relaxation = forms.CharField( widget=forms.Textarea( attrs={"placeholder": "Please enter the selection process"}), required=False, ) min_year = forms.IntegerField(required=True) max_year = forms.IntegerField(required=True) min_month = forms.IntegerField(required=True) max_month = forms.IntegerField(required=True) company_address = forms.CharField(max_length=10000) agency_job_type = forms.CharField(max_length=10000, required=False) agency_invoice_type = forms.CharField(max_length=10000, required=False) agency_amount = forms.IntegerField(required=False) # agency_recruiters = forms.CharField(max_length=10000, required=False) agency_client = forms.CharField(max_length=10000, required=False) agency_category = forms.CharField(max_length=10000, required=False) company = forms.CharField(max_length=100, required=False) # edu_qualification = forms.CharField(max_length=1000, required=False) company_links = forms.CharField(max_length=5000, required=False) salary_type = forms.CharField(required=False) published_message = forms.CharField(required=False) company_website = forms.CharField(max_length=5000, required=False) company_logo = forms.ImageField(required=False) pincode = forms.CharField(required=False) class Meta: model = JobPost exclude = [ "user", "code", "country", "status", "previous_status", "fb_views", "tw_views", "ln_views", "other_views", "fb_groups", "post_on_fb", "post_on_tw", "post_on_ln", "keywords", "job_interview_location", "job_type", "govt_job_type", "agency_client", "company", "meta_title", "meta_description", "agency_category", "major_skill", "vacancies", "slug", ] def __init__(self, *args, **kwargs): self.user = kwargs.pop("user", None) super(JobPostForm, self).__init__(*args, **kwargs) if self.user.is_superuser: self.fields["company"].required = True self.fields["company_address"].required = False self.fields["company_name"].required = False self.fields["company_description"].required = False self.fields["company_website"].required = False if self.user.company and self.user.is_agency_recruiter: # self.fields['code'].required = False self.fields["agency_job_type"].required = True self.fields["agency_recruiters"].required = True else: self.fields["agency_recruiters"].required = False if "vacancies" in self.data.keys() and self.data["vacancies"]: self.fields["vacancies"].required = True if "salary_type" in self.data.keys() and self.data["salary_type"]: self.fields["max_salary"].required = True self.fields["min_salary"].required = True if ("min_salary" in self.data.keys() and self.data["min_salary"] or "max_salary" in self.data.keys() and self.data["max_salary"]): self.fields["salary_type"].required = True if "min_salary" in self.data.keys() and self.data["min_salary"]: self.fields["salary_type"].required = True self.fields["min_salary"].required = True if "max_salary" in self.data.keys() and self.data["max_salary"]: self.fields["max_salary"].required = True self.fields["salary_type"].required = True if "final_industry" in self.data.keys(): if len(self.data["final_industry"]) > 2: self.fields["industry"].required = False else: self.fields["industry"].required = True if "final_skills" in self.data.keys(): if len(self.data["final_skills"]) > 2: self.fields["skills"].required = False else: self.fields["skills"].required = True if "final_edu_qualification" in self.data.keys(): if len(self.data["final_edu_qualification"]) > 2: self.fields["edu_qualification"].required = False else: self.fields["edu_qualification"].required = True if "final_functional_area" in self.data.keys(): if len(self.data["final_functional_area"]) > 2: self.fields["functional_area"].required = False else: self.fields["functional_area"].required = True if "other_location" in self.data.keys(): if len(self.data["other_location"]) != 0: self.fields["location"].required = False if "visa_required" in self.data.keys() and self.data["visa_required"]: self.fields["visa_country"].required = True self.fields["visa_type"].required = True else: self.fields["visa_country"].required = False self.fields["visa_type"].required = False if str(self.data["job_type"]) == "walk-in": self.fields["walkin_contactinfo"].required = True self.fields["walkin_from_date"].required = True self.fields["walkin_to_date"].required = True self.fields["walkin_time"].required = True self.fields["vacancies"].required = False # self.fields['company_description'].required = False self.fields["industry"].required = False self.fields["skills"].required = False self.fields["functional_area"].required = False self.fields["last_date"].required = False # self.fields['code'].required = False self.fields["job_role"].required = False self.fields["company_description"].required = False self.fields["walkin_time"].required = False self.fields["edu_qualification"].required = False if str(self.data["job_type"]) == "government": self.fields["min_year"].required = False self.fields["max_year"].required = False self.fields["min_month"].required = False self.fields["max_month"].required = False self.fields["company_address"].required = False self.fields["application_fee"].required = False self.fields["selection_process"].required = False self.fields["how_to_apply"].required = True self.fields["important_dates"].required = True self.fields["age_relaxation"].required = True self.fields["govt_from_date"].required = True self.fields["govt_to_date"].required = True self.fields["govt_exam_date"].required = False self.fields["industry"].required = False self.fields["skills"].required = False self.fields["functional_area"].required = False self.fields["last_date"].required = False # self.fields['code'].required = False self.fields["job_role"].required = False self.fields["company_description"].required = False if str(self.data["job_type"]) == "full-time": self.fields["last_date"].required = False self.fields["edu_qualification"].required = False if str(self.data["job_type"]) == "internship": self.fields["last_date"].required = False self.fields["edu_qualification"].required = False def clean_title(self): title = self.cleaned_data["title"] if bool( re.search(r"[~\.,!@#\$%\^&\*\(\)_\+{}\":;'\[\]\<\>\|\/]", title)) or bool(re.search(r"[0-9]", title)): raise forms.ValidationError( "Title Should not contain special charecters and numbers") if JobPost.objects.filter(title=title).exclude(id=self.instance.id): raise forms.ValidationError( "Job Post with this title already exists") return title.replace("/", "-") def clean_vacancies(self): if "vacancies" in self.data.keys() and self.data["vacancies"]: if int(self.data["vacancies"]) <= 0: raise forms.ValidationError( "Vacancies must be greater than zero") else: return self.cleaned_data.get("vacancies") return self.cleaned_data.get("vacancies") def clean_last_date(self): date = self.cleaned_data["last_date"] if str(date) < str(datetime.now().date()): raise forms.ValidationError("The date cannot be in the past!") return date def clean_govt_exam_date(self): if ("govt_exam_date", "govt_from_date", "govt_to_date") in self.data.keys(): date = self.cleaned_data["govt_exam_date"] from_date = self.data["govt_from_date"] to_date = self.data["govt_to_date"] if date and from_date and to_date: to_date = datetime.strptime(str(to_date), "%m/%d/%Y").strftime("%Y-%m-%d") from_date = datetime.strptime(str(from_date), "%m/%d/%Y").strftime("%Y-%m-%d") if str(date) < str(datetime.now().date()): raise forms.ValidationError( "The date cannot be in the past!") if str(from_date) > str(date) or str(to_date) > str(date): raise forms.ValidationError( "Exam Date must be in between from and to date") return date def clean_govt_from_date(self): if "govt_from_date" in self.data.keys(): date = self.cleaned_data["govt_from_date"] if str(date) < str(datetime.now().date()): raise forms.ValidationError("The date cannot be in the past!") return date def clean_govt_to_date(self): if "govt_to_date" in self.data.keys(): date = self.cleaned_data["govt_to_date"] if str(date) < str(datetime.now().date()): raise forms.ValidationError("The date cannot be in the past!") from_date = self.data["govt_from_date"] from_date = datetime.strptime(str(from_date), "%m/%d/%Y").strftime("%Y-%m-%d") if str(from_date) > str(date): raise forms.ValidationError( "To Date must be greater than From Date") return date def clean_published_date(self): date_time = self.cleaned_data["published_date"] asia_time = get_asia_time() if date_time: if str(date_time) < str(asia_time): raise forms.ValidationError("The date cannot be in the past!") if str(self.data["job_type"]) == "walk-in": if ("walkin_to_date" in self.cleaned_data.keys() and self.cleaned_data["walkin_to_date"] > date_time.date()): return date_time else: raise forms.ValidationError( "Published date must be less than walkin end date") return date_time def clean_min_salary(self): if self.cleaned_data.get("min_salary"): try: min_sal = int(self.cleaned_data["min_salary"]) return min_sal except: raise forms.ValidationError( "Minimum salary must be an Integer") else: return 0 def clean_max_salary(self): if self.cleaned_data.get("min_salary") and self.cleaned_data.get( "max_salary"): if int(self.cleaned_data["max_salary"]) < int( self.cleaned_data["min_salary"]): raise forms.ValidationError( "Maximum salary must be greater than minimum salary") return self.cleaned_data["max_salary"] elif self.cleaned_data.get("max_salary"): return self.cleaned_data["max_salary"] return 0 def clean_company_name(self): # companies = Company.objects.filter(name__iexact=self.data['company_name']) # if self.instance.company: # companies = companies.exclude(id=self.instance.company.id) # if companies: # raise forms.ValidationError('Company with this name already exists') return self.data["company_name"] def clean_company_website(self): if "company_website" in self.data and self.data["company_website"]: if (re.match(r"^http://", self.data["company_website"]) or re.match(r"^https://", self.data["company_website"]) or re.match(r"^www.", self.data["company_website"])): company = "" if "company_id" in self.data.keys( ) and self.data["company_id"]: company = Company.objects.filter( id=self.data["company_id"]) if company: companies = Company.objects.filter( website__iexact=self.data["company_website"]).exclude( id=self.data["company_id"]) if companies: raise forms.ValidationError( "Company with this website already exists") return self.cleaned_data["company_website"] else: raise forms.ValidationError( "Please include website with http:// or https:// or www.") def clean_company_logo(self): company_logo = self.cleaned_data.get("company_logo") if company_logo: sup_formates = ["image/jpeg", "image/png"] ftype = company_logo.content_type if str(ftype) not in sup_formates: raise forms.ValidationError( "Please upload Valid Image Format Ex: PNG, JPEG, JPG") return company_logo return company_logo def clean_pincode(self): pincode = self.cleaned_data.get("pincode") if pincode: match = re.findall(r"\d{6}", pincode) if not match or len(pincode) != 6: raise forms.ValidationError( "Please Enter 6 digit valid Pincode") return pincode
class PostForm(forms.Form): model = Post title = forms.CharField(min_length=1) image = forms.ImageField(required=True) description = forms.CharField(widget=forms.Textarea( {'palceholder': 'Give description of your image'}))
class UploadForm(forms.Form): CHOICES = (('0','Fruits'), ('1','Diseases'),) mode = forms.ChoiceField(widget=forms.Select, choices=CHOICES,label="") image=forms.ImageField(label='',)
class uploadForm(forms.Form): file = forms.ImageField(widget=forms.ClearableFileInput( attrs={ 'class': 'inputfile inputfile-4', 'style': 'display:none' }))
class ArticleForm(forms.Form): title = forms.CharField(max_length=255, min_length=5) categroy_id = forms.CharField() head_img = forms.ImageField() content = forms.CharField(max_length=5000, min_length=10)
class SimpleUserForm(forms.ModelForm): HIDE_INFO = (('True', 'Yes'), ('False', 'No')) middle_name = forms.CharField(required=False, max_length=100, widget=TextInput( attrs={ 'class': 'form-control input-sm', 'placeholder': "Middle Name", 'required': 'True', 'data-trigger': 'focus', 'title': 'Field: Middle Name', 'data-content': 'Enter your\ middle name' })) birth_date = forms.DateTimeField( error_messages={'invalid': 'Wrong date format'}, # noqa widget=DateInput(attrs={ 'class': 'datepicker form-control input-sm ', 'data-trigger': 'focus', 'title': 'Field: Birth Date', 'data-content': 'Only adults.', 'placeholder': 'Year-Month-Day' }, format=('%Y-%m-%d')), required=False, ) contact_time_min = forms.TimeField( required=False, widget=forms.TimeInput(attrs={'class': 'form-control input-sm'}, format='%H:%M')) contact_time_max = forms.TimeField( required=False, widget=forms.TimeInput(attrs={'class': 'form-control input-sm'}, format='%H:%M')) address = forms.CharField(required=False, max_length=100, widget=TextInput( attrs={ 'class': 'form-control input-sm', 'placeholder': "Address", 'data-trigger': 'focus', 'title': 'Field: Address', 'data-content': 'Enter your address' })) city = forms.CharField(required=False, max_length=100, widget=TextInput( attrs={ 'class': 'form-control input-sm', 'placeholder': "City", 'data-trigger': 'focus', 'title': 'Field: City', 'data-content': 'ΕEnter your city' })) website = forms.URLField(max_length=200, required=False, widget=TextInput( attrs={ 'class': 'form-control input-sm', 'placeholder': "Personal website/blog", 'data-trigger': 'focus', 'title': 'Field: Website', 'data-content': 'Personal website - blog', })) hide_contact_details = forms.ChoiceField( choices=HIDE_INFO, required=False, widget=forms.Select(attrs={ 'required': 'false', # noqa 'class': 'form-control input-sm', # noqa })) avatar = forms.ImageField(label=u'User avatar', required=False) facebook_link = forms.URLField( max_length=200, required=False, widget=TextInput( attrs={ 'class': 'form-control input-sm', # noqa 'placeholder': "Facebook profile link", # noqa 'data-trigger': 'focus', 'title': 'Field: Facebook link', 'data-content': 'Complete your\ facebook link', })) def clean_middle_name(self): middle_name = self.cleaned_data['middle_name'] sanizite = Allow() return sanizite.letters(middle_name) def clean_mobile_number(self): pass def clean_home_number(self): pass def clean_birth_date(self): pass def clean_contact_time_min(self): pass def clean_contact_time_max(self): pass def clean_address(self): pass def clean_city(self): pass def clean_website(self): pass def clean_avatar(self): pass def clean_facebook_link(self): pass class Meta(): model = SimpleUser fields = ('')
class SearchImageForm(forms.Form): image = forms.ImageField()
class UpdateProfileForm(forms.Form): website = forms.URLField(max_length=200, required=True) biography = forms.CharField(max_length=500, required=False) phone_number = forms.CharField(max_length=20, required=False) picture = forms.ImageField(required=True)
class EditionForm(forms.ModelForm): ''' form for bibliographic data (both editions and works ''' add_author = forms.CharField(max_length=500, required=False) add_author_relation = forms.ChoiceField(choices=CREATOR_RELATIONS, initial=('aut', 'Author')) add_subject = AutoCompleteSelectField( SubjectLookup, widget=AutoCompleteSelectWidget(SubjectLookup, allow_new=True), label='Keyword', required=False, ) add_related_work = AutoCompleteSelectField( WorkLookup, widget=AutoCompleteSelectWidget(WorkLookup, allow_new=False, attrs={'size': 40}), label='Related Work', required=False, ) add_work_relation = forms.ChoiceField( choices=TEXT_RELATION_CHOICES, initial=('translation', 'translation'), required=False, ) bisac = forms.ModelChoiceField(bisac_headings, required=False) publisher_name = AutoCompleteSelectField( PublisherNameLookup, label='Publisher Name', widget=AutoCompleteSelectWidget(PublisherNameLookup, allow_new=True), required=False, allow_new=True, ) id_type = forms.ChoiceField(label='Identifier Type', choices=ID_CHOICES) id_value = forms.CharField( label='Identifier Value', widget=forms.TextInput(attrs={'size': 60}), required=False, ) language = forms.ChoiceField(choices=LANGUAGES) age_level = forms.ChoiceField(choices=AGE_LEVEL_CHOICES, required=False) description = forms.CharField(required=False, widget=CKEditorWidget()) coverfile = forms.ImageField(required=False) note = AutoCompleteSelectField( EditionNoteLookup, widget=AutoCompleteSelectWidget(EditionNoteLookup, allow_new=True), label='Edition Note', required=False, allow_new=True, ) set_rights = forms.CharField(widget=forms.Select(choices=RIGHTS_CHOICES), required=False) def __init__(self, *args, **kwargs): super(EditionForm, self).__init__(*args, **kwargs) self.relators = [] if self.instance: for relator in self.instance.relators.all(): select = forms.Select(choices=CREATOR_RELATIONS).render( 'change_relator_%s' % relator.id, relator.relation.code) self.relators.append({'relator': relator, 'select': select}) def clean_title(self): return sanitize_line(self.cleaned_data["title"]) def clean_add_author(self): return sanitize_line(self.cleaned_data["add_author"]) def clean_description(self): return remove_badxml(self.cleaned_data["description"]) def clean(self): id_type = self.cleaned_data['id_type'] id_value = self.cleaned_data.get('id_value', '').strip() if id_value: try: id_value = identifier_cleaner(id_type)(id_value) identifier = Identifier.objects.filter(type=id_type, value=id_value) ident = identifier[0] if identifier else None if not ident or not self.instance: self.cleaned_data['id_value'] = id_value elif ident.edition_id == self.instance.id: self.cleaned_data['id_value'] = id_value elif not ident.edition_id and ident.work_id == self.instance.work_id: self.cleaned_data['id_value'] = id_value else: if ident.edition_id: err_msg = "{} is a duplicate for edition #{}.".format( id_value, ident.edition_id) else: err_msg = "{} is a duplicate for work #{}.".format( id_value, ident.work_id) self.add_error('id_value', forms.ValidationError(err_msg)) except forms.ValidationError, ve: self.add_error( 'id_value', forms.ValidationError('{}: {}'.format( ve.message, id_value))) return self.cleaned_data
class UploadForm(forms.Form): image = forms.ImageField(label='Selecciona una imagen')
class FileUploadForm(forms.Form): image_file = forms.ImageField(required=True)
class UserPictureForm(forms.Form): filename = forms.ImageField(label='Select a file', help_text='This will be your profile pic', required=False)
class UploadForm(forms.Form): file_upload = forms.ImageField()
class UserForm(forms.Form): # Widget - Charfield #username = forms.CharField(label='Username', max_length=100, initial='Enter user name') username = forms.CharField( widget=forms.TextInput(attrs={ 'placeholder': 'Username', 'class': 'djangoform' }), required=True, max_length="8") # Widget - Password # password = forms.CharField(widget=forms.PasswordInput()) password = forms.CharField(widget=forms.PasswordInput( attrs={ 'placeholder': 'Password', 'class': 'djangoform' })) # Widget - Email # email = forms.EmailField(label='Email', initial='We need your email') # email = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email'}), required = True) email = forms.EmailField(widget=forms.EmailInput(attrs={ 'placeholder': 'Email', 'class': 'djangoform' }), required=True) # Widget - Integer Field - Same used for Phone number # contact = forms.IntegerField(widget=forms.NumberInput(attrs={'placeholder': 'Phone number', 'min':10}), required = True ) contact = forms.IntegerField( widget=forms.NumberInput(attrs={ 'placeholder': 'Phone number', 'class': 'djangoform' }), required=True) # upload Multiple files #upload_image = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True,'class': 'fileupload'}), required=False) upload_image = forms.ImageField( widget=forms.ClearableFileInput(attrs={ 'multiple': True, 'class': 'fileupload' }), required=False) #upload_image = forms.FileField(widget=forms.ClearableFileInput(attrs={'class': 'fileupload'}), required=False) # Date and Time Widgets # date = forms.DateField(widget=forms.SelectDateWidget) # date = forms.DateTimeField(widget = forms.SelectDateWidget()) # date = forms.DateTimeField(widget = DatePickerInput(format='%m/%d/%Y')) # date = forms.DateField(widget=DatePicker(options={"format": "mm/dd/yyyy", "autoclose": True })) # date = forms.DateField(widget=widgets.AdminDateWidget) # date = forms.DateField(widget= forms.DateInput(format='%d/%m/%Y')) # # Using AdminDate and Time widget ## date = forms.DateField( widget=widgets.AdminDateWidget(attrs={'placeholder': 'Date'}), required=False) #time = forms.DateField(widget=widgets.AdminTimeWidget(attrs={'placeholder': 'Time'}), required=False) time = forms.TimeField( widget=widgets.AdminTimeWidget(attrs={'placeholder': 'Time'}), required=False) # SelectDateWidget: BIRTH_YEAR_CHOICES = ['1980', '1981', '1982'] birth_year = forms.DateField(widget=forms.SelectDateWidget( years=BIRTH_YEAR_CHOICES)) # Widget Multiple Chocies FAVORITE_COLORS_CHOICES = [ ('blue', 'Blue'), ('green', 'Green'), ('black', 'Black'), ] favorite_color = forms.MultipleChoiceField(widget=forms.SelectMultiple(), required=False, choices=FAVORITE_COLORS_CHOICES) favorite_colors = forms.MultipleChoiceField( widget=forms.CheckboxSelectMultiple, required=False, choices=FAVORITE_COLORS_CHOICES) # Widget - Radio Chocies Widget CHOICES = [('1', 'First'), ('2', 'Second')] choice_field = forms.ChoiceField(widget=forms.RadioSelect(), choices=CHOICES, required=False) # Widget - url url = forms.URLField( widget=forms.URLInput(attrs={'Placeholder': 'Enter url'}), required=False) # Widget - Charfield and Text Field description = forms.CharField( widget=forms.TextInput(attrs={ 'Placeholder': 'Short description', 'size': '40' }), required=False) comments = forms.CharField(widget=forms.Textarea(attrs={ 'Placeholder': "Enter Comment", 'rows': 5 }), required=False) # Widget - Boolen yes_no = forms.BooleanField( label="Are you coming?, Click check box if coming.", required=False) boolean_null = forms.BooleanField(required=False, widget=forms.NullBooleanSelect()) yes_no = forms.BooleanField( label="Are you coming?, Click check box if coming.", required=False) On_Off = forms.BooleanField( widget=forms.CheckboxInput(attrs={ 'input type': 'checkbox', 'checked data-toggle': 'toggle' }), required=False) Enabled_Disabled = forms.BooleanField( label="Enabled/Disabled", required=False, widget=forms.CheckboxInput(attrs={ 'data-on': 'Enabled', 'data-off': 'Disabled', 'data-toggle': 'toggle' })) agree = forms.BooleanField(required=True) #yes_no = forms.BooleanField(widget=forms.CheckboxInput(), label="Are you coming?", required=False) # Widget - MultiWidget fields = ( forms.CharField(widget=forms.TextInput(attrs={'class': 'big'})), forms.CharField(widget=forms.TextInput(attrs={'class': 'big'})), forms.CharField(widget=forms.TextInput(attrs={'class': 'big'})), ) widge = [fields[0].widget, fields[1].widget, fields[2].widget]
class CustomerProfileForm(forms.ModelForm): images = forms.ImageField() class Meta: model = CustomerProfile fields = ['images']
class ImageForm(forms.Form): """Image upload form.""" headpic = forms.ImageField()
class changePhoto(forms.Form): image = forms.ImageField()
class UploadImageFormID(forms.Form): image_ID = forms.ImageField()
class comentarioForm(forms.Form): comentario = forms.CharField() imagen = forms.ImageField(required=False)
class UploadImageFormPhoto(forms.Form): image_photo = forms.ImageField()
class RegisterForm(forms.Form): Username = forms.CharField() Email = forms.EmailField() Password = forms.CharField(max_length=32, widget=forms.PasswordInput) image = forms.ImageField(required=False)
class CompanyForm(ModelForm): name = forms.CharField( label='', required=True, widget=forms.TextInput(attrs={'placeholder': 'Company Name'})) logo = forms.ImageField( label='Logo', required=False, widget=forms.ClearableFileInput(attrs={'placeholder': 'Logo'})) image = forms.ImageField( label='Place Holder Image', required=False, widget=forms.ClearableFileInput( attrs={'placeholder': 'Place holder Image Image'})) description = forms.CharField( label='', required=True, max_length=1024, widget=PagedownWidget(attrs={'placeholder': 'Description'})) website = forms.URLField( label='', required=False, widget=forms.TextInput(attrs={'placeholder': 'Company Website'})) twitter = forms.CharField( max_length=20, label='', required=False, widget=forms.TextInput(attrs={'placeholder': 'twitter'})) location = forms.ModelChoiceField(label='', required=False, queryset=Location.objects.all(), empty_label="Choose Location") category = forms.ModelChoiceField(label='', required=False, queryset=Category.objects.all(), empty_label="Choose Category") email = forms.EmailField( label='', max_length=200, required=True, widget=forms.TextInput(attrs={'placeholder': 'Email'})) address = forms.CharField( label='', required=False, widget=forms.TextInput(attrs={'placeholder': 'Address'})) status = forms.ChoiceField(label='status', required=False, widget=forms.RadioSelect, choices=STATUS_CHOICES) tags = forms.CharField( label='', required=False, widget=forms.TextInput( attrs={'placeholder': 'Tags, A comma-separated list of tags'})) class Meta: model = Company fields = ('name', 'logo', 'image', 'description', 'website', 'twitter', 'location', 'category', 'email', "status", 'address') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( 'name', 'logo', 'image', 'description', Row(Column('website', css_class='mt-10 form-group col-md-6 mb-0'), Column('twitter', css_class='mt-10 form-group col-md-6 mb-0'), css_class='form-row'), Row(Column('location', css_class='mt-10 form-group col-md-6 mb-0'), Column('category', css_class='mt-10 form-group col-md-6 mb-0'), css_class='form-row'), Row(Column('email', css_class='mt-10 form-group col-md-6 mb-0'), Column('address', css_class='mt-10 form-group col-md-6 mb-0'), css_class='form-row'), Row(Column('openTime', css_class='mt-10 form-group col-md-6 mb-0'), Column('closeTime', css_class='mt-10 form-group col-md-6 mb-0'), css_class='form-row'), Row( InlineRadios('status', css_class='mt-10 form-group col-md-6 mb-0'), ), Submit('submit', 'Add Your Company'), )
def __init__(self, *args, **kwargs): registrationType = kwargs.pop('registrationType', None) companyType = kwargs.pop('employerCompany', None) extra_language_fields = kwargs.pop('extra_language_count', 1) super().__init__(*args, **kwargs) self.fields['extra_language_count'].initial = max( min(int(extra_language_fields), 10), 1) self.fields['registrationType'].initial = registrationType self.fields['employerCompany'].initial = companyType self.languageFields = [] self.languageFieldsNames = [] if (registrationType == "employer"): if (companyType == 'createNew'): self.fields['companyName'] = forms.CharField( max_length=100, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Company name' })) self.fields['address'] = forms.CharField( max_length=100, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Company address' })) self.fields['website'] = forms.CharField( max_length=100, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Company website' })) self.fields['profile'] = forms.CharField( max_length=1000, widget=TinyMCE( attrs={'class': 'tinymce-editor tinymce-editor-2'})) self.fields['image'] = forms.ImageField(required=False) if (companyType == 'selectFromExisting'): self.fields['company'] = forms.ChoiceField(widget=forms.Select( attrs={ 'class': 'form-control', 'placeholder': 'Select Category' })) company = Company.objects.all() company_choices = [] for obj in company: company_choices.append((obj.pk, obj)) self.fields['company'].choices = company_choices if (registrationType == "candidate"): self.fields['studentID'] = forms.CharField( max_length=MAX_LENGTH_STANDARDFIELDS, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Student ID' })) self.fields['creditCompleted'] = forms.FloatField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Credits Completed' })) self.fields['creditLeft'] = forms.FloatField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Credits left' })) self.fields['gpa'] = forms.FloatField(widget=forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Cumulative GPA' })) for i in range(int(self.fields['extra_language_count'].initial)): self.add_language(i) self.fields['program'] = forms.ChoiceField( choices=CATEGORY_CHOICES, widget=forms.Select(attrs={'class': 'form-control'})) self.fields['internationalStudent'] = forms.ChoiceField( choices=YES_NO, widget=forms.Select(attrs={'class': 'form-control'})) self.fields['travel'] = forms.ChoiceField( choices=YES_NO, widget=forms.Select(attrs={'class': 'form-control'})) self.fields['timeCommitment'] = forms.ChoiceField( choices=YES_NO, widget=forms.Select(attrs={'class': 'form-control'})) self.fields['transcript'] = forms.FileField(required=False)
class AddPhotoForm(forms.Form): image = forms.ImageField()
class EditPicForm(forms.Form): photo = forms.ImageField()