forms.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from django import forms
  2. import re
  3. class LogoForm(forms.Form):
  4. namesystem = forms.CharField(max_length=30, label="Название системы", required=False)
  5. logo = forms.FileField(label="Логотип", required=False)
  6. logo.widget.attrs.update({'accept':'.png, .svg, .ico'})
  7. class ColorsForm(forms.Form):
  8. f = str((open('design_template/static/design_template/colors.css',encoding='utf-8')).read())
  9. color_codes_list = re.findall(r'#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}', f)
  10. color_codes_list.append('#821e27')
  11. color_codes_list.append('#ffffff')
  12. colors = color_codes_list
  13. btnBg = forms.CharField(label='Цвет кнопок', initial=colors[0] , max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  14. btnTxt = forms.CharField(label='Цвет текста кнопок', initial=colors[1], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  15. btnHover = forms.CharField(label='Цвет наведения у кнопок', initial=colors[2], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  16. pillsBg = forms.CharField(label='Цвет плашек в меню', initial=colors[3], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  17. pillsTxt = forms.CharField(label='Цвет текста плашек в меню', initial=colors[4], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  18. linksTxt = forms.CharField(label='Цвет текста ссылок', initial=colors[5], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  19. linksHover = forms.CharField(label='Цвет наведения у ссылок', initial=colors[6], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  20. btnSuccessBg = forms.CharField(label='Цвет кнопок успеха', initial=colors[7], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  21. btnSuccessTxt = forms.CharField(label='Цвет текста кнопок успеха', initial=colors[8], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  22. btnSuccessHover = forms.CharField(label='Цвет наведения у кнопок успеха', initial=colors[9], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  23. btnDangerBg = forms.CharField(label='Цвет текста кнопок предупреждения', initial=colors[10], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  24. btnDangerTxt = forms.CharField(label='Цвет текста кнопок предупреждения', initial=colors[11], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
  25. btnDangerHover = forms.CharField(label='Цвет наведения у кнопок предупреждения', initial=colors[12], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))