Repository: fossasia/open-event-server

Issue:
Add paytm variables to event model
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Parent issue - https://github.com/fossasia/open-event-server/issues/6247
As we are moving forward with paytm now, we should have variables to ask organizer about their info if they want to link paytm to their event as a payment gateway

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
I'll add new fields required for paytm to event model

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
On it



Discussion:
Hey @shreyanshdwivedi , I would like to work on this issue.
@Abhi-khandelwal actually we are having discussions about this feature since a week ago and I've already made changes locally.
 I think you should start with some beginner friendly issues.

Resolving patch:
diff --git a/app/api/schema/events.py b/app/api/schema/events.py
--- a/app/api/schema/events.py
+++ b/app/api/schema/events.py
@@ -91,6 +91,7 @@ def validate_timezone(self, data, original_data):
     can_pay_onsite = fields.Bool(default=False)
     can_pay_by_omise = fields.Bool(default=False)
     can_pay_by_alipay = fields.Bool(default=False)
+    can_pay_by_paytm = fields.Bool(default=False)
     cheque_details = fields.Str(allow_none=True)
     bank_details = fields.Str(allow_none=True)
     onsite_details = fields.Str(allow_none=True)
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -99,13 +99,14 @@ class Event(SoftDeletionModel):
     paypal_email = db.Column(db.String)
     is_tax_enabled = db.Column(db.Boolean, default=False)
     is_billing_info_mandatory = db.Column(db.Boolean, default=False)
-    can_pay_by_paypal = db.Column(db.Boolean, default=False)
-    can_pay_by_stripe = db.Column(db.Boolean, default=False)
-    can_pay_by_cheque = db.Column(db.Boolean, default=False)
-    can_pay_by_bank = db.Column(db.Boolean, default=False)
-    can_pay_onsite = db.Column(db.Boolean, default=False)
-    can_pay_by_omise = db.Column(db.Boolean, default=False)
-    can_pay_by_alipay = db.Column(db.Boolean, default=False)
+    can_pay_by_paypal = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_stripe = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_cheque = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_bank = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_onsite = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_omise = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_alipay = db.Column(db.Boolean, default=False, nullable=False)
+    can_pay_by_paytm = db.Column(db.Boolean, default=False, nullable=False)
     cheque_details = db.Column(db.String)
     bank_details = db.Column(db.String)
     onsite_details = db.Column(db.String)
@@ -219,15 +220,16 @@ def __init__(self,
                  payment_currency=None,
                  paypal_email=None,
                  speakers_call=None,
-                 can_pay_by_paypal=None,
-                 can_pay_by_stripe=None,
-                 can_pay_by_cheque=None,
-                 can_pay_by_omise=None,
-                 can_pay_by_alipay=None,
+                 can_pay_by_paypal=False,
+                 can_pay_by_stripe=False,
+                 can_pay_by_cheque=False,
+                 can_pay_by_omise=False,
+                 can_pay_by_alipay=False,
+                 can_pay_by_paytm=False,
                  identifier=None,
-                 can_pay_by_bank=None,
+                 can_pay_by_bank=False,
                  is_featured=False,
-                 can_pay_onsite=None,
+                 can_pay_onsite=False,
                  cheque_details=None,
                  bank_details=None,
                  pentabarf_url=None,
@@ -290,6 +292,7 @@ def __init__(self,
         self.can_pay_onsite = can_pay_onsite
         self.can_pay_by_omise = can_pay_by_omise
         self.can_pay_by_alipay = can_pay_by_alipay
+        self.can_pay_by_paytm = can_pay_by_paytm
         self.is_donation_enabled = is_donation_enabled
         self.is_featured = is_featured
         self.is_ticket_form_enabled = is_ticket_form_enabled
@@ -361,7 +364,7 @@ def get_average_rating(self):
 
     def is_payment_enabled(self):
         return self.can_pay_by_paypal or self.can_pay_by_stripe or self.can_pay_by_omise or self.can_pay_by_alipay \
-            or self.can_pay_by_cheque or self.can_pay_by_bank or self.can_pay_onsite
+            or self.can_pay_by_cheque or self.can_pay_by_bank or self.can_pay_onsite or self.can_pay_by_paytm
 
     @property
     def average_rating(self):
diff --git a/migrations/versions/rev-2019-08-13-13:24:45-d252c86d0200_.py b/migrations/versions/rev-2019-08-13-13:24:45-d252c86d0200_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/rev-2019-08-13-13:24:45-d252c86d0200_.py
@@ -0,0 +1,58 @@
+"""empty message
+
+Revision ID: d252c86d0200
+Revises: 1bdf23be63bd
+Create Date: 2019-08-13 13:24:45.899422
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+# revision identifiers, used by Alembic.
+revision = 'd252c86d0200'
+down_revision = '1bdf23be63bd'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('events', sa.Column('can_pay_by_paytm', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_alipay', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_bank', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_cheque', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_omise', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_paypal', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_by_stripe', sa.Boolean(), server_default='False', nullable=False))
+    op.alter_column('events', sa.Column('can_pay_onsite', sa.Boolean(), server_default='False', nullable=False))
+    op.add_column('events_version', sa.Column('can_pay_by_paytm', sa.Boolean(), server_default='False', nullable=False))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('events_version', 'can_pay_by_paytm')
+    op.alter_column('events', 'can_pay_onsite',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_stripe',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_paypal',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_omise',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_cheque',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_bank',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.alter_column('events', 'can_pay_by_alipay',
+               existing_type=sa.BOOLEAN(),
+               nullable=True)
+    op.drop_column('events', 'can_pay_by_paytm')
+    # ### end Alembic commands ###


Test patch: