Changeset - 80d2c2d73626
[Not reviewed]
0 1 4
James Tauber - 12 years ago 2012-07-13 13:21:27
jtauber@jtauber.com
added proposal models, forms and base fixtures to project
5 files changed with 207 insertions and 0 deletions:
0 comments (0 inline, 0 general)
fixtures/proposal_base.json
Show inline comments
 
new file 100644
 
[
 
    {
 
        "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"
 
        }
 
    }
 
]
...
 
\ No newline at end of file
symposion_project/proposals/__init__.py
Show inline comments
 
new file 100644
symposion_project/proposals/forms.py
Show inline comments
 
new file 100644
 
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(),
 
        }
symposion_project/proposals/models.py
Show inline comments
 
new file 100644
 
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"
symposion_project/settings.py
Show inline comments
...
 
@@ -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:
0 comments (0 inline, 0 general)