# Path: conference/cfp/forms.py
# class WorkshopSubmissionForm(forms.ModelForm):
# 
#     class Meta:
#         model = WorkshopSubmission
#         fields = (
#             'author', 'email', 'author_bio', 'proposal_title',
#             'proposal_abstract', 'proposal_audience', 'workshop_duration',
#             'notes'
#         )
# 
#     def __init__(self, *args, **kwargs):
#         super(WorkshopSubmissionForm, self).__init__(*args, **kwargs)
#         self.fields['author'].label = _('Your name')
#         self.fields['email'].label = _('Your email')
#         self.fields['author_bio'].label = _('Tell us about yourself')
#         self.fields['proposal_title'].label = _('Your proposal\'s title')
#         self.fields['proposal_abstract'].label = _('Abstract of your proposal')
#         self.fields['proposal_audience'].label = _(
#             'What\'s the intended audience of your proposal?')
#         self.fields['workshop_duration'].lable = _('How long is the workshop?')
# 
# Path: conference/cfp/models.py
# class WorkshopSubmission(AbstractSubmission):
#     TWO_HOURS = '2'
#     DURATIONS = (
#         (TWO_HOURS, _('2 Hours')),
#     )
#     workshop_duration = models.CharField(
#         _('Duration'), choices=DURATIONS, max_length=10,
#     )
# 
#     class Meta:
#         verbose_name = _('workshop submission')
#         verbose_name_plural = _('workshop submissions')
# 
# Path: conference/cfp/views.py
# class SubmissionView(CreateView):
#     thanks_page = 'thanks_cfp'
#     closed_page = 'closed_cfp'
#     closing_date = settings.CFP_CLOSING_DATE
# 
#     def _send_notification(self):
#         if self.object:
#             with open(os.path.join(settings.STATIC_ROOT, 'css', 'style.css'), 'r') as css_file:
#                 css = css_file.read()
#             context = {
#                 'css': css,
#                 'instance': self.object
#             }
#             email = MagicMailBuilder()
#             notification = email.submission_notification(self.object.email, context)
#             notification.send()
# 
#     def get_success_url(self):
#         self._send_notification()
#         try:
#             return Page.objects.public().get(reverse_id=self.thanks_page).get_absolute_url()
#         except Page.DoesNotExist:
#             return Page.objects.public().get_home().get_absolute_url()
# 
#     def get(self, request, *args, **kwargs):
#         if is_cfp_closed(self.closing_date):
#             redirect_url = Page.objects.public().get(reverse_id=self.closed_page).get_absolute_url()
#             return HttpResponseRedirect(redirect_url)
#         return super(SubmissionView, self).get(request, *args, **kwargs)


from django.conf import settings
from django.conf.urls import url
from .forms import WorkshopSubmissionForm
from .models import WorkshopSubmission
from .views import SubmissionView
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals



urlpatterns = [
    url(r'^', SubmissionView.as_view(
        form_class=WorkshopSubmissionForm, model=WorkshopSubmission,
        thanks_page='thanks_workshop', closed_page='closed_workshop',
        closing_date=settings.WORKSHOP_CLOSING_DATE
    ), name='cfp_talks_submission'),

# Path: conference/cfp/forms.py
# class WorkshopSubmissionForm(forms.ModelForm):
# 
#     class Meta:
#         model = WorkshopSubmission
#         fields = (
#             'author', 'email', 'author_bio', 'proposal_title',
#             'proposal_abstract', 'proposal_audience', 'workshop_duration',
#             'notes'
#         )
# 
#     def __init__(self, *args, **kwargs):
#         super(WorkshopSubmissionForm, self).__init__(*args, **kwargs)
#         self.fields['author'].label = _('Your name')
#         self.fields['email'].label = _('Your email')
#         self.fields['author_bio'].label = _('Tell us about yourself')
#         self.fields['proposal_title'].label = _('Your proposal\'s title')
#         self.fields['proposal_abstract'].label = _('Abstract of your proposal')
#         self.fields['proposal_audience'].label = _(
#             'What\'s the intended audience of your proposal?')
#         self.fields['workshop_duration'].lable = _('How long is the workshop?')
# 
# Path: conference/cfp/models.py
# class WorkshopSubmission(AbstractSubmission):
#     TWO_HOURS = '2'
#     DURATIONS = (
#         (TWO_HOURS, _('2 Hours')),
#     )
#     workshop_duration = models.CharField(
#         _('Duration'), choices=DURATIONS, max_length=10,
#     )
# 
#     class Meta:
#         verbose_name = _('workshop submission')
#         verbose_name_plural = _('workshop submissions')
# 
# Path: conference/cfp/views.py
# class SubmissionView(CreateView):
#     thanks_page = 'thanks_cfp'
#     closed_page = 'closed_cfp'
#     closing_date = settings.CFP_CLOSING_DATE
# 
#     def _send_notification(self):
#         if self.object:
#             with open(os.path.join(settings.STATIC_ROOT, 'css', 'style.css'), 'r') as css_file:
#                 css = css_file.read()
#             context = {
#                 'css': css,
#                 'instance': self.object
#             }
#             email = MagicMailBuilder()
#             notification = email.submission_notification(self.object.email, context)
#             notification.send()
# 
#     def get_success_url(self):
#         self._send_notification()
#         try:
#             return Page.objects.public().get(reverse_id=self.thanks_page).get_absolute_url()
#         except Page.DoesNotExist:
#             return Page.objects.public().get_home().get_absolute_url()
# 
#     def get(self, request, *args, **kwargs):
#         if is_cfp_closed(self.closing_date):
#             redirect_url = Page.objects.public().get(reverse_id=self.closed_page).get_absolute_url()
#             return HttpResponseRedirect(redirect_url)
#         return super(SubmissionView, self).get(request, *args, **kwargs)


# Path: conference/cfp/workshop_urls.py
from django.conf import settings
from django.conf.urls import url
from .forms import WorkshopSubmissionForm
from .models import WorkshopSubmission
from .views import SubmissionView

# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals



urlpatterns = [
    url(r'^', SubmissionView.as_view(
        form_class=WorkshopSubmissionForm, model=WorkshopSubmission,
        thanks_page='thanks_workshop', closed_page='closed_workshop',
        closing_date=settings.WORKSHOP_CLOSING_DATE
    ), name='cfp_talks_submission'),

]