class SignupForm(forms.Form): first_name = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter First Name' })) last_name = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter Last Name' })) username = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter User Name' })) password = forms.CharField( max_length=40, required=True, widget=forms.PasswordInput(attrs={ 'class': 'input', 'placeholder': 'Enter password' }))
class SignUpForm(forms.Form): first_name = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name ' })) last_name = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Last Name ' })) username = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'User Nsme' })) password = forms.CharField( max_length=15, required=True, widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name ' }))
class Meta: model = Product exclude = ['id', 'subcategory'] widgets = { 'title': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'enter title' }), 'price': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter price' }), 'units': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter units' }), 'rating': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter rating' }), 'description': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'enter description' }), }
class Meta: model = Student exclude = {'id', 'dob', 'college'} widgets = { 'name': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter name of the student' }), 'email': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter email of the Email' }), 'db_folder': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter DB Folder Name' }), 'dropped_out': forms.CheckboxInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter Dropped out of the Is Dropped' }) }
class RegistrationForm(forms.Form): username = forms.RegexField( regex=r'^\w+$', widget=forms.TextInput(attrs=dict(required=True, max_length=30)), label=_("Username"), error_messages={ 'invalid': ("This value must contain only letters, numbers and underscores.") }) email = forms.EmailField( widget=forms.TextInput(attrs=dict(required=True, max_length=30)), label=("Email address")) password1 = forms.CharField(widget=forms.PasswordInput( attrs=dict(required=True, max_length=30, render_value=False)), label=("Password")) password2 = forms.CharField(widget=forms.PasswordInput( attrs=dict(required=True, max_length=30, render_value=False)), label=("Password (again)")) def clean_username(self): try: user = User.objects.get( username__iexact=self.cleaned_data['username']) except User.DoesNotExist: return self.cleaned_data['username'] raise forms.ValidationError( _("The username already exists. Please try another one.")) def clean(self): if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data: if self.cleaned_data['password1'] != self.cleaned_data['password2']: raise forms.ValidationError( _("The two password fields did not match.")) return self.cleaned_data
class Meta: model = College exclude = {'id'} widgets = { 'name': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter name of the college' }), 'acronym': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter acronym of the college' }), 'location': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter location of the college' }), 'contact': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter contact of the college' }) }
class NewBlog(ModelForm): title = forms.CharField( max_length=200, required=True, widget=forms.TextInput( attrs={'placeholder': 'Enter Title For the Bog'})) byline = forms.CharField( max_length=400, required=True, widget=forms.TextInput(attrs={'placeholder': 'Enter byline'})) content = forms.CharField( required=False, widget=forms.Textarea(attrs={'placeholder': 'Enter Content'})) class Meta: model = Post exclude = ('slug', 'is_published', 'updated_on', 'created_on', 'publish_on', 'author', 'list_display', 'search_fields', 'list_filter', 'date_hierarchy') def __init__(self, *args, **kwargs): super(NewBlog, self).__init__(*args, **kwargs) self.fields['title'].widget.attrs['class'] = 'input is-medium' self.fields['featured_image'].widget.attrs['id'] = "file" self.fields['byline'].widget.attrs['class'] = 'input is-medium' self.fields['featured_image'].widget.attrs['class'] = 'file-input' self.fields['tags'].widget.attrs['class'] = ' '
class UserRegistartionForm(forms.ModelForm): username = forms.CharField( max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Имя пользователя') first_name = forms.CharField( max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Имя') last_name = forms.CharField( max_length=40, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Фамилия') email = forms.EmailField( max_length=100, widget=forms.EmailInput(attrs={'class': 'form-control'}), label='Email') password = forms.CharField( max_length=128, strip=False, widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='Пароль') password2 = forms.CharField( max_length=128, strip=False, widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='Повторите пароль') error_messages = { 'password_mismatch': _("The two password fields didn't match."), } class Meta: model = AllUsers fields = ('username', 'email')
class UserForm(forms.ModelForm): username = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อผู้ใช้ ') password = forms.CharField( widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='รหัสผ่าน ') first_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อจริง ') last_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='นามสกุล ') email = forms.EmailField( widget=forms.EmailInput(attrs={'class': 'form-control'}), label='อีเมล์ ') class Meta: model = User fields = ['username', 'password', 'email', 'first_name', 'last_name'] help_texts = { 'username': str('Required. 30 characters or fewer. Usernames may contain alphanumeric, _, @, +, . and - characters.<br><br>' ) }
class DeviceProfileForm(forms.ModelForm): owner = forms.ModelChoiceField(queryset=User.objects.all(), widget=forms.HiddenInput(), label='เจ้าของ ') device_id = forms.IntegerField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='รหัสระจำตัวอุปกรณ์ ') device_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่ออุปกรณ์ ') openTime = forms.DateTimeField( widget=forms.DateTimeInput(attrs={'class': 'form-control'}), initial=(timezone.make_aware(datetime.datetime.now(), timezone.get_default_timezone())), label='เวลาเปิดอุปกรณ์ ', required=False) closeTime = forms.DateTimeField( widget=forms.DateTimeInput(attrs={'class': 'form-control'}), initial=(timezone.make_aware(datetime.datetime.now(), timezone.get_default_timezone())), label='เวลาปิดอุปกรณ์ ', required=False) class Meta: model = DeviceProfile fields = ('owner', 'device_id', 'device_name', 'openTime', 'closeTime')
class Meta: model = Job fields = [ 'title', 'description', 'category', 'pay', 'number_of_positions', 'address' ] #styling through bootstrap class in form-control widgets = { 'title': forms.TextInput(attrs={'class': 'form-control'}), 'description': forms.Textarea( attrs={ 'class': 'form-control', 'placeholder': "Describe the job in 3-5 sentences." }), 'category': forms.Select(attrs={'class': 'form-control'}), 'pay': forms.TextInput(attrs={'class': 'form-control'}), 'number_of_positions': forms.NumberInput(attrs={'class': 'form-control'}), 'address': forms.TextInput(attrs={'class': 'form-control'}), }
class userform(forms.ModelForm): username= forms.CharField(widget=forms.TextInput( attrs={'class': 'forms-control', 'placeholder': 'Enter username'} ), required=True, max_length=50) email = forms.CharField(widget=forms.EmailInput( attrs={'class': 'forms-control', 'placeholder': 'Enter email ID'} ), required=True, max_length=50) first_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'forms-control', 'placeholder': 'Enter first name'} ), required=True, max_length=50) lastname = forms.CharField(widget=forms.TextInput( attrs={'class': 'forms-control', 'placeholder': 'Enter last name'} ), required=True, max_length=50) password = forms.CharField(widget=forms.PasswordInput( attrs={'class': 'forms-control', 'placeholder': 'Enter password'} ), required=True, max_length=50) confirm_password = forms.CharField(widget=forms.PasswordInput( attrs={'class': 'forms-control', 'placeholder': 'Enter confirm password'} ), required=True, max_length=50) class Meta(): model = User fields =['username','email','first_name','last_name','password','confirm_password'] def clean_username(self): user=self.cleaned_data['username'] try: match = User.objects.get(username = user) except: return self.cleaned_data['username'] #user raise forms.ValidationError("Username already exist") def clean_email(self): email = self.cleaned_data['email'] try: mt = validate_email(email) except: return forms.ValidationError("Email is not in correct Format") return email def clean_confirm_password(self): pas = self.cleaned_data['password'] cpas = self.cleaned_data['confirm_password'] MIN_LENGTH = 8 if pas and cpas: if pas != cpas: raise forms.ValidationError("password and confirm password not matched") else: if len(pas) < MIN_LENGTH: raise forms.ValidationError("Password should have atleast %d character" %MIN_LENGTH) if pas.isdigit(): raise forms.ValidationError("Password should not all numeric")
class EditProfileForm(forms.ModelForm): first_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อจริง ') last_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='นามสกุล ') email = forms.EmailField( widget=forms.EmailInput(attrs={'class': 'form-control'}), label='อีเมล์ ') class Meta: model = User fields = ['first_name', 'last_name', 'email']
class UserForm(ModelForm): class Meta: model = MyUser localized_fields = ( 'full_name', 'email', ) fields = ( 'full_name', 'email', ) email = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), disabled=True) full_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control'}))
class SearchForm(forms.Form): empty_choices = [('', '')] empty_choices.extend(list(UserProfile.school_choices)) schools = tuple(empty_choices) restrict_school = forms.ChoiceField(required=False, label="School", choices=schools) empty_choices = [('', '')] empty_choices.extend(list(UserProfile.year_choices)) years = tuple(empty_choices) restrict_year = forms.ChoiceField(required=False, label="Year", choices=years) empty_choices = [('', '')] empty_choices.extend(list(UserProfile.major_choices)) majors = tuple(empty_choices) restrict_major = forms.ChoiceField(required=False, label="Major", choices=majors) class_subject = forms.CharField( required=False, label="Course Designation", widget=forms.TextInput(attrs={'style': 'width:160px'})) class_number = forms.CharField(required=False, label="Course Number") class_name = forms.CharField(required=False, label="Course Title")
class LogFilterForm(forms.Form): user = ChoiceField(label=_('User'), choices=[], required=False) action = ChoiceField(label=_('Action'), choices=action_list, required=False) project = ChoiceField(label=_('Project'), choices=[]) daterange = CharField(label=_("Date Range"), widget=forms.TextInput(attrs={ 'style': 'width: 130px;', 'id': 'dateRangePicker' })) def __init__(self, *args, **kwargs): request = kwargs.pop("request", None) assert request is not None forms.Form.__init__(self, *args, **kwargs) org_id = request.user.get_profile().org_id users_rs = NGOUserProfile.objects.select_related().\ extra(select={'lower_username': '******'}).\ filter(org_id=org_id).order_by("lower_username") all_users = [("", _("All Users"))] all_users.extend([(user.user.id, "%s" % (user.user.first_name)) for user in users_rs]) self.fields["user"].choices = all_users project_choices = [("", _("All Projects"))] projects = get_all_projects(get_database_manager(request.user)) project_choices.extend( sorted([(prj["value"]["name"], prj["value"]["name"].capitalize()) for prj in projects], key=itemgetter(1, 0))) self.fields["project"].choices = project_choices
class ClassForm(forms.Form): class_subject = forms.CharField( required=False, label="Course Designation", widget=forms.TextInput(attrs={'style': 'width:160px'})) class_number = forms.CharField(required=False, label="Course Number") class_name = forms.CharField(required=False, label="Course Title")
class ApartmentAddForm(ModelForm): def __init__(self, *args, **kwargs): super(ApartmentAddForm, self).__init__(*args, **kwargs) self.fields['number'].required = False image = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control'})) class Meta: model = Apartment exclude = ['id', 'created', 'updated', 'sold'] optional = ['number'] widgets = { 'address': widgets.TextInput(attrs={'class': 'form-control'}), 'number': widgets.NumberInput(attrs={'class': 'form-control'}), 'zip': widgets.Select(attrs={'class': 'form-control'}), 'description': widgets.TextInput(attrs={'class': 'form-control'}), 'rooms': widgets.NumberInput(attrs={'class': 'form-control'}), 'size': widgets.NumberInput(attrs={'class': 'form-control'}), 'price': widgets.NumberInput(attrs={'class': 'form-control'}), 'category': widgets.Select(attrs={'class': 'form-control'}), 'seller': widgets.Select(attrs={'class': 'form-control'}), 'owner_name': widgets.TextInput(attrs={'class': 'form-control'}), 'owner_ssn': widgets.NumberInput(attrs={'class': 'form-control'}), 'owner_phone': widgets.NumberInput(attrs={'class': 'form-control'}), 'buyer_id': widgets.NumberInput(attrs={'class': 'form-control'}) }
class LoginForm(forms.Form): email = forms.EmailField( max_length=70, error_messages=my_default_errors, required=True, label='', widget=forms.TextInput( attrs={ 'placeholder': 'پست الکترونیک', 'style': "margin-top: 0px; direction: ltr;", 'class': "form-control register-inputs", 'type': 'email' })) password = Password(max_length=50, error_messages=my_default_errors, label='', widget=forms.PasswordInput( attrs={ 'placeholder': 'رمز عبور', 'style': "direction: ltr;", 'class': "form-control register-inputs", 'type': 'password' }), required=True) captcha = CaptchaField(label='', error_messages=captcha_errors, required=True)
class SignUp(forms.Form): """ Sign Up """ Name = forms.CharField( label="Your Name", widget=forms.TextInput(attrs={"placeholder": "It's Nice to meet you"})) username = forms.CharField( max_length=255, widget=forms.TextInput(attrs={"placeholder": "Make it Creative"})) password = forms.CharField( widget=forms.PasswordInput(attrs={"placeholder": "We wont sell it. "}), label="Password") email = forms.EmailField(label="Email Id") DateOfBirth = forms.DateField(label="Date of Birth") Bio = forms.CharField(widget=forms.Textarea( attrs={"placeholder": "Tell us about yourself"})) profilePic = forms.FileField()
class Meta: model = Item fields = ('name', 'age', 'sex', 'memo') widgets = { 'name': forms.TextInput(attrs={'placeholder': '記入例:山田 太郎'}), 'age': forms.NumberInput(attrs={'min': 1}), 'sex': forms.RadioSelect(), 'memo': forms.Textarea(attrs={'rows': 4}), }
class TenxGSCSubmissionForm(forms.Form): name = forms.CharField(max_length=50, widget=forms.TextInput()) email = forms.EmailField(max_length=50, widget=forms.EmailInput()) date = forms.DateField(widget=forms.SelectDateWidget(), initial=datetime.date.today()) tenxpools = forms.ChoiceField( widget=forms.Select(), choices=[(pool.id, pool.pool_name) for pool in TenxPool.objects.all().order_by('id')], label="TenX Pool", )
class GrocerySendMail(forms.Form): """Grocery form to send a grocery list to someone in email""" def __init__(self, data=None, files=None, request=None, *args, **kwargs): if request is None: raise TypeError("Keyword argument 'request must be supplies'") super(GrocerySendMail, self).__init__(data=data, files=files, *args, **kwargs) self.request = request # set up the return email address and sender name to the user logged in if request.user.is_authenticated(): self.fields['to_email'].initial = request.user.email to_email = forms.EmailField(widget=forms.TextInput(), label=_('email address')) gid = forms.CharField(widget=forms.HiddenInput()) from_email = settings.DEFAULT_FROM_EMAIL from_site = '' #from_site = Site.objects.get_current() subject = _('Grocery list from ' + str(from_site)) def get_body(self): """get the grocery list and return the message body for the email""" if self.is_valid(): list = GroceryList.objects.get(pk=self.cleaned_data['gid']) template_name = 'list/grocery_mail_body.html' # template that contains the email body and also shared by the grocery print view message = loader.render_to_string(template_name, {'list': list}, context_instance=RequestContext( self.request)) return message else: raise ValueError( _('Can not get grocery list id from invalid form data')) def get_toMail(self): """gets the email to send the list to from the form""" if self.is_valid(): return self.cleaned_data['to_email'] else: raise ValueError(_('Can not get to_email from invalid form data')) def save(self, fail_silently=False): """ sends the email message""" if self.subject and self.get_body() and self.from_email: try: msg = EmailMessage(self.subject, self.get_body(), self.from_email, [self.get_toMail()]) msg.content_subtype = 'html' msg.send() except BadHeaderError: return HttpResponse(_('Invalid header found.')) return HttpResponse(_('Email Sent')) else: return HttpResponse('Make sure all fields are entered and valid.')
class Meta: model = Profile fields = ['first_name', 'last_name'] widgets = { 'first_name': forms.TextInput( attrs={ 'class': "form-control", 'placeholder': "your first name", 'type': "text" }), 'last_name': forms.TextInput( attrs={ 'class': "form-control", 'placeholder': "your first name", 'type': "text" }), }
class Meta: model = Subcategory exclude = ['id', 'category'] widgets = { 'title': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'enter title' }), 'active': forms.CheckboxInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter active out of the Is Dropped' }), 'description': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'enter description' }), }
class UserRegistrationForm(forms.Form): first_name = forms.CharField( label="First Name", required=False, widget=forms.TextInput(attrs={"class": "form-control"}), ) last_name = forms.CharField( label="Last Name", required=False, widget=forms.TextInput(attrs={"class": "form-control"}), ) username = forms.CharField( label="Username", required=True, widget=forms.TextInput(attrs={"class": "form-control"}), ) password = forms.CharField(widget=forms.PasswordInput( attrs={"class": "form-control"})) birth_date = forms.DateField( widget=forms.DateInput(attrs={"class": "form-control"}), required=False) profile_pic = forms.ImageField(required=False)
class PictureUploadForm(forms.ModelForm): title = forms.CharField( label='Заголовок', widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Введите название' })) picture = forms.ImageField(label='Картинка', required=False) class Meta: model = Picture include = ["title", "picture"]
class BlacklistForm(forms.Form): email = forms.CharField(label='Email', required=True, widget=forms.TextInput( attrs={ 'type': 'email', 'class': 'form-control', 'placeholder': '*****@*****.**' })) country = forms.ChoiceField( label='País', choices=COUNTRIES, required=True, widget=forms.Select(attrs={'class': 'form-control'}))
class New_Project_Date_form1(forms.Form): day1 = forms.CharField( required=False, max_length=2, label='', error_messages=date_error, widget=forms.TextInput( attrs={ 'placeholder': ' روز', 'style': "direction: ltr; width:60px; text-align-last:center; display:inline;", 'class': "form-control register-inputs" })) month1 = forms.CharField( required=False, max_length=2, label='', error_messages=date_error, widget=forms.TextInput( attrs={ 'placeholder': ' ماه', 'style': "direction: ltr; width:60px; text-align-last:center; display:inline;", 'class': "form-control register-inputs" })) year1 = forms.CharField( required=False, max_length=4, label='', error_messages=date_error, widget=forms.TextInput( attrs={ 'placeholder': ' سال', 'style': "direction: ltr; width:60px; text-align-last:center; display:inline;", 'class': "form-control register-inputs" }))
class LoginForm(forms.Form): username = forms.CharField( max_length=50, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter Username' })) password = forms.CharField( max_length=50, required=True, widget=forms.PasswordInput(attrs={ 'class': 'input', 'placeholder': 'Enter Password' }))