You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
# -*- coding: utf-8 -*-
|
|
from django import forms
|
|
from django.core.validators import RegexValidator
|
|
|
|
import models
|
|
from mydefs import ip_addr_regex
|
|
|
|
|
|
class AbonForm(forms.Form):
|
|
username = forms.CharField(max_length=127, required=False, widget=forms.TextInput(attrs={
|
|
'placeholder': u'Логин',
|
|
'class': "form-control",
|
|
'id': "login"
|
|
}))
|
|
fio = forms.CharField(max_length=256, widget=forms.TextInput(attrs={
|
|
'placeholder': u'ФИО',
|
|
'class': "form-control",
|
|
'id': "fio"
|
|
}), required=False)
|
|
ip_address = forms.GenericIPAddressField(protocol='IPv4', required=False, widget=forms.TextInput(attrs={
|
|
'pattern': ip_addr_regex,
|
|
'placeholder': u'127.0.0.1',
|
|
'class': "form-control",
|
|
'id': "ip"
|
|
}))
|
|
|
|
telephone = forms.CharField(
|
|
max_length=16,
|
|
validators=[RegexValidator(r'^\+[7,8,9,3]\d{10,11}$')],
|
|
widget=forms.TextInput(attrs={
|
|
'placeholder': u'+[7,8,9,3] и 10,11 цифр',
|
|
'pattern': r'^\+[7,8,9,3]\d{10,11}$',
|
|
'required': '',
|
|
'class': 'form-control',
|
|
'id': 'telephone'
|
|
})
|
|
)
|
|
is_active = forms.BooleanField(
|
|
required=False,
|
|
widget=forms.NullBooleanSelect(attrs={'class': 'form-control', 'id': 'isactive'})
|
|
)
|
|
|
|
group = forms.ModelChoiceField(
|
|
queryset=models.AbonGroup.objects.all(),
|
|
required=False,
|
|
widget=forms.Select(attrs={'class': 'form-control', 'id': 'grp'})
|
|
)
|
|
address = forms.CharField(
|
|
max_length=256,
|
|
required=False,
|
|
widget = forms.TextInput(attrs={'class': 'form-control', 'id': 'address'})
|
|
)
|
|
|
|
|
|
class AbonGroupForm(forms.ModelForm):
|
|
class Meta:
|
|
model = models.AbonGroup
|
|
fields = ['title', 'address']
|
|
widgets = {
|
|
'class': 'form-control'
|
|
}
|
|
|
|
|
|
class BuyTariff(forms.Form):
|
|
tariff = forms.ModelChoiceField(
|
|
queryset=models.Tariff.objects.all(),
|
|
required=True,
|
|
widget=forms.Select(attrs={'class': 'form-control', 'id': 'tariff'})
|
|
)
|