Changeset - c9a76ea17fe3
[Not reviewed]
0 2 0
Ben Sturmfels (bsturmfels) - 2 years ago 2021-12-10 23:25:57
ben@sturm.com.au
assignment: Fix period ends in email.
2 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/assignment/forms.py
Show inline comments
...
 
@@ -56,12 +56,14 @@ class AssignmentForm(forms.ModelForm):
 
            'period_end_type',
 
            'period_ends',
 
            'agreement_terms',
 
            'attestation_of_copyright',
 
        ]
 

	
 
    def clean_period_ends(self):
 
        if 'period_begins' in self.cleaned_data and 'period_ends' in self.cleaned_data and self.cleaned_data['period_begins'] and self.cleaned_data['period_ends'] and self.cleaned_data['period_begins'] > self.cleaned_data['period_ends']:
 
            raise ValidationError('End of period is before start')
 

	
 
        if self.cleaned_data['period_end_type'] == 'a specific past date' and not self.cleaned_data['period_ends']:
 
            raise ValidationError('This field is required')
 

	
 
        return self.cleaned_data['period_ends']
www/conservancy/apps/assignment/views.py
Show inline comments
...
 
@@ -13,25 +13,25 @@ class AssignmentCreateView(CreateView):
 
    template_name = 'assignment/assignment_form.html'
 

	
 
    def form_valid(self, form):
 
        intro = 'The following copyright assignment has been submitted:\n\n'
 
        body = intro + '\n'.join(['{}: {}'.format(k, v) for k, v in form.cleaned_data.items() if k != 'agreement_terms'])
 
        send_mail(
 
            'Copyright assignment form: {}'.format(form.cleaned_data['full_name']),
 
            body,
 
            'ben@sturm.com.au',
 
            ['denver@sfconservancy.org', 'bsturmfels@sfconservancy.org'],
 
        )
 
        return super().form_valid(form)
 
    
 

 
    def get_success_url(self, *args, **kwargs):
 
        return reverse_lazy('assignment-thanks', kwargs={'pk': str(self.object.uuid)})
 

	
 

	
 
class AssignmentThanksView(DetailView):
 
    model = Assignment
 
    template_name = 'assignment/thanks.html'
 

	
 
    def get_context_data(self, **kwargs):
 
        context = super().get_context_data(**kwargs)
 
        context['form'] = AssignmentForm(instance=self.object)
 
        for _, field in context['form'].fields.items():
0 comments (0 inline, 0 general)