Skip to content

Commit 7dbf33f

Browse files
nnhathungHieu Lam - TMAlthanhhieunorbusanmariobehling
authored
feature-8957: Store and Retrieve check in and out data on server (#8994)
* feature-8958: Store check in kiosk id to mark association * feature-8958: Store check in kiosk id to mark association * feature-8957: Store and Retrieve check in and out data on server implement api post and get detail * feature-8958: Store check in kiosk id to mark association set validate for station type and station name * feature-8958: Store check in kiosk id to mark association fix ci/cd * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association fix ci and update latest branch from development * feature-8958: Store check in kiosk id to mark association * feature-8958: Store check in kiosk id to mark association update station_type, remove session, add new 2 types check in and check out * feature-8958: Store check in kiosk id to mark association * feature-8958: Store check in kiosk id to mark association * fix multiple migration head * feature-8957:Store and Retrieve check in and out data on server * feature-8957: Store and Retrieve check in and out data on server * feature-8957: Store and Retrieve check in and out data on server * fix ci/cd * fix ci/cd * fix ci/cd * fix function too conplex * fix alembic revision * fix alembic revision --------- Co-authored-by: Hieu Lam - TMA <[email protected]> Co-authored-by: lthanhhieu <[email protected]> Co-authored-by: Norbert Preining <[email protected]> Co-authored-by: Mario Behling <[email protected]>
1 parent 6601854 commit 7dbf33f

File tree

7 files changed

+463
-0
lines changed

7 files changed

+463
-0
lines changed

app/api/helpers/static.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,10 @@
575575
LEVEL_CHOICES = ['Beginner', 'Intermediate', 'Advanced', 'Expert']
576576

577577
STATION_CHOICES = ['registration', 'daily', 'check in', 'check out']
578+
579+
STATION_TYPE = {
580+
'registration': 'registration',
581+
'check in': 'check in',
582+
'check out': 'check out',
583+
'daily': 'daily',
584+
}

app/api/helpers/user_check_in.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from app.api.helpers.errors import UnprocessableEntityError
2+
from app.api.helpers.static import STATION_TYPE
3+
from app.models.session import Session
4+
from app.models.station import Station
5+
from app.models.user_check_in import UserCheckIn
6+
7+
8+
def validate_microlocation(station: Station, session: Session):
9+
"""
10+
validate if microlocation matches
11+
@param station:
12+
@param session:
13+
"""
14+
if station.microlocation_id != session.microlocation_id:
15+
raise UnprocessableEntityError(
16+
{
17+
'station microlocation': station.microlocation_id,
18+
'session microlocation': session.microlocation_id,
19+
},
20+
"Location of your session not matches with station location"
21+
", please check with the organizer.",
22+
)
23+
24+
25+
def validate_check_in_out_status(station: Station, attendee_data: UserCheckIn):
26+
"""
27+
validate if attendee already check in/out
28+
@param station:
29+
@param attendee_data:
30+
"""
31+
if attendee_data:
32+
if (
33+
attendee_data.station.station_type == station.station_type
34+
and station.station_type == STATION_TYPE.get('check in')
35+
):
36+
raise UnprocessableEntityError(
37+
{
38+
'attendee': attendee_data.ticket_holder_id,
39+
'session ': attendee_data.session_id,
40+
},
41+
"Attendee already checked in.",
42+
)
43+
if (
44+
attendee_data.station.station_type == station.station_type
45+
and station.station_type == STATION_TYPE.get('check out')
46+
):
47+
raise UnprocessableEntityError(
48+
{
49+
'attendee': attendee_data.ticket_holder_id,
50+
'session ': attendee_data.session_id,
51+
},
52+
"Attendee not check in yet.",
53+
)
54+
else:
55+
if station.station_type == STATION_TYPE.get('check out'):
56+
raise UnprocessableEntityError(
57+
{
58+
'attendee': attendee_data.ticket_holder_id,
59+
'session ': attendee_data.session_id,
60+
},
61+
"Attendee not check in yet.",
62+
)

app/api/routes.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@
259259
TrackRelationshipOptional,
260260
TrackRelationshipRequired,
261261
)
262+
from app.api.user_check_in import (
263+
UserCheckInDetail,
264+
UserCheckInList,
265+
UserCheckInListPost,
266+
UserCheckInRelationship,
267+
)
262268
from app.api.user_emails import (
263269
UserEmailDetail,
264270
UserEmailList,
@@ -2046,6 +2052,40 @@
20462052
'station_microlocation',
20472053
'/stations/<int:id>/relationships/microlocation',
20482054
)
2055+
# user check in
2056+
api.route(
2057+
UserCheckInListPost,
2058+
'user_check_in_list_post',
2059+
'/user-check-in',
2060+
)
2061+
api.route(
2062+
UserCheckInList,
2063+
'user_check_in_list',
2064+
'/events/<int:event_id>/user-check-in',
2065+
'/events/<event_identifier>/user-check-in',
2066+
'/microlocations/<int:microlocation_id>/user-check-in',
2067+
)
2068+
api.route(UserCheckInDetail, 'user_check_in_detail', '/user-check-in/<int:id>')
2069+
api.route(
2070+
UserCheckInRelationship,
2071+
'user_check_in_ticket',
2072+
'/user-check-in/<int:id>/relationships/ticket',
2073+
)
2074+
api.route(
2075+
UserCheckInRelationship,
2076+
'user_check_in_attendee',
2077+
'/user-check-in/<int:id>/relationships/attendee',
2078+
)
2079+
api.route(
2080+
UserCheckInRelationship,
2081+
'user_check_in_station',
2082+
'/user-check-in/<int:id>/relationships/station',
2083+
)
2084+
api.route(
2085+
UserCheckInRelationship,
2086+
'user_check_in_session',
2087+
'/user-check-in/<int:id>/relationships/session',
2088+
)
20492089
api.route(
20502090
BadgeFormListPost,
20512091
'badge_form_list_post',

app/api/schema/user_check_in.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from marshmallow_jsonapi import fields
2+
from marshmallow_jsonapi.flask import Relationship, Schema
3+
4+
from app.api.helpers.static import STATION_TYPE
5+
from app.api.helpers.utilities import dasherize
6+
from utils.common import use_defaults
7+
8+
9+
@use_defaults()
10+
class UserCheckInSchema(Schema):
11+
"""API Schema for Station database model"""
12+
13+
class Meta:
14+
"""Meta class for Station Schema"""
15+
16+
type_ = 'user_check_in'
17+
self_view = 'v1.user_check_in_detail'
18+
self_view_kwargs = {'id': '<id>'}
19+
inflect = dasherize
20+
21+
id = fields.Integer(dump_only=True)
22+
success = fields.Boolean(dump_only=True, default=True)
23+
message = fields.Method("get_check_in_out_status")
24+
25+
ticket_holder = Relationship(
26+
self_view='v1.user_check_in_attendee',
27+
self_view_kwargs={'id': '<id>'},
28+
related_view='v1.attendee_detail',
29+
related_view_kwargs={'id': '<id>'},
30+
schema='AttendeeSchemaPublic',
31+
type_='attendee',
32+
load_only=True,
33+
)
34+
station = Relationship(
35+
self_view='v1.user_check_in_station',
36+
self_view_kwargs={'id': '<id>'},
37+
related_view='v1.station_detail',
38+
related_view_kwargs={'id': '<id>'},
39+
schema='StationSchema',
40+
type_='station',
41+
load_only=True,
42+
)
43+
session = Relationship(
44+
self_view='v1.user_check_in_session',
45+
self_view_kwargs={'id': '<id>'},
46+
related_view='v1.session_detail',
47+
related_view_kwargs={'id': '<id>'},
48+
schema='SessionSchema',
49+
type_='session',
50+
load_only=True,
51+
)
52+
53+
@staticmethod
54+
def get_check_in_out_status(obj):
55+
"""
56+
get checkin status
57+
@param obj:
58+
@return:
59+
"""
60+
if obj.station.station_type == STATION_TYPE.get('check in'):
61+
return "Attendee check in successful."
62+
if obj.station.station_type == STATION_TYPE.get('check out'):
63+
return "Attendee check out successful."
64+
if obj.station.station_type == STATION_TYPE.get('registration'):
65+
return "Ticket register successful."
66+
if obj.station.station_type == STATION_TYPE.get('daily'):
67+
return "Attendee daily check successful."
68+
return None

0 commit comments

Comments
 (0)