40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
from django.core.mail import send_mail
|
|
from django.urls import reverse_lazy
|
|
from django.views.generic import DetailView
|
|
from django.views.generic.edit import CreateView
|
|
|
|
from .forms import CommunityTrackProposalForm
|
|
from .models import CommunityTrackProposal
|
|
|
|
|
|
class CommunityTrackProposalCreateView(CreateView):
|
|
"""Show a form for accepting FOSSY community track proposals."""
|
|
|
|
form_class = CommunityTrackProposalForm
|
|
template_name = 'fossy/community_track_proposal_form.html'
|
|
|
|
def form_valid(self, form):
|
|
intro = 'The following FOSSY community track proposal 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(
|
|
'Community track proposal {}'.format(form.cleaned_data['title']),
|
|
body,
|
|
'conference@sfconservancy.org',
|
|
['conference@sfconservancy.org'],
|
|
)
|
|
return super().form_valid(form)
|
|
|
|
def get_success_url(self, *args, **kwargs):
|
|
return reverse_lazy('fossy-thanks', kwargs={'pk': str(self.object.uuid)})
|
|
|
|
|
|
class CommunityTrackProposalThanksView(DetailView):
|
|
model = CommunityTrackProposal
|
|
template_name = 'fossy/thanks.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context['form'] = CommunityTrackProposalForm(instance=self.object)
|
|
for _, field in context['form'].fields.items():
|
|
field.widget.attrs['disabled'] = 'disabled'
|
|
return context
|