Example #1
0
 def __init__(self, *args, **kwargs):
     super(NewCaseForm, self).__init__(*args, **kwargs)
     self.instance.created_by = self.user
     self.helper.add_input(Submit('save', _("Save"), css_class="btn-primary"))
     if can_send(self.user, self.instance):
         self.helper.add_input(Submit('send', _("Save & send"), css_class="btn-primary"))
     self.instance.created_by = self.user
     self.helper.layout = Layout(
         Fieldset(
             _('Identification'),
             'name',
         ),
         Fieldset(
             _('Recipient'),
             Div(
                 Div('office', css_class='col-sm-6'),
                 Div('email', css_class='col-sm-6'),
                 css_class='row'
             ),
             'postcode'
         ),
         Fieldset(
             _('Content'),
             'subject',
             'text',
         ),
     )
Example #2
0
 def save_letter(self):
     letter = OutgoingLetter(case=self.instance,
                             office=self.cleaned_data['office'],
                             subject=self.cleaned_data['subject'],
                             content=self.cleaned_data['text'],
                             email=self.cleaned_data['email'].email,
                             author=self.user)
     if 'send' in self.data and can_send(self.user, self.instance):
         letter.send(user=self.user)
     letter.save()
     return letter