-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
706 additions
and
12 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
from django import forms | ||
|
||
from crispy_forms.layout import Layout, Fieldset | ||
|
||
from core.utils import horizontal_form_helper | ||
from labour.forms import AlternativeFormMixin | ||
from labour.models import Signup, JobCategory | ||
from programme.models import Category, Programme | ||
from programme.forms import AlternativeProgrammeFormMixin | ||
|
||
from .models import SignupExtra | ||
|
||
|
||
class SignupExtraForm(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = horizontal_form_helper() | ||
self.helper.form_tag = False | ||
self.helper.layout = Layout( | ||
"shift_type", | ||
"total_work", | ||
Fieldset( | ||
"Lisätiedot", | ||
"special_diet", | ||
"special_diet_other", | ||
"prior_experience", | ||
"free_text", | ||
), | ||
) | ||
|
||
class Meta: | ||
model = SignupExtra | ||
fields = ( | ||
"shift_type", | ||
"total_work", | ||
"special_diet", | ||
"special_diet_other", | ||
"prior_experience", | ||
"free_text", | ||
) | ||
|
||
widgets = dict( | ||
special_diet=forms.CheckboxSelectMultiple, | ||
) | ||
|
||
|
||
class OrganizerSignupForm(forms.ModelForm, AlternativeFormMixin): | ||
def __init__(self, *args, **kwargs): | ||
event = kwargs.pop("event") | ||
admin = kwargs.pop("admin") | ||
|
||
assert not admin | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
self.helper = horizontal_form_helper() | ||
self.helper.form_tag = False | ||
self.helper.layout = Layout( | ||
Fieldset( | ||
"Tehtävän tiedot", | ||
"job_title", | ||
), | ||
) | ||
|
||
self.fields["job_title"].help_text = "Mikä on vastaavatehtäväsi? Printataan badgeen." | ||
# self.fields['job_title'].required = True | ||
|
||
class Meta: | ||
model = Signup | ||
fields = ("job_title",) | ||
|
||
widgets = dict( | ||
job_categories=forms.CheckboxSelectMultiple, | ||
) | ||
|
||
def get_excluded_m2m_field_defaults(self): | ||
return dict(job_categories=JobCategory.objects.filter(event__slug="cosvision2023", name="Vastaava")) | ||
|
||
|
||
class OrganizerSignupExtraForm(forms.ModelForm, AlternativeFormMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = horizontal_form_helper() | ||
self.helper.form_tag = False | ||
self.helper.layout = Layout( | ||
Fieldset( | ||
"Lisätiedot", | ||
"special_diet", | ||
"special_diet_other", | ||
), | ||
) | ||
|
||
class Meta: | ||
model = SignupExtra | ||
fields = ( | ||
"special_diet", | ||
"special_diet_other", | ||
) | ||
|
||
widgets = dict( | ||
special_diet=forms.CheckboxSelectMultiple, | ||
) | ||
|
||
def get_excluded_field_defaults(self): | ||
return dict( | ||
shift_type="yli4h", | ||
total_work="yli8h", | ||
prior_experience="", | ||
free_text="Syötetty käyttäen vastaavan ilmoittautumislomaketta", | ||
) | ||
|
||
def get_excluded_m2m_field_defaults(self): | ||
return dict() | ||
|
||
|
||
class ProgrammeForm(forms.ModelForm, AlternativeProgrammeFormMixin): | ||
def __init__(self, *args, **kwargs): | ||
event = kwargs.pop("event") | ||
if "admin" in kwargs: | ||
admin = kwargs.pop("admin") | ||
else: | ||
admin = False | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
self.helper = horizontal_form_helper() | ||
self.helper.form_tag = False | ||
|
||
for field_name in [ | ||
"title", | ||
]: | ||
self.fields[field_name].required = True | ||
|
||
if not admin: | ||
for field_name in [ | ||
"description", | ||
# "video_permission", | ||
# "stream_permission", | ||
"photography", | ||
"rerun", | ||
# "encumbered_content", | ||
]: | ||
self.fields[field_name].required = True | ||
|
||
self.fields["category"].queryset = Category.objects.filter(event=event, public=True) | ||
self.fields["approximate_length"].initial = 60 | ||
self.fields[ | ||
"approximate_length" | ||
].help_text = "Arvio ohjelman pituudesta minuutteina. Huomaathan, että lopullinen ohjelmapaikan pituus voi poiketa tästä." | ||
|
||
def get_excluded_field_defaults(self): | ||
return dict() | ||
|
||
class Meta: | ||
model = Programme | ||
fields = ( | ||
"title", | ||
"description", | ||
"approximate_length", | ||
"category", | ||
"computer", | ||
"use_audio", | ||
"use_video", | ||
"number_of_microphones", | ||
"tech_requirements", | ||
# "video_permission", | ||
# "stream_permission", | ||
# "encumbered_content", | ||
"photography", | ||
"rerun", | ||
"room_requirements", | ||
"requested_time_slot", | ||
"notes_from_host", | ||
) | ||
|
||
|
||
class ProgrammeSignupExtraForm(forms.ModelForm, AlternativeFormMixin): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.helper = horizontal_form_helper() | ||
self.helper.form_tag = False | ||
self.helper.layout = Layout( | ||
"special_diet", | ||
"special_diet_other", | ||
) | ||
|
||
class Meta: | ||
model = SignupExtra | ||
fields = ( | ||
"special_diet", | ||
"special_diet_other", | ||
) | ||
|
||
widgets = dict( | ||
special_diet=forms.CheckboxSelectMultiple, | ||
) | ||
|
||
def get_excluded_field_defaults(self): | ||
return dict( | ||
free_text="Syötetty käyttäen ohjelmanjärjestäjän ilmoittautumislomaketta", | ||
) |
Empty file.
Empty file.
Oops, something went wrong.