Repository: fossasia/open-event-server

Issue:
Allow restricting check-in and auto-check-in for certain ticket types
**Is your feature request related to a problem? Please describe.**
The API should be able to restrict check in for all attendees holding certain ticket types

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
There should be an attribute of for Ticket API called as 'is-check-in-restricted`, and 'auto-check-in-enabled'.

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
Orga app issues: [#973](https://github.com/fossasia/open-event-orga-app/issues/973) [#974](https://github.com/fossasia/open-event-orga-app/issues/974)


Discussion:
Are you working on this or can I work on this one?

On Tue, Jun 5, 2018 at 11:11 AM, mishuvs <notifications@github.com> wrote:

> *Is your feature request related to a problem? Please describe.*
> The API should be able to restrict check in for all attendees holding
> certain ticket types
>
> *Describe the solution you'd like*
>
> There should be an attribute of for Ticket API called as
> 'is-check-in-restricted`, and 'auto-check-in-enabled'.
>
> *Additional context*
>
> Orga app issues: #973
> <https://github.com/fossasia/open-event-orga-app/issues/973>
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/fossasia/open-event-server/issues/4856>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/AVwOaByrdzedNsrrnekCbEY1KkT7OHc3ks5t5hoVgaJpZM4UaL4C>
> .
>

Please go ahead.
Besides adding the attributes mentioned above, should additional code for validating the check-in of attendees be implemented as well? Thoughts @iamareebjamal @srv-twry @bhaveshAn @mayank8318 ?
Yes @schedutron 

Resolving patch:
diff --git a/app/api/schema/tickets.py b/app/api/schema/tickets.py
--- a/app/api/schema/tickets.py
+++ b/app/api/schema/tickets.py
@@ -58,6 +58,8 @@ def validate_quantity(self, data):
     is_hidden = fields.Boolean(default=False)
     min_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
     max_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
+    is_checkin_restricted = fields.Boolean(default=True)
+    auto_checkin_enabled = fields.Boolean(default=False)
     event = Relationship(attribute='event',
                          self_view='v1.ticket_event',
                          self_view_kwargs={'id': '<id>'},
diff --git a/app/models/ticket.py b/app/models/ticket.py
--- a/app/models/ticket.py
+++ b/app/models/ticket.py
@@ -33,7 +33,8 @@ class Ticket(SoftDeletionModel):
 
     min_order = db.Column(db.Integer)
     max_order = db.Column(db.Integer)
-
+    is_checkin_restricted = db.Column(db.Boolean)
+    auto_checkin_enabled = db.Column(db.Boolean)
     event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
     event = db.relationship('Event', backref='tickets_')
 
@@ -51,6 +52,8 @@ def __init__(self,
                  is_hidden=False,
                  description=None,
                  is_description_visible=True,
+                 is_checkin_restricted=True,
+                 auto_checkin_enabled=False,
                  quantity=100,
                  position=1,
                  price=0,
@@ -71,6 +74,8 @@ def __init__(self,
         self.event_id = event_id
         self.description = description
         self.is_description_visible = is_description_visible
+        self.is_checkin_restricted = is_checkin_restricted
+        self.auto_checkin_enabled = auto_checkin_enabled
         self.price = price
         self.sales_starts_at = sales_starts_at
         self.sales_ends_at = sales_ends_at
diff --git a/migrations/versions/6440077182f0_.py b/migrations/versions/6440077182f0_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/6440077182f0_.py
@@ -0,0 +1,28 @@
+"""empty message
+
+Revision ID: 6440077182f0
+Revises: eaa029ebb260
+Create Date: 2018-06-12 16:12:06.233030
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+# revision identifiers, used by Alembic.
+revision = '6440077182f0'
+down_revision = 'eaa029ebb260'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('tickets', sa.Column('auto_checkin_enabled', sa.Boolean(), nullable=True))
+    op.add_column('tickets', sa.Column('is_checkin_restricted', sa.Boolean(), nullable=True))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('tickets', 'is_checkin_restricted')
+    op.drop_column('tickets', 'auto_checkin_enabled')
+    # ### end Alembic commands ###


Test patch: