Repository: fossasia/open-event-server

Issue:
Add fields for reCAPTCHA Keys
Sub-Issue Of #6036 


Discussion:

Resolving patch:
diff --git a/app/api/schema/settings.py b/app/api/schema/settings.py
--- a/app/api/schema/settings.py
+++ b/app/api/schema/settings.py
@@ -129,6 +129,15 @@ class Meta:
     gs_secret = fields.Str(allow_none=True)
     gs_bucket_name = fields.Str(allow_none=True)
 
+    #
+    # CAPTCHA
+    #
+
+    # Google reCAPTCHA
+    is_google_recaptcha_enabled = fields.Bool(allow_none=False, default=False)
+    google_recaptcha_site = fields.Str(allow_none=True)
+    google_recaptcha_secret = fields.Str(allow_none=True)
+
     #
     # Social Login
     #
diff --git a/app/models/setting.py b/app/models/setting.py
--- a/app/models/setting.py
+++ b/app/models/setting.py
@@ -47,6 +47,15 @@ class Setting(db.Model):
     gs_secret = db.Column(db.String)
     gs_bucket_name = db.Column(db.String)
 
+    #
+    # CAPTCHA
+    #
+
+    # Google reCAPTCHA
+    is_google_recaptcha_enabled = db.Column(db.Boolean, default=False, nullable=False)
+    google_recaptcha_site = db.Column(db.String)
+    google_recaptcha_secret = db.Column(db.String)
+
     #
     # Social Login
     #
@@ -148,6 +157,7 @@ def __init__(self,
                  gs_key=None,
                  gs_secret=None,
                  gs_bucket_name=None,
+                 is_google_recaptcha_enabled=False, google_recaptcha_secret=None, google_recaptcha_site=None,
                  google_client_id=None, google_client_secret=None,
                  fb_client_id=None, fb_client_secret=None, tw_consumer_key=None,
                  stripe_client_id=None,
@@ -198,6 +208,10 @@ def __init__(self,
         self.gs_secret = gs_secret
         self.gs_bucket_name = gs_bucket_name
 
+        self.is_google_recaptcha_enabled = is_google_recaptcha_enabled
+        self.google_recaptcha_site = google_recaptcha_site
+        self.google_recaptcha_secret = google_recaptcha_secret
+
         self.google_client_id = google_client_id
         self.google_client_secret = google_client_secret
         self.fb_client_id = fb_client_id
diff --git a/migrations/versions/232b13d4e86a_.py b/migrations/versions/232b13d4e86a_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/232b13d4e86a_.py
@@ -0,0 +1,32 @@
+"""empty message
+
+Revision ID: 232b13d4e86a
+Revises: 14e31b3a860b
+Create Date: 2019-06-17 02:51:42.186307
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+# revision identifiers, used by Alembic.
+revision = '232b13d4e86a'
+down_revision = '14e31b3a860b'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('settings', sa.Column('google_recaptcha_secret', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('google_recaptcha_site', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('is_google_recaptcha_enabled', sa.Boolean(), server_default='False', nullable=False))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('settings', 'is_google_recaptcha_enabled')
+    op.drop_column('settings', 'google_recaptcha_site')
+    op.drop_column('settings', 'google_recaptcha_secret')
+    # ### end Alembic commands ###


Test patch: