<commit_before># -*- coding: UTF-8 -*-
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.db import transaction
from django.utils.translation import ugettext as _

import assopy.models as amodels
import assopy.forms as aforms
import conference.forms as cforms
import conference.models as cmodels
import conference.settings as csettings

from p3 import dataaccess
from p3 import models

import datetime

### Globals

## These should really be changes in the conference package:

# Talk lanuages, mapping ISO code to languageT
TALK_LANGUAGES = getattr(settings,
                         'CONFERENCE_TALK_LANGUAGES',
                         # TBD: Should add TALK_LANGUAGES to conference.settings
                         #csettings.TALK_LANGUAGES
                         settings.LANGUAGES
                         )

# Available talk durations
TALK_DURATION = getattr(settings,
                         'CONFERENCE_TALK_DURATION',
                         csettings.TALK_DURATION)

###

# TBD: These forms need some cleanup. Probably best to merge the
# conference repo into epcon and then remove all this subclassing.

class P3TalkFormMixin(object):
    def clean(self):
        data = super(P3TalkFormMixin, self).clean()

        # You can select the right duration now, so this is no longer
        # needed
        #if data['type'] in ('t', 'h'):
        #    data['duration'] = 240

        # Set default duration
        if not data.get('duration'):
            data['duration'] = 45

        # Set default language
        if not data.get('language') or data['type'] != 's':
            data['language'] = 'en'

        # Set Q&A duration
        if data['duration'] < 45:
            data['qa_duration'] = 5
        elif data['duration'] < 90:
            data['qa_duration'] = 10
        elif data['duration'] == 90:
            data['qa_duration'] = 15
        else:
            # Trainings and helpdesk don't get Q&A time
            data['qa_duration'] = 0

        return data


# This form is used for new talk submissions and only when the speaker
# has not yet submitted another talk; see P3SubmissionAdditionalForm
# for talk editing and additional talks.

class P3SubmissionForm(P3TalkFormMixin, cforms.SubmissionForm):
    duration = forms.TypedChoiceField(
        label=_('Duration'),
        help_text=_('This is the <i>desired duration</i> of the talk/training'),
        choices=TALK_DURATION,
        coerce=int,
        initial=30,
        required=False,
    )
    first_time = forms.BooleanField(
        label=_('I\'m a first-time speaker'),
        help_text=_('We would love to have more first time speakers at the conference. This setting will be visible for the Program WG to use in their talk selection.'),
        required=False,
    )
    type = forms.TypedChoiceField(
        label=_('Submission type'),
        help_text='Choose between a standard talk, an in-depth training, a poster session or an help desk session',
        choices=(('s', 'Standard talk'), ('t', 'Training'), ('p', 'Poster session'), ('h', 'Help Desk')),
        initial='s',
        required=True,
        widget=forms.RadioSelect(renderer=cforms.PseudoRadioRenderer),
    )

    # Note: These three fields are *not* saved in the talk record,
    # they are just used to show the checkboxes when first submitting
    # a talk and required, so that no talk can be submitted without
    # checking them.
    personal_agreement = forms.BooleanField(
        label=_('I agree to let you publish my profile data (excluding birth date and phone number).'),
        help_text=_('The speaker profile will be publicly accessible if one of your talks is accepted. Your mobile phone and date of birth will <i>never</i> be published'),
    )
    slides_agreement = forms.BooleanField(
        label=_('I agree to upload my presentation material after the event to this web site.'),
        help_text=_('If the talk is accepted, speakers are encouraged to upload their talk slides to make them available to users of this web site.'),
    )
    video_agreement = forms.BooleanField(
        label=_('I agree to have my presentation recorded and have read, understood and agree to the <a href="/speaker-release-agreement/">EuroPython Speaker Release Agreement</a>'),
        help_text=_('We will be recording the conference talks and publish them on the EuroPython YouTube channel and archive.org.'),
    )

    bio = forms.CharField(
        label=_('Compact biography'),
        help_text=_('Short biography (one or two paragraphs). Do not paste your CV'),
        widget=cforms.MarkEditWidget,)
    abstract = forms.CharField(
        max_length=5000,
        label=_('Abstract/description'),
        help_text=_('<p>
Short description of the talk/training/helpdesk/poster you are submitting. Be sure to include the goals and any prerequisite required to fully understand it. See the section "Submitting Your Talk, Trainings, Helpdesk or Poster“ of the CFP for further details.</p><p>Suggested size: two or three paragraphs.</p>'),
        widget=cforms.MarkEditWidget,)

    language = forms.TypedChoiceField(
        help_text=_('Select a non-English language only if you are not comfortable in speaking English.'),
        choices=TALK_LANGUAGES,
        initial='en', required=False)

    sub_community = forms.ChoiceField(
        label=_('Sub community'),
        help_text=_('Select the sub community this talk is intended for, if any.'),
        choices=models.TALK_SUBCOMMUNITY,
        initial='',
        required=False)

    def __init__(self, user, *args, **kwargs):
        data = {}<commit_msg>Fix typo.<commit_after># -*- coding: UTF-8 -*-
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.db import transaction
from django.utils.translation import ugettext as _

import assopy.models as amodels
import assopy.forms as aforms
import conference.forms as cforms
import conference.models as cmodels
import conference.settings as csettings

from p3 import dataaccess
from p3 import models

import datetime

### Globals

## These should really be changes in the conference package:

# Talk lanuages, mapping ISO code to languageT
TALK_LANGUAGES = getattr(settings,
                         'CONFERENCE_TALK_LANGUAGES',
                         # TBD: Should add TALK_LANGUAGES to conference.settings
                         #csettings.TALK_LANGUAGES
                         settings.LANGUAGES
                         )

# Available talk durations
TALK_DURATION = getattr(settings,
                         'CONFERENCE_TALK_DURATION',
                         csettings.TALK_DURATION)

###

# TBD: These forms need some cleanup. Probably best to merge the
# conference repo into epcon and then remove all this subclassing.

class P3TalkFormMixin(object):
    def clean(self):
        data = super(P3TalkFormMixin, self).clean()

        # You can select the right duration now, so this is no longer
        # needed
        #if data['type'] in ('t', 'h'):
        #    data['duration'] = 240

        # Set default duration
        if not data.get('duration'):
            data['duration'] = 45

        # Set default language
        if not data.get('language') or data['type'] != 's':
            data['language'] = 'en'

        # Set Q&A duration
        if data['duration'] < 45:
            data['qa_duration'] = 5
        elif data['duration'] < 90:
            data['qa_duration'] = 10
        elif data['duration'] == 90:
            data['qa_duration'] = 15
        else:
            # Trainings and helpdesk don't get Q&A time
            data['qa_duration'] = 0

        return data


# This form is used for new talk submissions and only when the speaker
# has not yet submitted another talk; see P3SubmissionAdditionalForm
# for talk editing and additional talks.

class P3SubmissionForm(P3TalkFormMixin, cforms.SubmissionForm):
    duration = forms.TypedChoiceField(
        label=_('Duration'),
        help_text=_('This is the <i>desired duration</i> of the talk/training'),
        choices=TALK_DURATION,
        coerce=int,
        initial=30,
        required=False,
    )
    first_time = forms.BooleanField(
        label=_('I\'m a first-time speaker'),
        help_text=_('We would love to have more first time speakers at the conference. This setting will be visible for the Program WG to use in their talk selection.'),
        required=False,
    )
    type = forms.TypedChoiceField(
        label=_('Submission type'),
        help_text='Choose between a standard talk, an in-depth training, a poster session or an help desk session',
        choices=(('s', 'Standard talk'), ('t', 'Training'), ('p', 'Poster session'), ('h', 'Help Desk')),
        initial='s',
        required=True,
        widget=forms.RadioSelect(renderer=cforms.PseudoRadioRenderer),
    )

    # Note: These three fields are *not* saved in the talk record,
    # they are just used to show the checkboxes when first submitting
    # a talk and required, so that no talk can be submitted without
    # checking them.
    personal_agreement = forms.BooleanField(
        label=_('I agree to let you publish my profile data (excluding birth date and phone number).'),
        help_text=_('The speaker profile will be publicly accessible if one of your talks is accepted. Your mobile phone and date of birth will <i>never</i> be published'),
    )
    slides_agreement = forms.BooleanField(
        label=_('I agree to upload my presentation material after the event to this web site.'),
        help_text=_('If the talk is accepted, speakers are encouraged to upload their talk slides to make them available to users of this web site.'),
    )
    video_agreement = forms.BooleanField(
        label=_('I agree to have my presentation recorded and have read, understood and agree to the <a href="/speaker-release-agreement/">EuroPython Speaker Release Agreement</a>'),
        help_text=_('We will be recording the conference talks and publish them on the EuroPython YouTube channel and archive.org.'),
    )

    bio = forms.CharField(
        label=_('Compact biography'),
        help_text=_('Short biography (one or two paragraphs). Do not paste your CV'),
        widget=cforms.MarkEditWidget,)
    abstract = forms.CharField(
        max_length=5000,
        label=_('Abstract/description'),
        help_text=_('<p>Short description of the talk/training/helpdesk/poster you are submitting. Be sure to include the goals and any prerequisite required to fully understand it. See the section "Submitting Your Talk, Trainings, Helpdesk or Poster“ of the CFP for further details.</p><p>Suggested size: two or three paragraphs.</p>'),
        widget=cforms.MarkEditWidget,)

    language = forms.TypedChoiceField(
        help_text=_('Select a non-English language only if you are not comfortable in speaking English.'),
        choices=TALK_LANGUAGES,
        initial='en', required=False)

    sub_community = forms.ChoiceField(
        label=_('Sub community'),
        help_text=_('Select the sub community this talk is intended for, if any.'),
        choices=models.TALK_SUBCOMMUNITY,
        initial='',
        required=False)

    def __init__(self, user, *args, **kwargs):
        data = {}
{'fraction_non_alphanumeric': 0.09039597848134756, 'fraction_numerical': 0.005467854308140048, 'mean_word_length': 2.815612382234186, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2036249', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2993, 'n_words': 1124}