Repository: fossasia/open-event-server

Issue:
Remove timezone field from call for speakers model and API
Call for speakers will use the timezone of the event. 


Discussion:
@niranjan94 Should this be done after #3739 , considering old data that is already using the timezone field. 
Or is it not that necessary, as at the time of nextgen switch, it does not matter if the cfs times for closed events has changed?
@shubham-padia yep. Do be done after #3739. 

As for the old data, I checked and found out everyone just uses the event timezone (since that is autoselected in the wizard anyway). So, wouldn't be an issue.

Resolving patch:
diff --git a/app/api/call_for_papers.py b/app/api/call_for_papers.py
--- a/app/api/call_for_papers.py
+++ b/app/api/call_for_papers.py
@@ -27,9 +27,8 @@ class Meta:
 
     id = fields.Str(dump_only=True)
     announcement = fields.Str(required=True)
-    start_date = fields.DateTime(required=True)
-    end_date = fields.DateTime(required=True)
-    timezone = fields.Str(default="UTC")
+    starts_at = fields.DateTime(required=True)
+    ends_at = fields.DateTime(required=True)
     hash = fields.Str()
     privacy = fields.String()
     event = Relationship(attribute='event',
diff --git a/app/models/call_for_paper.py b/app/models/call_for_paper.py
--- a/app/models/call_for_paper.py
+++ b/app/models/call_for_paper.py
@@ -8,9 +8,8 @@ class CallForPaper(db.Model):
     __tablename__ = 'call_for_papers'
     id = db.Column(db.Integer, primary_key=True)
     announcement = db.Column(db.Text, nullable=False)
-    start_date = db.Column(db.DateTime(timezone=True), nullable=False)
-    end_date = db.Column(db.DateTime(timezone=True), nullable=False)
-    timezone = db.Column(db.String, nullable=False, default="UTC")
+    starts_at = db.Column(db.DateTime(timezone=True), nullable=False)
+    ends_at = db.Column(db.DateTime(timezone=True), nullable=False)
     hash = db.Column(db.String, nullable=True)
     privacy = db.Column(db.String, nullable=False)
     event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
diff --git a/migrations/versions/5432cb603630_.py b/migrations/versions/5432cb603630_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/5432cb603630_.py
@@ -0,0 +1,31 @@
+"""empty message
+
+Revision ID: 5432cb603630
+Revises: f5fec4ca8b2b
+Create Date: 2017-06-10 16:17:31.460649
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '5432cb603630'
+down_revision = 'f5fec4ca8b2b'
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+from sqlalchemy.dialects import postgresql
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column('call_for_papers', 'start_date', new_column_name='starts_at')
+    op.alter_column('call_for_papers', 'end_date', new_column_name='ends_at')
+    op.drop_column('call_for_papers', 'timezone')
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column('call_for_papers', 'starts_at', new_column_name='start_date')
+    op.alter_column('call_for_papers', 'ends_at', new_column_name='end_date')
+    op.add_column('call_for_papers', sa.Column('timezone', sa.VARCHAR(), server_default='UTC', autoincrement=False, nullable=False))
+    # ### end Alembic commands ###


Test patch: