Repository: fossasia/open-event-server

Issue:
Fix aspect fields in image_size api and model
Aspect fields are to be Boolean instead of string 


Discussion:

Resolving patch:
diff --git a/app/api/image_sizes.py b/app/api/image_sizes.py
--- a/app/api/image_sizes.py
+++ b/app/api/image_sizes.py
@@ -25,15 +25,15 @@ class Meta:
     type = fields.Str()
     full_width = fields.Integer()
     full_height = fields.Integer()
-    full_aspect = fields.Str()
+    full_aspect = fields.Boolean(default=False)
     full_quality = fields.Integer()
     icon_width = fields.Integer()
     icon_height = fields.Integer()
-    icon_aspect = fields.Str()
+    icon_aspect = fields.Boolean(default=False)
     icon_quality = fields.Integer()
     thumbnail_width = fields.Integer()
     thumbnail_height = fields.Integer()
-    thumbnail_aspect = fields.Str()
+    thumbnail_aspect = fields.Boolean(default=False)
     thumbnail_quality = fields.Integer()
     logo_width = fields.Integer()
     logo_height = fields.Integer()
diff --git a/app/models/image_size.py b/app/models/image_size.py
--- a/app/models/image_size.py
+++ b/app/models/image_size.py
@@ -9,15 +9,15 @@ class ImageSizes(db.Model):
     type = db.Column(db.String)
     full_width = db.Column(db.Integer)
     full_height = db.Column(db.Integer)
-    full_aspect = db.Column(db.String)
+    full_aspect = db.Column(db.Boolean, default=False)
     full_quality = db.Column(db.Integer)
     icon_width = db.Column(db.Integer)
     icon_height = db.Column(db.Integer)
-    icon_aspect = db.Column(db.String)
+    icon_aspect = db.Column(db.Boolean, default=False)
     icon_quality = db.Column(db.Integer)
     thumbnail_width = db.Column(db.Integer)
     thumbnail_height = db.Column(db.Integer)
-    thumbnail_aspect = db.Column(db.String)
+    thumbnail_aspect = db.Column(db.Boolean, default=False)
     thumbnail_quality = db.Column(db.Integer)
     logo_width = db.Column(db.Integer)
     logo_height = db.Column(db.Integer)
@@ -26,15 +26,15 @@ def __init__(self,
                  type=None,
                  full_width=None,
                  full_height=None,
-                 full_aspect=None,
+                 full_aspect=False,
                  full_quality=None,
                  icon_width=None,
                  icon_height=None,
-                 icon_aspect=None,
+                 icon_aspect=False,
                  icon_quality=None,
                  thumbnail_width=None,
                  thumbnail_height=None,
-                 thumbnail_aspect=None,
+                 thumbnail_aspect=False,
                  thumbnail_quality=None,
                  logo_width=None,
                  logo_height=None):
diff --git a/migrations/versions/6904ae1e0e33_.py b/migrations/versions/6904ae1e0e33_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/6904ae1e0e33_.py
@@ -0,0 +1,42 @@
+"""empty message
+
+Revision ID: 6904ae1e0e33
+Revises: ccd80550c01f
+Create Date: 2017-06-13 08:42:28.606478
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '6904ae1e0e33'
+down_revision = 'ccd80550c01f'
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+def upgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.execute("ALTER TABLE image_sizes ALTER full_aspect TYPE boolean USING CASE full_aspect WHEN 'on' THEN TRUE\
+                ELSE FALSE END", execution_options=None)
+
+    op.execute("ALTER TABLE image_sizes ALTER icon_aspect TYPE boolean USING CASE icon_aspect WHEN 'on' THEN TRUE\
+                ELSE FALSE END", execution_options=None)
+
+    op.execute("ALTER TABLE image_sizes ALTER thumbnail_aspect TYPE boolean USING CASE thumbnail_aspect WHEN 'on' THEN TRUE\
+                ELSE FALSE END", execution_options=None)
+
+    ### end Alembic commands ###
+
+
+def downgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.execute("ALTER TABLE image_sizes ALTER full_aspect TYPE varchar USING CASE full_aspect WHEN TRUE THEN 'on'\
+                ELSE 'off' END", execution_options=None)
+
+    op.execute("ALTER TABLE image_sizes ALTER icon_aspect TYPE varchar USING CASE icon_aspect WHEN TRUE THEN 'on'\
+                ELSE 'off' END", execution_options=None)
+
+    op.execute("ALTER TABLE image_sizes ALTER thumbnail_aspect TYPE varchar USING CASE thumbnail_aspect WHEN TRUE THEN 'on'\
+                ELSE 'off' END", execution_options=None)
+    ### end Alembic commands ###


Test patch: