Skip to content

Commit

Permalink
Setting URL field lengths to 2000 (#298)
Browse files Browse the repository at this point in the history
* updated field length in models

* added migration

* added website of project

* removed comment

* fixed indentation

* added length validator to proposal form

* added length validators to project model form
  • Loading branch information
Bibhas committed Nov 22, 2018
1 parent fb4203b commit 898e507
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
8 changes: 4 additions & 4 deletions funnel/forms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ProjectForm(forms.Form):
tagline = forms.StringField(__("Tagline"), validators=[forms.validators.DataRequired()],
description=__("This is displayed on the card on the homepage"))
website = forms.URLField(__("Website"),
validators=[forms.validators.Optional()])
validators=[forms.validators.Optional(), forms.validators.Length(max=2000)])
description = forms.MarkdownField(__("Description"), validators=[forms.validators.DataRequired()],
description=__("About Event"))
instructions = forms.MarkdownField(__("Instructions"),
Expand All @@ -39,14 +39,14 @@ class ProjectForm(forms.Form):
description=__("The timezone in which this event occurs"),
validators=[forms.validators.DataRequired()], choices=sorted_timezones(), default=u'UTC')
bg_image = forms.URLField(__("Background image URL"), description=u"Background image for the mobile app",
validators=[forms.validators.Optional()])
validators=[forms.validators.Optional(), forms.validators.Length(max=2000)])
bg_color = forms.StringField(__("Background color"),
description=__("RGB color for the event, shown on the mobile app. Enter without the '#'. E.g. CCCCCC."),
validators=[forms.validators.Optional(), forms.validators.Length(max=6)],
default=u"CCCCCC")
explore_url = forms.URLField(__("Explore tab URL"),
description=__(u"Page containing the explore tab’s contents, for the mobile app"),
validators=[forms.validators.Optional()])
validators=[forms.validators.Optional(), forms.validators.Length(max=2000)])
parent = QuerySelectField(__(u"Parent project"), get_label='title', allow_blank=True, blank_text=__(u"None"))

admin_team = QuerySelectField(u"Admin team", validators=[forms.validators.DataRequired(__(u"Please select a team"))],
Expand All @@ -61,7 +61,7 @@ class ProjectForm(forms.Form):
allow_rsvp = forms.BooleanField(__("Allow site visitors to RSVP (login required)"))
buy_tickets_url = forms.URLField(__("URL to buy tickets"),
description=__(u"Eg: Explara, Instamojo"),
validators=[forms.validators.Optional()])
validators=[forms.validators.Optional(), forms.validators.Length(max=2000)])

def validate_date_upto(self, date_upto):
if self.date_upto.data < self.date.data:
Expand Down
6 changes: 4 additions & 2 deletions funnel/forms/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ class ProposalForm(forms.Form):
description=__("A detailed description of the session"))
requirements = forms.MarkdownField(__("Requirements"),
description=__("For workshops, what must participants bring to the session?"))
slides = forms.URLField(__("Slides"), validators=[forms.validators.Optional(), forms.validators.URL()],
slides = forms.URLField(__("Slides"),
validators=[forms.validators.Optional(), forms.validators.URL(), forms.validators.Length(max=2000)],
description=__("Link to your slides. These can be just an outline initially. "
"If you provide a Slideshare/Speakerdeck link, we'll embed slides in the page"))
preview_video = forms.URLField(__("Preview Video"), validators=[forms.validators.Optional(), forms.validators.URL()],
preview_video = forms.URLField(__("Preview Video"),
validators=[forms.validators.Optional(), forms.validators.URL(), forms.validators.Length(max=2000)],
description=__("Link to your preview video. Use a video to engage the community and give them a better idea about what you are planning to cover in your session and why they should attend. "
"If you provide a YouTube/Vimeo link, we'll embed it in the page"))
links = forms.TextAreaField(__("Links"),
Expand Down
8 changes: 4 additions & 4 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ class Project(BaseScopedNameMixin, db.Model):
datelocation = db.Column(db.Unicode(50), default=u'', nullable=False)
date = db.Column(db.Date, nullable=True)
date_upto = db.Column(db.Date, nullable=True)
website = db.Column(db.Unicode(250), nullable=True)
website = db.Column(db.Unicode(2000), nullable=True)
timezone = db.Column(db.Unicode(40), nullable=False, default=u'UTC')

_state = db.Column('state', db.Integer, StateManager.check_constraint('state', PROJECT_STATE),
default=PROJECT_STATE.DRAFT, nullable=False)
state = StateManager('_state', PROJECT_STATE, doc="State of this project.")

# Columns for mobile
bg_image = db.Column(db.Unicode(250), nullable=True)
bg_image = db.Column(db.Unicode(2000), nullable=True)
bg_color = db.Column(db.Unicode(6), nullable=True)
explore_url = db.Column(db.Unicode(250), nullable=True)
explore_url = db.Column(db.Unicode(2000), nullable=True)
allow_rsvp = db.Column(db.Boolean, default=False, nullable=False)
buy_tickets_url = db.Column(db.Unicode(250), nullable=True)
buy_tickets_url = db.Column(db.Unicode(2000), nullable=True)

banner_video_url = db.Column(db.Unicode(2000), nullable=True)
boxoffice_data = db.Column(JsonDict, nullable=False, server_default='{}')
Expand Down
4 changes: 2 additions & 2 deletions funnel/models/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class Proposal(UuidMixin, BaseScopedIdNameMixin, CoordinatesMixin, db.Model):
description = MarkdownColumn('description', nullable=True)
part_b = db.synonym('description')
requirements = MarkdownColumn('requirements', nullable=True)
slides = db.Column(db.Unicode(250), nullable=True)
preview_video = db.Column(db.Unicode(250), default=u'', nullable=True)
slides = db.Column(db.Unicode(2000), nullable=True)
preview_video = db.Column(db.Unicode(2000), default=u'', nullable=True)
links = db.Column(db.Text, default=u'', nullable=True)

_state = db.Column('state', db.Integer, StateManager.check_constraint('state', PROPOSAL_STATE),
Expand Down
45 changes: 45 additions & 0 deletions migrations/versions/60a132ae73f1_url_field_leng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""url field leng
Revision ID: 60a132ae73f1
Revises: d6b1904bea0e
Create Date: 2018-11-20 18:01:51.811819
"""

# revision identifiers, used by Alembic.
revision = '60a132ae73f1'
down_revision = 'd6b1904bea0e'

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


def upgrade():
op.alter_column('project', 'bg_image', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)
op.alter_column('project', 'website', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)
op.alter_column('project', 'buy_tickets_url', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)
op.alter_column('project', 'explore_url', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)
op.alter_column('proposal', 'preview_video', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)
op.alter_column('proposal', 'slides', existing_type=sa.Unicode(length=250),
type_=sa.Unicode(length=2000), existing_nullable=True)


def downgrade():
op.alter_column('proposal', 'slides', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)
op.alter_column('proposal', 'preview_video', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)
op.alter_column('project', 'explore_url', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)
op.alter_column('project', 'buy_tickets_url', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)
op.alter_column('project', 'website', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)
op.alter_column('project', 'bg_image', existing_type=sa.Unicode(length=2000),
type_=sa.Unicode(length=250), existing_nullable=True)

0 comments on commit 898e507

Please sign in to comment.