from django import forms

import re
from sicurezza.views import getSecurityLevelAll
from .models import *

from django import forms

class formNota(forms.Form):
  def __init__(self,*args,**kwargs):
    forms.Form.__init__(self,*args,**kwargs)

    self.fields['soggetto'] = forms.CharField(required=True)
    self.fields['oggetto'] = forms.CharField(widget=forms.Textarea(attrs={'rows':4,'cols':60}),required=False,initial='')
    self.fields['livello'] = forms.ChoiceField(required=False,choices=self.listLivelli())
    self.fields['enabled'] =  forms.BooleanField(required=False)
    self.fields['tobedeleted'] = forms.BooleanField(required=False)

  def listLivelli(self):
    _livelli = []
    l = SecurityLevel.objects.all().filter(enabled=True).order_by('id')
    for i in l:
      _livelli.append((i.id,i.nome))
    return _livelli
