forms.py 1.12 KB
Newer Older
stef's avatar
stef committed
1
2
from django import forms
from django.conf import settings
3
4
from bt.models import Violation, COUNTRIES
from operator import itemgetter
stef's avatar
stef committed
5
6
7
8
9
10
11
12
13
14
15

class AdvancedEditor(forms.Textarea):
	class Media:
		js = (settings.MEDIA_URL+'/js/tinymce/tiny_mce.js',)

	def __init__(self, language=None, attrs=None):
		self.language = language or settings.LANGUAGE_CODE[:2]
		self.attrs = {'class': 'advancededitor'}
		if attrs: self.attrs.update(attrs)
		super(AdvancedEditor, self).__init__(attrs)

16
17
18
19
20
21
22
23
24
25
26
27
class AddViolation(forms.Form):
   country = forms.ChoiceField(choices=(('',''),)+tuple(sorted(COUNTRIES,key=itemgetter(1))))
   operator = forms.CharField(max_length=256)
   contract = forms.CharField(max_length=256)
   comment = forms.CharField(required=True, widget=AdvancedEditor())
   resource = forms.CharField(required=False, max_length=1)
   type = forms.CharField(max_length=1)
   media = forms.CharField(required=False, max_length=1)
   temporary = forms.BooleanField(required=False )
   contractual = forms.BooleanField(required=False)
   contract_excerpt = forms.CharField(required=False, widget=AdvancedEditor())
   loophole = forms.BooleanField(required=False)