# Path: leavedemo/leave/models.py
# class LeaveRequest(models.Model):
#     TYPE_CHOICES = (
#             ('Vacation','Vacation'),
#             ('Birth or marriage of child','Birth or marriage of child'),
#             ('Change of residence','Change of residence'),
#             ('Death of a child','Death of a child'),
#             ('Death of a relative in the ascending line','Death of a relative in the ascending line'),
#             ('Death of parent-in-law, brother or sister','Death of parent-in-law, brother or sister'),
#             ('Death of spouse','Death of spouse'),
#             ('Marriage','Marriage'),
#             ('Maternity','Maternity'),
#             ('Serious illness of a child','Serious illness of a child'),
#             ('Serious illness of a relative in the asc line','Serious illness of a relative in the asc line'),
#             ('Serious illness of a parent-in-law','Serious illness of a parent-in-law'),
#             ('Serious illness of spouse','Serious illness of spouse'))
#     date = models.DateTimeField(auto_now=True)
#     day_start = models.DateField()
#     day_end = models.DateField()
#     type = models.CharField(max_length=50, choices=TYPE_CHOICES, default='Vacation')
#     reason = models.TextField(null=True, blank=True)
#     reason_denial = models.TextField(null=True, blank=True, verbose_name='reason of denial')
#     requester = models.ForeignKey(User, null=True, blank=True)
#     
#     def __unicode__(self):
#         return 'leaverequest-%s' % str(self.pk)
# 
# Path: goflow/apptools/forms.py
# class BaseForm(ModelForm):
#     '''
#     base class for edition forms
#     '''
#     
#     workitem_id = forms.IntegerField(widget=forms.HiddenInput, required=False)
#     priority = forms.ChoiceField(label='Priority', widget=forms.RadioSelect, initial='0',
#                                  choices=(('0','normal'), ('1','urgent'), ('5','emergency')),
#                                  )
#     def save(self, workitem=None, submit_value=None, commit=True):
#         ob = super(BaseForm, self).save(commit=commit)
#         if workitem and workitem.can_priority_change():
#             workitem.priority = int(self.cleaned_data['priority'])
#             workitem.save()
#         return ob
#     
#     def pre_check(self, obj_context=None, user=None):
#         """may be overriden to do some check before.
#         
#         obj_context    object instance (if cmp_attr is set, this is the root object)
#         an exception should be risen if pre-conditions are not fullfilled
#         """
#         pass
# 
#     class Meta:
#          exclude = ('workitem_id',)
# 
# class StartForm(ModelForm):
#     '''
#     base class for starting a workflow
#     '''
#     priority = forms.ChoiceField(label='Priority', widget=forms.RadioSelect, initial='0',
#                                  choices=(('0','normal'), ('1','urgent'), ('5','emergency')),
#                                  )
#     
#     def save(self, user=None, data=None, commit=True):
#         ob = super(StartForm, self).save(commit=commit)
#         return ob
#     
#     def pre_check(self, user=None):
#         """may be overriden to do some check before.
#         
#         an exception should be risen if pre-conditions are not fullfilled
#         """
#         pass


from .models import LeaveRequest
from goflow.apptools.forms import BaseForm, StartForm
from django import forms
#!/usr/local/bin/python
# -*- coding: utf-8 -*-


# allows calendar widgets

class StartRequestForm(StartForm):
    day_start = forms.DateField(widget=forms.TextInput(attrs={'class': 'vDateField'}))
    day_end = forms.DateField(widget=forms.TextInput(attrs={'class': 'vDateField'}))
    
    def save(self, user, data=None, commit=True):
        ''' overriden for adding the requester
        '''
        obj = super(StartForm, self).save(commit=False)
        obj.requester = user
        obj.save()
        return obj
    
    class Meta:
         model = LeaveRequest
         exclude = ('reason_denial', 'requester')


# Path: leavedemo/leave/models.py
# class LeaveRequest(models.Model):
#     TYPE_CHOICES = (
#             ('Vacation','Vacation'),
#             ('Birth or marriage of child','Birth or marriage of child'),
#             ('Change of residence','Change of residence'),
#             ('Death of a child','Death of a child'),
#             ('Death of a relative in the ascending line','Death of a relative in the ascending line'),
#             ('Death of parent-in-law, brother or sister','Death of parent-in-law, brother or sister'),
#             ('Death of spouse','Death of spouse'),
#             ('Marriage','Marriage'),
#             ('Maternity','Maternity'),
#             ('Serious illness of a child','Serious illness of a child'),
#             ('Serious illness of a relative in the asc line','Serious illness of a relative in the asc line'),
#             ('Serious illness of a parent-in-law','Serious illness of a parent-in-law'),
#             ('Serious illness of spouse','Serious illness of spouse'))
#     date = models.DateTimeField(auto_now=True)
#     day_start = models.DateField()
#     day_end = models.DateField()
#     type = models.CharField(max_length=50, choices=TYPE_CHOICES, default='Vacation')
#     reason = models.TextField(null=True, blank=True)
#     reason_denial = models.TextField(null=True, blank=True, verbose_name='reason of denial')
#     requester = models.ForeignKey(User, null=True, blank=True)
#     
#     def __unicode__(self):
#         return 'leaverequest-%s' % str(self.pk)
# 
# Path: goflow/apptools/forms.py
# class BaseForm(ModelForm):
#     '''
#     base class for edition forms
#     '''
#     
#     workitem_id = forms.IntegerField(widget=forms.HiddenInput, required=False)
#     priority = forms.ChoiceField(label='Priority', widget=forms.RadioSelect, initial='0',
#                                  choices=(('0','normal'), ('1','urgent'), ('5','emergency')),
#                                  )
#     def save(self, workitem=None, submit_value=None, commit=True):
#         ob = super(BaseForm, self).save(commit=commit)
#         if workitem and workitem.can_priority_change():
#             workitem.priority = int(self.cleaned_data['priority'])
#             workitem.save()
#         return ob
#     
#     def pre_check(self, obj_context=None, user=None):
#         """may be overriden to do some check before.
#         
#         obj_context    object instance (if cmp_attr is set, this is the root object)
#         an exception should be risen if pre-conditions are not fullfilled
#         """
#         pass
# 
#     class Meta:
#          exclude = ('workitem_id',)
# 
# class StartForm(ModelForm):
#     '''
#     base class for starting a workflow
#     '''
#     priority = forms.ChoiceField(label='Priority', widget=forms.RadioSelect, initial='0',
#                                  choices=(('0','normal'), ('1','urgent'), ('5','emergency')),
#                                  )
#     
#     def save(self, user=None, data=None, commit=True):
#         ob = super(StartForm, self).save(commit=commit)
#         return ob
#     
#     def pre_check(self, user=None):
#         """may be overriden to do some check before.
#         
#         an exception should be risen if pre-conditions are not fullfilled
#         """
#         pass


# Path: leavedemo/leave/forms.py
from .models import LeaveRequest
from goflow.apptools.forms import BaseForm, StartForm
from django import forms

#!/usr/local/bin/python
# -*- coding: utf-8 -*-


# allows calendar widgets

class StartRequestForm(StartForm):
    day_start = forms.DateField(widget=forms.TextInput(attrs={'class': 'vDateField'}))
    day_end = forms.DateField(widget=forms.TextInput(attrs={'class': 'vDateField'}))
    
    def save(self, user, data=None, commit=True):
        ''' overriden for adding the requester
        '''
        obj = super(StartForm, self).save(commit=False)
        obj.requester = user
        obj.save()
        return obj
    
    class Meta:
         model = LeaveRequest
         exclude = ('reason_denial', 'requester')


class RequesterForm(BaseForm):