Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Implement event check-in handler #93

Merged
merged 5 commits into from
Feb 26, 2016
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/GDGUkraine/rest_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,21 @@ def generate_invites(self, id):
raise HTTPError(500, "Cannot save generated invites") from e
return {"ok": True}

@cherrypy.tools.json_out()
@cherrypy.tools.authorize()
def record_visit(self, id):
'''POST /api/events/:id/check-in'''
req = cherrypy.request
orm_session = req.orm_session
reg_id = int(id)
reg_data = api.get_event_registration_by_id(orm_session, reg_id)
if not reg_data:
raise HTTPError(400, "Something wrong with registration")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more clear in error message:

'There is no registration record for id={id}'.format(id=reg_id)

reg_data.visited = True
orm_session.merge(reg_data)
orm_session.commit()
return to_collection(reg_data, sort_keys=True)


class Places(APIBase):
@cherrypy.tools.json_out()
Expand Down Expand Up @@ -577,6 +592,10 @@ def list_all(self, **kwargs):
conditions={"method": ["GET"]})
rest_api.connect("sign-in", "/sign-in", Admin, action="sign_in",
conditions={"method": ["POST"]})
rest_api.connect("check-in",
r"/events/{id:\d+}/check-in", Events,
action="record_visit",
conditions={"method": ["POST"]})


# Error handlers
Expand Down