Guest User

Untitled

a guest
Jan 16th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. from django import forms
  2. from django.forms import ModelForm, TextInput
  3. from django.contrib.auth.forms import AuthenticationForm
  4. from django.utils.translation import ugettext_lazy as _
  5.  
  6. from panel.models import Location, SwTitle, KvmPort, Equipment, Employee
  7.  
  8. class BootstrapAuthenticationForm(AuthenticationForm):
  9. username = forms.CharField(max_length=254,
  10. widget=forms.TextInput({
  11. 'class': 'form-control',
  12. 'placeholder': 'Имя пользователя'}))
  13. password = forms.CharField(label=_("Password"),
  14. widget=forms.PasswordInput({
  15. 'class': 'form-control',
  16. 'placeholder': 'Пароль'}))
  17.  
  18.  
  19. class ChoiceForm(forms.Form):
  20. LIST_ACTION = (('1', 'Местоположение коммутаторов'), ('2', 'КВМ-порты'), ('3', 'Номера сотрудников'))
  21. RANGE_FLOOR = ((str(x), x) for x in range(1, 14))
  22. choice_action = forms.ChoiceField(label='Выберите объекты редактирования:', choices=LIST_ACTION, widget=forms.Select())
  23. choice_floor = forms.ChoiceField(label='Этаж:', choices=RANGE_FLOOR, widget=forms.Select())
  24.  
  25.  
  26. class LocationForm(ModelForm):
  27. class Meta:
  28. model = Location
  29. fields = ('floor', 'block', 'room', 'line', 'area')
  30. labels = {
  31. 'floor': 'Этаж',
  32. 'block': 'Блок',
  33. 'room': 'Помещение',
  34. 'line': 'Ряд',
  35. 'area': 'Место'
  36. }
  37. # text_field = forms.CharField(widget=forms.Textarea)
  38.  
  39. class SwTitleForm(ModelForm):
  40. class Meta:
  41. model = SwTitle
  42. fields = ('title', 'equipment', 'location')
  43. labels = {
  44. 'title': 'Название',
  45. 'equipment': 'Оборудование',
  46. 'location': 'Местонахождение'
  47. }
  48. widgets = {
  49. 'equipment': TextInput(),
  50. }
  51.  
  52. class KvmPortForm(ModelForm):
  53. class Meta:
  54. model = KvmPort
  55. fields = ['port', 'comment']
  56.  
  57. class EquipmentForm(ModelForm):
  58. class Meta:
  59. model = Equipment
  60. fields = ['model_name']
  61.  
  62. class EmployeeForm(ModelForm):
  63. class Meta:
  64. model = Employee
  65. fields = ('employee', 'phone_number', 'location')
  66. labels = {
  67. 'employee': 'Сотрудник',
  68. 'phone_number': 'Номер',
  69. 'location': 'Место работы',
  70. }
Add Comment
Please, Sign In to add comment