Skip to content

Commit

Permalink
Remove proposal part labels (resolves #403)
Browse files Browse the repository at this point in the history
Also removes the obsolete session_type and technical_level columns that have been converted to labels as of #392.
  • Loading branch information
jace committed Jun 6, 2019
1 parent 3721806 commit b89e777
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 93 deletions.
20 changes: 4 additions & 16 deletions funnel/forms/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ class ProposalForm(forms.Form):
(0, __(u"I’m proposing a topic for someone to speak on"))])
title = forms.StringField(__("Title"), validators=[forms.validators.DataRequired()],
description=__("The title of your session"))
objective = forms.MarkdownField(__("Objective"), validators=[forms.validators.DataRequired()],
description=__("What is the expected benefit for someone attending this?"))
description = forms.MarkdownField(__("Description"), validators=[forms.validators.DataRequired()],
description=__("A detailed description of the session"))
abstract = forms.MarkdownField(__("Abstract"), validators=[forms.validators.DataRequired()],
description=__("A brief description of your session with target audience and key takeaways"))
outline = forms.MarkdownField(__("Outline"), validators=[forms.validators.DataRequired()],
description=__("A detailed description of the session with the sequence of ideas to be presented"))
requirements = forms.MarkdownField(__("Requirements"),
description=__("For workshops, what must participants bring to the session?"))
slides = forms.URLField(__("Slides"),
Expand Down Expand Up @@ -110,18 +110,6 @@ class ProposalForm(forms.Form):

formlabels = forms.FormField(forms.Form, __("Labels"))

def __init__(self, *args, **kwargs):
super(ProposalForm, self).__init__(*args, **kwargs)
project = kwargs.get('parent')
if project.proposal_part_a.get('title'):
self.objective.label.text = project.proposal_part_a.get('title')
if project.proposal_part_a.get('hint'):
self.objective.description = project.proposal_part_a.get('hint')
if project.proposal_part_b.get('title'):
self.description.label.text = project.proposal_part_b.get('title')
if project.proposal_part_b.get('hint'):
self.description.description = project.proposal_part_b.get('hint')

def set_queries(self):
self.formlabels.form = proposal_label_form(project=self.edit_parent, proposal=self.edit_obj)

Expand Down
35 changes: 0 additions & 35 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class Project(UuidMixin, BaseScopedNameMixin, db.Model):
parent_id = db.Column(None, db.ForeignKey('project.id', ondelete='SET NULL'), nullable=True)
parent_project = db.relationship('Project', remote_side='Project.id', backref='subprojects')
inherit_sections = db.Column(db.Boolean, default=True, nullable=False)
part_labels = db.Column('labels', JsonDict, nullable=False, server_default='{}')

#: Featured project flag. This can only be set by website editors, not
#: project editors or profile admins.
Expand Down Expand Up @@ -357,40 +356,6 @@ def proposals_by_confirmation(self):
def location_geonameid(self):
return geonameid_from_location(self.location) if self.location else set()

@property
def proposal_part_a(self):
return self.part_labels.get('proposal', {}).get('part_a', {})

@property
def proposal_part_b(self):
return self.part_labels.get('proposal', {}).get('part_b', {})

def set_labels(self, value=None):
"""
Sets 'labels' with the provided JSON, else with a default configuration
for fields with customizable labels.
Currently, the 'part_a' and 'part_b' fields in 'Proposal'
are allowed to be customized per project.
"""
if value and isinstance(value, dict):
self.part_labels = value
else:
self.part_labels = {
"proposal": {
"part_a": {
"title": "Abstract",
"hint": "Give us a brief description of your talk, key takeaways for the audience and the"
" intended audience."
},
"part_b": {
"title": "Outline",
"hint": "Give us a break-up of your talk either in the form of draft slides, mind-map or"
" text description."
}
}
}

def permissions(self, user, inherited=None):
perms = super(Project, self).permissions(user, inherited)
perms.add('view')
Expand Down
12 changes: 4 additions & 8 deletions funnel/models/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ class Proposal(UuidMixin, BaseScopedIdNameMixin, CoordinatesMixin, db.Model):
section_id = db.Column(None, db.ForeignKey('section.id'), nullable=True)
section = db.relationship(Section, primaryjoin=section_id == Section.id,
backref="proposals")
objective = MarkdownColumn('objective', nullable=True)
part_a = db.synonym('objective')
session_type = db.Column(db.Unicode(40), nullable=True)
technical_level = db.Column(db.Unicode(40), nullable=True)
description = MarkdownColumn('description', nullable=True)
part_b = db.synonym('description')
abstract = MarkdownColumn('abstract', nullable=True)
outline = MarkdownColumn('outline', nullable=True)
requirements = MarkdownColumn('requirements', nullable=True)
slides = db.Column(UrlType, nullable=True)
preview_video = db.Column(UrlType, default=u'', nullable=True)
Expand Down Expand Up @@ -107,8 +103,8 @@ class Proposal(UuidMixin, BaseScopedIdNameMixin, CoordinatesMixin, db.Model):
__roles__ = {
'all': {
'read': {
'title', 'speaker', 'speaking', 'bio', 'section', 'objective', 'session_type',
'technical_level', 'description', 'requirements', 'slides', 'preview_video', 'links', 'location',
'title', 'speaker', 'speaking', 'bio', 'section', 'abstract',
'outline', 'requirements', 'slides', 'preview_video', 'links', 'location',
'latitude', 'longitude', 'coordinates'
},
'call': {
Expand Down
10 changes: 5 additions & 5 deletions funnel/templates/proposal.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@

<div class="proposal__section proposal__section--left">
<div class="proposal-content">
<h3 class="mui--text-headline mui--text-bold">{% trans %}{{part_a}}{% endtrans %} {% if proposal.user == g.user %}<a href="{{ proposal.url_for('edit') }}#field-objective" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a>{% endif %}</h3>
<div class="mui--text-subhead">{{ proposal.objective }}</div>
<h3 class="mui--text-headline mui--text-bold">{% trans %}Abstract{% endtrans %} {% if proposal.user == g.user %}<a href="{{ proposal.url_for('edit') }}#field-abstract" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a>{% endif %}</h3>
<div class="mui--text-subhead">{{ proposal.abstract }}</div>

<h3 class="mui--text-headline mui--text-bold">{% trans %}{{part_b}}{% endtrans %} {% if proposal.user == g.user %}<a href="{{ proposal.url_for('edit') }}#field-description" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a>{% endif %}</h3>
<div class="mui--text-subhead">{{ proposal.description }}</div>
<h3 class="mui--text-headline mui--text-bold">{% trans %}Outline{% endtrans %} {% if proposal.user == g.user %}<a href="{{ proposal.url_for('edit') }}#field-outline" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a>{% endif %}</h3>
<div class="mui--text-subhead">{{ proposal.outline }}</div>

{% if proposal.requirements.text -%}
<h3 class="mui--text-headline mui--text-bold">{% trans %}Requirements{% endtrans %} {% if proposal.user == g.user %}<a href="{{ proposal.url_for('edit') }}#field-requirements" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a>{% endif %} </h3>
Expand Down Expand Up @@ -278,7 +278,7 @@
<h3 class="mui--text-headline mui--text-bold">{% trans %}Slides{% endtrans %} <a href="{{ proposal.url_for('edit') }}#field-slides" title="{% trans %}Edit{% endtrans %}"><i class="material-icons mui--text-title mui--align-middle mui--text-link">edit</i></a></h3>
<p><i>This section is empty.</i></p>
{% endif %}

{% if proposal.preview_video.url %}
<h3 class="mui--text-headline mui--text-bold">{% trans %}Preview video{% endtrans %}</h3>
<a href="{{ proposal.preview_video }}">{{ proposal.preview_video }}</a>
Expand Down
3 changes: 0 additions & 3 deletions funnel/templates/proposals.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
<ul class="mui-list--inline mui--text-body2 list-item-rgborder zero-bottom-margin">
{%- if proposal.project != project %}
<li>{{ proposal.project.short_title() }}</li>
{% elif proposal.section.title %}
<li>{{ proposal.section.title }}</li>
{% endif %}
<li>{{ proposal.technical_level }}</li>
<li>{{ proposal.voteset.count }} upvotes</li>
<li>{{ proposal.commentset.count }} comments</li>
<li class="no-border">{{ proposal.datetime.strftime("%a, %e %b") }}</li>
Expand Down
16 changes: 0 additions & 16 deletions funnel/templates/session_view_popup.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@
</div>
</div>
<div class="modal__body">
{% if session.proposal %}
<div class="proposal-status-wrapper">
<div class="grid">
{% if session.proposal.section %}
<div class="col-auto columns">
<p class="mui--text-body2 mui--text-light zero-bottom-margin">Section</p>
<p class="mui--text-title">{{ session.proposal.section.title }}</p>
</div>
{% endif %}
<div class="col-auto columns">
<p class="mui--text-body2 mui--text-light zero-bottom-margin">Technical Level</p>
<p class="mui--text-title">{{ session.proposal.technical_level }}</p>
</div>
</div>
</div>
{% endif %}
<div class="section">
{% if session.description_html %}
<h3 class="mui--text-title"><strong>{% trans %}Description{% endtrans %}</strong></h3>
Expand Down
17 changes: 10 additions & 7 deletions funnel/views/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ def proposal_data(proposal):
('proposer', proposal.user.pickername),
('speaker', proposal.speaker.pickername if proposal.speaker else None),
('section', proposal.section.title if proposal.section else None),
('type', proposal.session_type),
('level', proposal.technical_level),
('objective', proposal.objective.html),
('description', proposal.description.html),
('requirements', proposal.requirements.html),
('objective', proposal.abstract.html), # TODO: Remove this, name has changed
('description', proposal.outline.html), # TODO: Remove this, name has changed
('requirements', proposal.requirements.html), # TODO: Remove this, name has changed
('abstract_text', proposal.abstract.text),
('abstract_html', proposal.abstract.html),
('outline_text', proposal.outline.text),
('outline_html', proposal.outline.html),
('requirements_text', proposal.requirements.text),
('requirements_html', proposal.requirements.html),
('slides', proposal.slides.url),
('links', proposal.links),
('preview_video', proposal.preview_video.url),
Expand Down Expand Up @@ -158,8 +162,7 @@ def view(self):
return dict(project=self.obj.project, proposal=self.obj,
comments=comments, commentform=commentform, delcommentform=delcommentform,
links=links, transition_form=transition_form, proposal_move_form=proposal_move_form,
part_a=self.obj.project.proposal_part_a.get('title', 'Objective'),
part_b=self.obj.project.proposal_part_b.get('title', 'Description'), csrf_form=Form(),
csrf_form=Form(),
proposal_label_admin_form=proposal_label_admin_form)

@route('json')
Expand Down
3 changes: 0 additions & 3 deletions funnel/views/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ def schedule_data(project):
'description': session.description,
'speaker_bio': session.speaker_bio,
'speaker_bio_text': session.speaker_bio_text,
'section_name': session.proposal.section.name if session.proposal and session.proposal.section else None,
'section_title': session.proposal.section.title if session.proposal and session.proposal.section else None,
'technical_level': session.proposal.technical_level if session.proposal and session.proposal.section else None,
})
schedule = []
for day in sorted(data):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Remove and rename obsolete columns
Revision ID: 1b8fc63c0fb0
Revises: ea20c403b240
Create Date: 2019-06-06 12:43:24.087572
"""

# revision identifiers, used by Alembic.
revision = '1b8fc63c0fb0'
down_revision = 'ea20c403b240'

import json
from alembic import op
import sqlalchemy as sa # NOQA
from sqlalchemy.dialects import postgresql


default_part_labels = {
"proposal": {
"part_a": {
"title": "Abstract",
"hint": "Give us a brief description of your talk, key takeaways for the audience and the"
" intended audience."
},
"part_b": {
"title": "Outline",
"hint": "Give us a break-up of your talk either in the form of draft slides, mind-map or"
" text description."
}
}
}


def upgrade():
op.alter_column('proposal', 'objective_text', new_column_name='abstract_text')
op.alter_column('proposal', 'objective_html', new_column_name='abstract_html')
op.alter_column('proposal', 'description_text', new_column_name='outline_text')
op.alter_column('proposal', 'description_html', new_column_name='outline_html')
op.drop_column('project', 'labels')
op.drop_column('proposal', 'technical_level')
op.drop_column('proposal', 'session_type')


def downgrade():
op.add_column('proposal', sa.Column('session_type', sa.VARCHAR(length=40), autoincrement=False, nullable=True))
op.add_column('proposal', sa.Column('technical_level', sa.VARCHAR(length=40), autoincrement=False, nullable=True))
op.add_column('project', sa.Column('labels',
postgresql.JSONB(astext_type=sa.Text()),
server_default=sa.text("'" + json.dumps(default_part_labels) + "'::jsonb"),
autoincrement=False, nullable=False))
op.alter_column('project', 'labels', server_default=sa.text("'{}'::jsonb"))
op.alter_column('proposal', 'abstract_text', new_column_name='objective_text')
op.alter_column('proposal', 'abstract_html', new_column_name='objective_html')
op.alter_column('proposal', 'outline_text', new_column_name='description_text')
op.alter_column('proposal', 'outline_html', new_column_name='description_html')

0 comments on commit b89e777

Please sign in to comment.