def get_extended_event_model(includes=None): if includes is None: includes = [] included_fields = {} if 'sessions' in includes: included_fields['sessions'] = fields.List(fields.Nested(SESSION), attribute='session') if 'tracks' in includes: included_fields['tracks'] = fields.List(fields.Nested(TRACK), attribute='track') if 'microlocations' in includes: included_fields['microlocations'] = fields.List(fields.Nested(MICROLOCATION), attribute='microlocation') if 'sponsors' in includes: included_fields['sponsors'] = fields.List(fields.Nested(SPONSOR), attribute='sponsor') if 'speakers' in includes: included_fields['speakers'] = fields.List(fields.Nested(SPEAKER), attribute='speaker') if 'tickets' in includes: included_fields['tickets'] = fields.List(fields.Nested(TICKET), attribute='tickets') return EVENT.extend('ExtendedEvent', included_fields)
api = Namespace('microlocations', description='Microlocations', path='/') MICROLOCATION = api.model( 'Microlocation', { 'id': fields.Integer(required=True), 'name': fields.String(required=True), 'latitude': fields.Float(), 'longitude': fields.Float(), 'floor': fields.Integer(), 'room': fields.String(), }) MICROLOCATION_PAGINATED = api.clone( 'MicrolocationPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(MICROLOCATION))}) MICROLOCATION_POST = api.clone('MicrolocationPost', MICROLOCATION) del MICROLOCATION_POST['id'] # Create DAO class MicrolocationDAO(ServiceDAO): version_key = 'microlocations_ver' DAO = MicrolocationDAO(MicrolocationModel, MICROLOCATION_POST) @api.route('/events/<int:event_id>/microlocations/<int:microlocation_id>') @api.doc(responses=SERVICE_RESPONSES)
SESSION_TYPE_POST = api.clone('SessionTypePost', SESSION_TYPE) del SESSION_TYPE_POST['id'] SESSION = api.model( 'Session', { 'id': fields.Integer(required=True), 'title': fields.String(required=True), 'subtitle': fields.String(), 'level': fields.String(), 'short_abstract': fields.String(), 'long_abstract': fields.String(), 'comments': fields.String(), 'start_time': fields.DateTime(required=True), 'end_time': fields.DateTime(required=True), 'track': fields.Nested(SESSION_TRACK, allow_null=True), 'speakers': fields.List(fields.Nested(SESSION_SPEAKER)), 'language': SessionLanguageField(), 'microlocation': fields.Nested(SESSION_MICROLOCATION, allow_null=True), 'slides': fields.Upload(), 'video': fields.Upload(), 'audio': fields.Upload(), 'signup_url': fields.Uri(), 'state': SessionStateField(), 'session_type': fields.Nested(SESSION_TYPE, allow_null=True) }) SESSION_PAGINATED = api.clone('SessionPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(SESSION))}) SESSION_POST = api.clone( 'SessionPost', SESSION, {
'icon': fields.Upload(), 'short_biography': fields.String(), 'long_biography': fields.String(), 'email': fields.Email(required=True), 'mobile': fields.String(), 'featured': fields.Boolean(), 'website': fields.Uri(), 'twitter': fields.String(), # not sure for now whether uri or string field 'facebook': fields.String(), 'github': fields.String(), 'linkedin': fields.String(), 'organisation': fields.String(required=True), 'position': fields.String(), 'country': fields.String(required=True), 'sessions': fields.List(fields.Nested(SPEAKER_SESSION)), 'city': fields.String(), 'heard_from': fields.String(), 'speaking_experience': fields.String(), 'sponsorship_required': fields.String(), 'gender': fields.String() }) SPEAKER_PAGINATED = api.clone('SpeakerPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(SPEAKER))}) SPEAKER_POST = api.clone('SpeakerPost', SPEAKER) del SPEAKER_POST['id'] del SPEAKER_POST['sessions'] # don't allow adding sessions SPEAKER_PRIVATE = api.clone('SpeakerPrivate', SPEAKER)
'sub_topic': EventSubTopicField(), 'privacy': EventPrivacyField(), 'ticket_url': fields.Uri(), 'copyright': fields.Nested(EVENT_COPYRIGHT, allow_null=True), 'licence_details': fields.Licence(attribute='copyright.licence', allow_null=True), 'schedule_published_on': fields.DateTime(), 'code_of_conduct': fields.String(), 'social_links': fields.List(fields.Nested(SOCIAL_LINK), attribute='social_link'), 'call_for_papers': fields.Nested(EVENT_CFS, allow_null=True), 'version': fields.Nested(EVENT_VERSION), 'has_session_speakers': fields.Boolean(default=False), 'thumbnail': fields.Uri(), 'large': fields.Uri() }) EVENT_COMPLETE = api.clone( 'EventComplete', EVENT, { 'sessions':
api = Namespace('sponsors', description='Sponsors', path='/') SPONSOR = api.model( 'Sponsor', { 'id': fields.Integer(required=True), 'name': fields.String(required=True), 'url': fields.Uri(), 'logo': fields.Upload(), 'description': fields.String(), 'level': fields.String(), 'sponsor_type': fields.String(), }) SPONSOR_PAGINATED = api.clone('SponsorPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(SPONSOR))}) SPONSOR_POST = api.clone('SponsorPost', SPONSOR) del SPONSOR_POST['id'] # Create DAO class SponsorDAO(ServiceDAO): version_key = 'sponsors_ver' def list_types(self, event_id): sponsors = self.list(event_id) return list( set(sponsor.sponsor_type for sponsor in sponsors if sponsor.sponsor_type))
'contact': fields.String(), 'facebook': fields.String(), 'twitter': fields.String() }) USER = api.model( 'User', { 'id': fields.Integer(), 'email': fields.Email(required=True), 'signup_time': fields.DateTime(), 'last_access_time': fields.DateTime(), 'user_detail': fields.Nested(USER_DETAIL) }) USER_PAGINATED = api.clone('UserPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(USER))}) USER_PUT = api.clone('UserPut', USER) del USER_PUT['id'] del USER_PUT['signup_time'] del USER_PUT['last_access_time'] USER_POST = api.model('UserPost', { 'email': fields.Email(required=True), 'password': fields.String(required=True) }) # Responses USER_POST_RESPONSES = POST_RESPONSES.copy() del USER_POST_RESPONSES[404]
api = Namespace('tracks', description='Tracks', path='/') TRACK_SESSION = api.model('TrackSession', { 'id': fields.Integer(required=True), 'title': fields.String(), }) TRACK = api.model('Track', { 'id': fields.Integer(required=True), 'name': fields.String(required=True), 'description': fields.String(), 'color': fields.Color(required=True), 'track_image_url': fields.Upload(), 'location': fields.String(), 'sessions': fields.List(fields.Nested(TRACK_SESSION)), }) TRACK_PAGINATED = api.clone('TrackPaginated', PAGINATED_MODEL, { 'results': fields.List(fields.Nested(TRACK)) }) TRACK_POST = api.clone('TrackPost', TRACK) del TRACK_POST['id'] del TRACK_POST['sessions'] # Create DAO class TrackDAO(ServiceDAO): version_key = 'tracks_ver'
api = Namespace('notifications', description='Notifications', path='/') NOTIFICATION = api.model( 'Notification', { 'id': fields.Integer(required=True), 'email': fields.String(required=True), 'title': fields.String(), 'message': fields.String(), 'action': fields.String(), 'received_at': fields.DateTime(), }) NOTIFICATION_PAGINATED = api.clone( 'NotificationPaginated', PAGINATED_MODEL, {'results': fields.List(fields.Nested(NOTIFICATION))}) NOTIFICATION_POST = api.clone('NotificationPost', NOTIFICATION) del NOTIFICATION_POST['id'] # Create DAO class NotificationDAO(ServiceDAO): version_key = 'notifications_ver' def create_user_notify(self, payload): user = DataGetter.get_user_by_email(payload['email']) DataManager().create_user_notification(user, payload['action'], payload['title'], payload['message']) return user