Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes it easier to customise proposals #164

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/proposals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ There is also an ``additional_notes`` field which can be used for speakers to
communicate additional information about their proposal to reviewers that is
not intended to be shared with others.

The ``description``, ``abstract``, and ``additional_notes`` fields are
not required in the model. See "How To Add Custom Proposal Kinds" for
information on how make these required for end-users.

This base model supports each proposal having multiple speakers (although
the submitting speaker is always treated differently) and also supports
the attachments of supporting documents for reviewers that are, like the
Expand Down Expand Up @@ -102,10 +106,28 @@ For each kind:
name of your ``ModelForm``.

For example::

PROPOSAL_FORMS = {
"tutorial": "pycon.forms.PyConTutorialProposalForm",
"talk": "pycon.forms.PyConTalkProposalForm",
"poster": "pycon.forms.PyConPosterProposalForm",
}

You may wish to make some of the pre-defined fields required fields. By default
neither ``description``, ``abstract``, or ``additional_notes`` are required.

You can make your proposal form include ``ProposalMixIn`` as a base class
which can let you make these fields required within the form in the form's
initializer. For example::

from symposion.proposals.forms import ProposalMixIn


class ProposalForm(forms.ModelForm, ProposalMixIn):

def __init__(self, *a, **k):
super(ProposalForm, self).__init__(*a, **k)
print "Hello!"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this print a debugging remnant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that should definitely not be there.

self.description_required()

will create a form whose ``description`` field is required.
19 changes: 19 additions & 0 deletions symposion/proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@

# @@@ generic proposal form

class ProposalMixIn(forms.Form):
''' A MixIn form that allows apps that subclass ProposalBase to set
the abstract, description, or additional notes fields to be required.

See proposals.rst for information.
'''

def _set_field_required(self, key, required):
self.fields[key].required = required

def abstract_required(self, required=True):
self._set_field_required("abstract", required)

def description_required(self, required=True):
self._set_field_required("description", required)

def additional_notes_required(self, required=True):
self._set_field_required("additional_notes", required)


class AddSpeakerForm(forms.Form):

Expand Down
25 changes: 25 additions & 0 deletions symposion/proposals/migrations/0002_auto_20170811_1903.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2017-08-11 19:03
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('symposion_proposals', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='proposalbase',
name='abstract',
field=models.TextField(blank=True, help_text="Detailed outline. Will be made public if your proposal is accepted. Edit using <a href='http://daringfireball.net/projects/markdown/basics' target='_blank'>Markdown</a>.", verbose_name='Detailed Abstract'),
),
migrations.AlterField(
model_name='proposalbase',
name='description',
field=models.TextField(blank=True, help_text='If your proposal is accepted this will be made public and printed in the program. Should be one paragraph, maximum 400 characters.', max_length=400, verbose_name='Brief Description'),
),
]
8 changes: 5 additions & 3 deletions symposion/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ class ProposalBase(models.Model):
description = models.TextField(
_("Brief Description"),
max_length=400, # @@@ need to enforce 400 in UI
blank=True,
help_text=_("If your proposal is accepted this will be made public and printed in the "
"program. Should be one paragraph, maximum 400 characters.")
"program. Should be one paragraph, maximum 400 characters."),
)
abstract = models.TextField(
_("Detailed Abstract"),
blank=True,
help_text=_("Detailed outline. Will be made public if your proposal is accepted. Edit "
"using <a href='http://daringfireball.net/projects/markdown/basics' "
"target='_blank'>Markdown</a>.")
"target='_blank'>Markdown</a>."),
)
abstract_html = models.TextField(blank=True)
additional_notes = models.TextField(
Expand All @@ -105,7 +107,7 @@ class ProposalBase(models.Model):
help_text=_("Anything else you'd like the program committee to know when making their "
"selection: your past experience, etc. This is not made public. Edit using "
"<a href='http://daringfireball.net/projects/markdown/basics' "
"target='_blank'>Markdown</a>.")
"target='_blank'>Markdown</a>."),
)
additional_notes_html = models.TextField(blank=True)
submitted = models.DateTimeField(
Expand Down