Repository: fossasia/open-event-server

Issue:
Ability to add donation support
**Describe the feature**
Our system requires the option of adding NGO events. When an event is categorised as an NGO event, it should have the feature of selling **only free** tickets. It should also have the option where people can donate funds to the fundraising event. 

This is a **parent** issue. It can be divided into sub-parts:
1. Integration of a working donation system
2. Adding NGO events/Open Source events
3. Adding the feature of recurring donations(_Monthly, Yearly etc..._)

**Additional context**
Working on it. 


Discussion:
@mrsaicharan1 Can I work on the server side implementation of this?
> @mrsaicharan1 Can I work on the server side implementation of this?

@prateekj117 I was planning to work on this myself, as discussed in the latest meeting. Will notify if I need help :)
@mrsaicharan1 As @mariobehling said that the term `is_ngo` is misleading, should we change the field name in the models as well?
@prateekj117 yes, Please remove this 
@iamareebjamal What should we rename it to?
Ask your peers
@mrsaicharan1 @uds5501 @shreyanshdwivedi What should I rename it to?
@prateekj117 It's better to remove the fields as they are not required. We already have donation fields for events. At first, we needed NGo so that we could represent them separately as Open Source/ngo events. But, we just need donation support. So yeah, it'd be better to remove these fields now.

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
@@ -1,5 +1,6 @@
-import pytz
 from datetime import datetime
+
+import pytz
 from flask_rest_jsonapi.exceptions import ObjectNotFound
 from marshmallow import validates_schema, validate
 from marshmallow_jsonapi import fields
@@ -107,7 +108,6 @@ def validate_timezone(self, data, original_data):
     revenue = fields.Float(dump_only=True)
     paypal_email = fields.Str(allow_none=True)
     is_tax_enabled = fields.Bool(default=False)
-    is_ngo = fields.Bool(default=False, nullable=False)
     is_donation_enabled = fields.Bool(default=False)
     can_pay_by_paypal = fields.Bool(default=False)
     can_pay_by_stripe = fields.Bool(default=False)
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -10,20 +10,21 @@
 
 from app.api.helpers.db import get_count
 from app.models import db
-from app.models.order import Order
-from app.models.ticket_fee import get_fee
-from app.models.ticket_fee import get_maximum_fee
 from app.models.base import SoftDeletionModel
 from app.models.email_notification import EmailNotification
+from app.models.event_topic import EventTopic
 from app.models.feedback import Feedback
 from app.models.helpers.versioning import clean_up_string, clean_html
-from app.models.user import ATTENDEE, ORGANIZER
-from app.models.event_topic import EventTopic
+from app.models.order import Order
+from app.models.search import sync
 from app.models.session import Session
 from app.models.speaker import Speaker
-from app.models.search import sync
 from app.models.ticket import Ticket
+from app.models.ticket_fee import get_fee
+from app.models.ticket_fee import get_maximum_fee
 from app.models.ticket_holder import TicketHolder
+from app.models.user import ATTENDEE, ORGANIZER
+
 
 def get_new_event_identifier(length=8):
     identifier = str(binascii.b2a_hex(os.urandom(int(length / 2))), 'utf-8')
@@ -96,7 +97,6 @@ class Event(SoftDeletionModel):
     payment_country = db.Column(db.String)
     payment_currency = db.Column(db.String)
     paypal_email = db.Column(db.String)
-    is_ngo = db.Column(db.Boolean, default=False)
     is_tax_enabled = 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)
@@ -210,7 +210,6 @@ def __init__(self,
                  payment_country=None,
                  payment_currency=None,
                  paypal_email=None,
-                 is_ngo=False,
                  speakers_call=None,
                  can_pay_by_paypal=None,
                  can_pay_by_stripe=None,
@@ -275,7 +274,6 @@ def __init__(self,
         self.payment_country = payment_country
         self.payment_currency = payment_currency
         self.paypal_email = paypal_email
-        self.is_ngo = is_ngo
         self.speakers_call = speakers_call
         self.can_pay_by_paypal = can_pay_by_paypal
         self.can_pay_by_stripe = can_pay_by_stripe
diff --git a/migrations/versions/14e31b3a860b_.py b/migrations/versions/14e31b3a860b_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/14e31b3a860b_.py
@@ -0,0 +1,28 @@
+"""empty message
+
+Revision ID: 14e31b3a860b
+Revises: 09c86e38f5e7
+Create Date: 2019-06-15 23:52:13.462368
+
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = '14e31b3a860b'
+down_revision = '09c86e38f5e7'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('events', 'is_ngo')
+    op.drop_column('events_version', 'is_ngo')
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('events_version', sa.Column('is_ngo', sa.BOOLEAN(), autoincrement=False, nullable=True))
+    op.add_column('events', sa.Column('is_ngo', sa.BOOLEAN(), autoincrement=False, nullable=True))
+    # ### end Alembic commands ###


Test patch: