added proposal models, forms and base fixtures to project
This commit is contained in:
parent
9d367667f2
commit
80d2c2d736
5 changed files with 207 additions and 0 deletions
62
fixtures/proposal_base.json
Normal file
62
fixtures/proposal_base.json
Normal file
|
@ -0,0 +1,62 @@
|
|||
[
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "proposals.proposalsection",
|
||||
"fields": {
|
||||
"start": null,
|
||||
"section": 1,
|
||||
"end": null,
|
||||
"closed": null,
|
||||
"published": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "proposals.proposalsection",
|
||||
"fields": {
|
||||
"start": null,
|
||||
"section": 2,
|
||||
"end": null,
|
||||
"closed": null,
|
||||
"published": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 3,
|
||||
"model": "proposals.proposalsection",
|
||||
"fields": {
|
||||
"start": null,
|
||||
"section": 3,
|
||||
"end": null,
|
||||
"closed": null,
|
||||
"published": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "proposals.proposalkind",
|
||||
"fields": {
|
||||
"section": 1,
|
||||
"name": "tutorial",
|
||||
"slug": "tutorial"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "proposals.proposalkind",
|
||||
"fields": {
|
||||
"section": 2,
|
||||
"name": "talk",
|
||||
"slug": "talk"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 3,
|
||||
"model": "proposals.proposalkind",
|
||||
"fields": {
|
||||
"section": 3,
|
||||
"name": "poster",
|
||||
"slug": "poster"
|
||||
}
|
||||
}
|
||||
]
|
0
symposion_project/proposals/__init__.py
Normal file
0
symposion_project/proposals/__init__.py
Normal file
81
symposion_project/proposals/forms.py
Normal file
81
symposion_project/proposals/forms.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
from django import forms
|
||||
|
||||
from markitup.widgets import MarkItUpWidget
|
||||
|
||||
from symposion_project.proposals.models import ProposalCategory, TalkProposal, TutorialProposal, PosterProposal
|
||||
|
||||
|
||||
class ProposalForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ProposalForm, self).__init__(*args, **kwargs)
|
||||
self.fields["category"] = forms.ModelChoiceField(
|
||||
queryset = ProposalCategory.objects.order_by("name")
|
||||
)
|
||||
|
||||
def clean_description(self):
|
||||
value = self.cleaned_data["description"]
|
||||
if len(value) > 400:
|
||||
raise forms.ValidationError(
|
||||
u"The description must be less than 400 characters"
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
class TalkProposalForm(ProposalForm):
|
||||
|
||||
class Meta:
|
||||
model = TalkProposal
|
||||
fields = [
|
||||
"title",
|
||||
"category",
|
||||
"audience_level",
|
||||
"description",
|
||||
"abstract",
|
||||
"additional_notes",
|
||||
"recording_release",
|
||||
]
|
||||
widgets = {
|
||||
"abstract": MarkItUpWidget(),
|
||||
"additional_notes": MarkItUpWidget(),
|
||||
}
|
||||
|
||||
|
||||
class TutorialProposalForm(ProposalForm):
|
||||
|
||||
class Meta:
|
||||
model = TutorialProposal
|
||||
fields = [
|
||||
"title",
|
||||
"category",
|
||||
"audience_level",
|
||||
"description",
|
||||
"abstract",
|
||||
"additional_notes",
|
||||
"recording_release",
|
||||
|
||||
]
|
||||
widgets = {
|
||||
"abstract": MarkItUpWidget(),
|
||||
"additional_notes": MarkItUpWidget(),
|
||||
}
|
||||
|
||||
|
||||
class PosterProposalForm(ProposalForm):
|
||||
|
||||
class Meta:
|
||||
model = PosterProposal
|
||||
fields = [
|
||||
"title",
|
||||
"category",
|
||||
"audience_level",
|
||||
"description",
|
||||
"abstract",
|
||||
"additional_notes",
|
||||
"recording_release",
|
||||
|
||||
]
|
||||
widgets = {
|
||||
"abstract": MarkItUpWidget(),
|
||||
"additional_notes": MarkItUpWidget(),
|
||||
}
|
55
symposion_project/proposals/models.py
Normal file
55
symposion_project/proposals/models.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
from django.db import models
|
||||
|
||||
from symposion.proposals.models import ProposalBase
|
||||
|
||||
|
||||
class ProposalCategory(models.Model):
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
slug = models.SlugField()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "proposal category"
|
||||
verbose_name_plural = "proposal categories"
|
||||
|
||||
|
||||
class Proposal(ProposalBase):
|
||||
|
||||
AUDIENCE_LEVEL_NOVICE = 1
|
||||
AUDIENCE_LEVEL_EXPERIENCED = 2
|
||||
AUDIENCE_LEVEL_INTERMEDIATE = 3
|
||||
|
||||
AUDIENCE_LEVELS = [
|
||||
(AUDIENCE_LEVEL_NOVICE, "Novice"),
|
||||
(AUDIENCE_LEVEL_INTERMEDIATE, "Intermediate"),
|
||||
(AUDIENCE_LEVEL_EXPERIENCED, "Experienced"),
|
||||
]
|
||||
|
||||
category = models.ForeignKey(ProposalCategory)
|
||||
audience_level = models.IntegerField(choices=AUDIENCE_LEVELS)
|
||||
|
||||
recording_release = models.BooleanField(
|
||||
default=True,
|
||||
help_text="By submitting your talk proposal, you agree to give permission to the conference organizers to record, edit, and release audio and/or video of your presentation. If you do not agree to this, please uncheck this box."
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class TalkProposal(Proposal):
|
||||
class Meta:
|
||||
verbose_name = "talk proposal"
|
||||
|
||||
|
||||
class TutorialProposal(Proposal):
|
||||
class Meta:
|
||||
verbose_name = "tutorial proposal"
|
||||
|
||||
|
||||
class PosterProposal(Proposal):
|
||||
class Meta:
|
||||
verbose_name = "poster proposal"
|
|
@ -169,6 +169,9 @@ INSTALLED_APPS = [
|
|||
"symposion.boxes",
|
||||
"symposion.proposals",
|
||||
"symposion.speakers",
|
||||
|
||||
# project
|
||||
"symposion_project.proposals",
|
||||
]
|
||||
|
||||
FIXTURE_DIRS = [
|
||||
|
@ -209,6 +212,12 @@ CONFERENCE_ID = 1
|
|||
|
||||
SYMPOSION_PAGE_REGEX = r"(([\w-]{1,})(/[\w-]{1,})*)/"
|
||||
|
||||
PROPOSAL_FORMS = {
|
||||
"tutorial": "symposion_project.proposals.forms.TutorialProposalForm",
|
||||
"talk": "symposion_project.proposals.forms.TalkProposalForm",
|
||||
"poster": "symposion_project.proposals.forms.PosterProposalForm",
|
||||
}
|
||||
|
||||
# local_settings.py can be used to override environment-specific settings
|
||||
# like database and email that differ between development and production.
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue