class NewsSubscriptionSchema(Schema): class Meta: type_ = 'news-subscription' self_view = 'v1.news_subscription_details' self_view_kwargs = {'id': '<id>'} self_view_many = 'v1.news_subscriptions_list' inflect = dasherize strict = True ordered = True id = fields.Str(dump_only=True) subscribed = fields.Boolean(required=True) subscribed_on_date_time = fields.DateTime(dump_only=True) user = Relationship( attribute='user', self_view='v1.news_subscription_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_details', related_view_kwargs={'id': '<user_id>'}, schema='UserSchema', type_='user', ) news = Relationship(attribute='news', self_view='v1.news_subscription_news', self_view_kwargs={'id': '<news.id>'}, related_view='v1.news_details', related_view_kwargs={'id': '<news.id>'}, schema='NewsSchema', type_='news', required=True)
class EmailNotificationSchema(SoftDeletionSchema): """ API Schema for email notification Model """ class Meta: """ Meta class for email notification API schema """ type_ = 'email-notification' self_view = 'v1.email_notification_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Integer(dump_only=True) next_event = fields.Boolean(default=False, allow_none=True) new_paper = fields.Boolean(default=False, allow_none=True) session_accept_reject = fields.Boolean(default=False, allow_none=True) session_schedule = fields.Boolean(default=False, allow_none=True) after_ticket_purchase = fields.Boolean(default=True, allow_none=True) event_id = fields.Integer(allow_none=True) event = Relationship(attribute='event', self_view='v1.email_notification_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'email_notification_id': '<id>'}, schema='EventSchemaPublic', type_='event') user = Relationship(attribute='user', self_view='v1.email_notification_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'email_notification_id': '<id>'}, schema='UserSchema', type_='user')
class EventsRolePermissionSchema(Schema): """ API Schema for Permission Model """ class Meta: """ Meta class for Notification API schema """ type_ = 'event-role-permission' self_view = 'v1.events_role_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'v1.events_role_list' inflect = dasherize id = fields.Str(dump_only=True) can_create = fields.Boolean(default=False) can_read = fields.Boolean(default=False) can_update = fields.Boolean(default=False) can_delete = fields.Boolean(default=False) role = Relationship(attribute='role', self_view='v1.event_role_role', self_view_kwargs={'id': '<id>'}, related_view='v1.role_detail', related_view_kwargs={'id': '<role_id>'}, schema='RoleSchema', type_='role') service = Relationship(attribute='service', self_view='v1.event_role_service', self_view_kwargs={'id': '<id>'}, related_view='v1.service_detail', related_view_kwargs={'id': '<service_id>'}, schema='ServiceSchema', type_='service')
class SampleSchema(Schema): class Meta: sqla_session = db.session model = models.Sample type_ = "samples" self_view = "rest_api.sample" self_view_many = "rest_api.samplelist" self_view_kwargs = {"id": "<id>"} id = f.Integer(attribute="sample_id", allow_none=True, as_string=True) name = f.String(attribute="sample_name") data = Relationship( related_view="rest_api.sample_sampledatalist", related_view_kwargs={"id": "<sample_id>"}, many=True, type_="sample_data", # include_resource_linkage=True, schema="SampleDataSchema", ) report = Relationship( related_view="rest_api.report", related_view_kwargs={"id": "<report_id>"}, many=False, type_="reports", id_field="report_id", include_resource_linkage=True, schema="ReportSchema", )
class PostSchema(Schema): id = fields.Str(dump_only=True) title = fields.Str() author = Relationship( related_view='author_detail', related_view_kwargs={ 'author_id': '<author.id>', '_external': True }, include_data=True, type_='people', ) comments = Relationship(related_view='posts_comments', related_view_kwargs={ 'post_id': '<id>', '_external': True }, many=True, include_data=True, type_='comments') def get_top_level_links(self, data, many): if many: self_link = url_for('posts_list', _external=True) else: self_link = url_for('posts_detail', post_id=data['id'], _external=True) return {'self': self_link} class Meta: type_ = 'posts'
class NewsCommentSchema(Schema): class Meta: type_ = 'news-comment' self_view = 'v1.news_comment_details' self_view_kwargs = {'id': '<id>'} self_view_many = 'v1.news_comments_list' inflect = dasherize ordered = True id = fields.Str(dump_only=True) comment = fields.Str() icon = fields.Integer(dump_only=True) created_on_date = fields.Date(dump_only=True) author = Relationship(attribute='author', self_view='v1.news_comments_author', self_view_kwargs={'id': '<id>'}, related_view='v1.user_details', related_view_kwargs={'id': '<author_id>'}, schema='UserSchema', type_='user', required=True) news = Relationship(attribute='news', self_view='v1.news_comments_news', self_view_kwargs={'id': '<id>'}, related_view='v1.news_details', related_view_kwargs={'id': '<news_id>'}, schema='NewsSchema', type_='news', required=True)
class CommentSchema(Schema): id = fields.String() content = fields.String() created_on = fields.DateTime() poster = fields.String() class Meta: type_ = 'comments' self_view = 'api.comments_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'api.comments_list' user = Relationship(type_='users', self_view='api.comments_user', self_view_kwargs={'id': '<id>'}, related_view='api.users_detail', related_view_kwargs={Meta.type_ + '_id': '<id>'}, include_resource_linkage=True, schema='UserSchema') post = Relationship(type_='posts', self_view='api.comments_post', self_view_kwargs={'id': '<id>'}, related_view='api.posts_detail', related_view_kwargs={Meta.type_ + '_id': '<id>'}, include_resource_linkage=True, schema='PostSchema')
class UserFollowGroupSchema(JSONAPISchema): """ Api schema for User Follow Group """ class Meta: type_ = 'user-follow-group' self_view = 'v1.user_follow_group_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) created_at = fields.DateTime(dump_only=True, timezone=True) group = Relationship( attribute='group', self_view='v1.user_follow_group_group', self_view_kwargs={'id': '<id>'}, related_view='v1.group_detail', related_view_kwargs={'user_follow_group_id': '<id>'}, schema='GroupSchema', type_='group', ) user = Relationship( attribute='user', self_view='v1.user_follow_group_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'user_follow_group_id': '<id>'}, schema='UserSchema', type_='user', )
class PhysicalReqSchema(Schema): id = fields.Int(dump_only=True) name = fields.String() model = fields.String() vendor = fields.String() part_number = fields.String() procs = fields.Int(allow_none=True) description = fields.String(allow_none=True) sfp_type = fields.String() power_draw = fields.String() network_ports = fields.Int() mgmt_ports = fields.Int() group = fields.String(allow_none=True) # Todo: replace with a team relationship ram = fields.Int(allow_none=True) storage = fields.Int(allow_none=True) vm_count = fields.Int(allow_none=True) hypervisor = fields.String(allow_none=True) env = fields.String(allow_none=True) team = Relationship( schema=TeamSchema, type_='team', include_resource_linkage=True ) location = Relationship( schema=LocationSchema, type_='location', include_resource_linkage=True ) class Meta: strict = True type_ = 'bm-req' inflect = dasherize
class EventInvoiceSchema(SoftDeletionSchema): """ Event Invoice API Schema based on event invoice model """ class Meta: type_ = 'event-invoice' self_view = 'v1.event_invoice_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) identifier = fields.Str(allow_none=True) amount = fields.Float(validate=lambda n: n >= 0, allow_none=True) address = fields.Str(allow_none=True) city = fields.Str(allow_none=True) state = fields.Str(allow_none=True) country = fields.Str(validate=validate.OneOf(choices=PAYMENT_COUNTRIES), allow_none=True) zipcode = fields.Str(allow_none=True) created_at = fields.DateTime(allow_none=True) completed_at = fields.DateTime(default=None) transaction_id = fields.Str(allow_none=True) paid_via = fields.Str(validate=validate.OneOf( choices=["free", "stripe", "paypal", "transfer", "onsite", "cheque"]), allow_none=True) payment_mode = fields.Str(allow_none=True) brand = fields.Str(allow_none=True) exp_month = fields.Integer(validate=lambda n: 0 <= n <= 12, allow_none=True) exp_year = fields.Integer(validate=lambda n: n >= 2015, allow_none=True) last4 = fields.Str(allow_none=True) stripe_token = fields.Str(allow_none=True) paypal_token = fields.Str(allow_none=True) status = fields.Str(validate=validate.OneOf(choices=["paid", "due"]), allow_none=True) invoice_pdf_url = fields.Url(allow_none=True) user = Relationship(attribute='user', self_view='v1.event_invoice_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'event_invoice_id': '<id>'}, schema='UserSchemaPublic', type_='user') order = Relationship(attribute='order', self_view='v1.event_invoice_order', self_view_kwargs={'id': '<id>'}, related_view='v1.order_detail', related_view_kwargs={'id': '<id>'}, schema='OrderSchema', type_='order') event = Relationship(attribute='event', self_view='v1.event_invoice_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'event_invoice_id': '<id>'}, schema='EventSchemaPublic', type_='event') discount_code = Relationship(attribute='discount_code', self_view='v1.event_invoice_discount_code', self_view_kwargs={'id': '<id>'}, related_view='v1.discount_code_detail', related_view_kwargs={'event_invoice_id': '<id>'}, schema='DiscountCodeSchemaPublic', type_='discount-code')
class ArticleSchema(Schema): class Meta: type_="article" self_view="api_v1.article_detail" self_view_kwargs={"id":"<id>"} self_viwe_many="api_v1.article_list" id=fields.Integer(as_string=True, dump_only=True) name=fields.String() price=fields.Float() iva=fields.Float() description=fields.String() image=fields.String() stock=fields.Integer() CategoryId=fields.Integer(load_only=True) category=Relationship( related_view="api_v1.category_detail", related_view_kwargs={"article_id":"<id>"}, self_view="api_v1.article_category", self_view_kwargs={"id":"<id>"}, schema="CategorySchema", type_="category" ) orderarticle=Relationship( attribute="order_association", related_view="api_v1.orderarticle_list", related_view_kwargs={"article_id":"<id>"}, self_view="api_v1.article_assc", self_view_kwargs={"id":"<id>"}, schema="OrderArticleSchema", type_="orderarticle" )
class OrderArticleSchema(Schema): class Meta: type_="orderarticle" self_view_many="api_v1.orderarticle_list" self_view="api_v1.orderarticle_detail" self_view_kwargs={"id":"<id>"} id=fields.Integer(as_string=True, dump_only=True) order_id= fields.Integer() article_id=fields.Integer() item_able=fields.Integer() items=fields.Integer(load_only=True) order=Relationship( related_view="api_v1.order_detail", related_view_kwargs={"orderarticle_id":"<id>"}, self_view="api_v1.orderarticle_order", self_view_kwargs={"id":"<id>"}, schema="OrderSchema", type_="order" ) article=Relationship( attribute="article_able", related_view="api_v1.article_detail", related_view_kwargs={"orderarticle_id":"<id>"}, self_view="api_v1.orderarticle_article", self_view_kwargs={"id":"<id>"}, schema="ArticleSchema", type_="article" )
class PostSchema(Schema): class Meta: type_ = 'posts' self_view = 'post_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'post_list' id = fields.Integer(dump_only=True) created_at = fields.DateTime(dump_only=True) updated_at = fields.DateTime(dump_only=True) link = fields.Url() text = fields.String(required=True) rating = fields.Integer(dump_only=True) user = Relationship(attribute='user', self_view='post_user', self_view_kwargs={'id': '<id>'}, related_view='post_detail', related_view_kwargs={'id': '<id>'}, schema='UserSchema', type_='users') channel = Relationship(attribute='channel', self_view='post_channel', self_view_kwargs={'id': '<id>'}, related_view='post_detail', related_view_kwargs={'id': '<id>'}, schema='ChannelSchema', type_='channels') comments = Relationship(self_view='post_comments', self_view_kwargs={'id': '<id>'}, related_view='comment_list', related_view_kwargs={'id': '<id>'}, many=True, schema='CommentSchema', type_='comments')
class TicketSchema(TicketSchemaPublic): class Meta: type_ = 'ticket' self_view = 'v1.ticket_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize access_codes = Relationship( attribute='access_codes', self_view='v1.ticket_access_code', self_view_kwargs={'id': '<id>'}, related_view='v1.access_code_list', related_view_kwargs={'ticket_id': '<id>'}, schema='AccessCodeSchema', many=True, type_='access-code', ) attendees = Relationship( attribute='ticket_holders', self_view='v1.ticket_attendees', self_view_kwargs={'id': '<id>'}, related_view='v1.attendee_list_post', related_view_kwargs={'ticket_id': '<id>'}, schema='AttendeeSchema', many=True, type_='attendee', )
def test_non_existing_view(self, app, post): field = Relationship( related_view='non_existing_view', related_view_kwargs={'author_id': '<author>'} ) with pytest.raises(BuildError): field.serialize('author', post)
class NotificationSchema(SoftDeletionSchema): """ API Schema for Notification Model """ class Meta: """ Meta class for Notification API schema """ type_ = 'notification' self_view = 'v1.notification_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) title = fields.Str(allow_none=True, dump_only=True) message = fields.Str(allow_none=True, dump_only=True) received_at = fields.DateTime(dump_only=True) accept = fields.Str(allow_none=True, dump_only=True) is_read = fields.Boolean() notification_actions = Relationship( attribute='actions', schema='NotificationActionSchema', self_view='v1.notification_actions', self_view_kwargs={'id': '<id>'}, related_view='v1.notification_actions_list', related_view_kwargs={'notification_id': '<id>'}, many=True, type_='notification-action') user = Relationship(attribute='user', self_view='v1.notification_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'notification_id': '<id>'}, schema='UserSchema', type_='user')
class AttendeeSchema(AttendeeSchemaPublic): """ Api schema for Ticket Holder Model """ class Meta: """ Meta class for Attendee API Schema """ type_ = 'attendee' self_view = 'v1.attendee_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize ticket = Relationship(attribute='ticket', self_view='v1.attendee_ticket', self_view_kwargs={'id': '<id>'}, related_view='v1.ticket_detail', related_view_kwargs={'attendee_id': '<id>'}, schema='TicketSchemaPublic', type_='ticket') order = Relationship(self_view='v1.attendee_order', self_view_kwargs={'id': '<id>'}, related_view='v1.order_detail', related_view_kwargs={'attendee_id': '<id>'}, schema='OrderSchema', type_='order')
def test_non_existing_view(self, app, post): field = Relationship( related_view="non_existing_view", related_view_kwargs={"author_id": "<author>"}, ) with pytest.raises(BuildError): field.serialize("author", post)
class TicketTagSchema(SoftDeletionSchema): """ Api schema for TicketTag Model """ class Meta: """ Meta class for TicketTag Api Schema """ type_ = 'ticket-tag' self_view = 'v1.ticket_tag_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) name = fields.Str(allow_none=True) tickets = Relationship( attribute='tickets', self_view='v1.ticket_tag_ticket', self_view_kwargs={'id': '<id>'}, related_view='v1.ticket_list', related_view_kwargs={'ticket_tag_id': '<id>'}, schema='TicketSchemaPublic', many=True, type_='ticket', ) event = Relationship( attribute='event', self_view='v1.ticket_tag_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'ticket_tag_id': '<id>'}, schema='EventSchemaPublic', type_='event', )
class PostSchema(Schema): id = fields.Str(dump_only=True) title = fields.Str() author = Relationship( related_view='author_detail', related_view_kwargs={ 'author_id': '<author.id>', '_external': True }, include_data=True, type_='people', ) comments = Relationship( related_view='posts_comments', related_view_kwargs={ 'post_id': '<id>', '_external': True }, many=True, include_data=True, type_='comments', ) class Meta: type_ = 'posts' self_view = 'posts_detail' self_view_kwargs = {'post_id': '<id>'} self_view_many = 'posts_list'
class FaqTypeSchema(Schema): """ Api Schema for faq type model """ class Meta: """ Meta class for FaqTypeSchema """ type_ = 'faq-type' self_view = 'v1.faq_type_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) name = fields.Str(required=True) event = Relationship(attribute='event', self_view='v1.faq_type_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'faq_type_id': '<id>'}, schema='EventSchemaPublic', type_='event') faqs = Relationship(attribute='faqs', self_view='v1.faq_type_faqs', self_view_kwargs={'id': '<id>'}, related_view='v1.faq_list', related_view_kwargs={'faq_type_id': '<id>'}, schema='FaqSchema', many=True, type_='faq')
class TripSchema(Schema): class Meta: type_ = 'trip' self_view = 'trip_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'trip_list' id = fields.Integer(as_string=True, dump_only=True, attribute='trip_id') launch = fields.Str(required=True) land = fields.Str(required=True) meters = fields.Integer(required=True) member = Relationship(attribute='member', self_view='trip_member', self_view_kwargs={'id': '<trip_id>'}, related_view='member_detail', related_view_kwargs={'trip_id': '<trip_id>'}, schema='MemberSchema', type_='member') boat = Relationship(attribute='boat', self_view='trip_boat', self_view_kwargs={'id': '<trip_id>'}, related_view='boat_detail', related_view_kwargs={'trip_id': '<trip_id>'}, schema='BoatSchema', type_='boat')
class FaqSchema(SoftDeletionSchema): """ Api schema for page Model """ class Meta: """ Meta class for page Api Schema """ type_ = 'faq' self_view = 'v1.faq_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) question = fields.Str(required=True) answer = fields.Str(required=True) event = Relationship(attribute='event', self_view='v1.faq_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'faq_id': '<id>'}, schema='EventSchemaPublic', type_='event') faq_type = Relationship(attribute='faq_type', self_view='v1.faq_faq_type', self_view_kwargs={'id': '<id>'}, related_view='v1.faq_type_detail', related_view_kwargs={'faq_id': '<id>'}, schema='FaqTypeSchemaPublic', type_='faq-type')
class UserFavouriteEventSchema(SoftDeletionSchema): """ Api schema for User Favourite Event Model """ class Meta: """ Meta class for User Favourite Event Api Schema """ type_ = 'user-favourite-event' self_view = 'v1.user_favourite_event_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) event = Relationship( self_view='v1.user_favourite_event_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'user_favourite_event_id': '<id>'}, schema='EventSchemaPublic', type_='event', ) user = Relationship( self_view='v1.user_favourite_event_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'user_favourite_event_id': '<id>'}, schema='UserSchema', type_='user', )
class FeatureRequestSchema(Schema): class Meta: type_ = 'feature_request' self_view = 'feature_request_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'feature_request_list' id = fields.Integer(as_string=True, dump_only=True) title = fields.Str(requried=True) description = fields.Str(requried=True) client = Relationship(attribute='client', self_view='client_detail', self_view_kwargs={'id': '<id>'}, schema='ClientSchema', type_='client') client_priority = Relationship(attribute='client_priority', self_view='priority_detail', self_view_kwargs={'id': '<id>'}, schema='PrioritySchema', type_='priority') target_date = fields.Date(requried=True) product_area = Relationship(attribute='product_area', self_view='product_area_detail', self_view_kwargs={'id': '<id>'}, schema='ProductAreaSchema', type_='product_area')
class EventTopicSchema(Schema): """ Api Schema for event topic model """ class Meta: """ Meta class for event topic Api Schema """ type_ = 'event-topic' self_view = 'v1.event_topic_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) name = fields.Str(required=True) slug = fields.Str(dump_only=True) events = Relationship(attribute='event', many=True, self_view='v1.event_topic_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_list', related_view_kwargs={'event_topic_id': '<id>'}, schema='EventSchemaPublic', type_='event') event_sub_topics = Relationship( attribute='event_sub_topics', self_view='v1.event_topic_event_sub_topic', self_view_kwargs={'id': '<id>'}, related_view='v1.event_sub_topic_list', related_view_kwargs={'event_topic_id': '<id>'}, many=True, schema='EventSubTopicSchema', type_='event-sub-topic')
class FeedbackSchema(Schema): """ Api schema for Feedback Model """ class Meta: """ Meta class for Feedback Api Schema """ type_ = 'feedback' self_view = 'v1.feedback_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) rating = fields.Str(required=True) comment = fields.Str(required=False) event = Relationship(attribute='event', self_view='v1.feedback_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'feedback_id': '<id>'}, schema='EventSchemaPublic', type_='event') user = Relationship(attribute='user', self_view='v1.feedback_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'feedback_id': '<id>'}, schema='UserSchema', type_='user')
class SampleSchema(Schema): class Meta: sqla_session = db.session model = models.Sample type_ = 'samples' self_view = 'rest_api.sample' self_view_many = 'rest_api.samplelist' self_view_kwargs = {'id': '<id>'} id = f.Integer(attribute='sample_id', allow_none=True, as_string=True) name = f.String(attribute='sample_name') data = Relationship( related_view='rest_api.sample_sampledatalist', related_view_kwargs={'id': '<sample_id>'}, many=True, type_='sample_data', # include_resource_linkage=True, schema="SampleDataSchema") report = Relationship(related_view='rest_api.report', related_view_kwargs={'id': '<report_id>'}, many=False, type_='reports', id_field='report_id', include_resource_linkage=True, schema='ReportSchema')
class AttendeeSchemaPublic(SoftDeletionSchema): """ Api schema for Ticket Holder Model """ class Meta: """ Meta class for Attendee API Schema """ type_ = 'attendee' self_view = 'v1.attendee_detail' self_view_kwargs = {'id': '<id>'} inflect = dasherize id = fields.Str(dump_only=True) firstname = fields.Str(required=True) lastname = fields.Str(required=True) email = fields.Str(allow_none=True) address = fields.Str(allow_none=True) city = fields.Str(allow_none=True) state = fields.Str(allow_none=True) country = fields.Str(allow_none=True) job_title = fields.Str(allow_none=True) phone = fields.Str(allow_none=True) tax_business_info = fields.Str(allow_none=True) billing_address = fields.Str(allow_none=True) home_address = fields.Str(allow_none=True) shipping_address = fields.Str(allow_none=True) company = fields.Str(allow_none=True) work_address = fields.Str(allow_none=True) work_phone = fields.Str(allow_none=True) website = fields.Url(allow_none=True) blog = fields.Url(allow_none=True) twitter = fields.Url(allow_none=True) facebook = fields.Url(allow_none=True) github = fields.Url(allow_none=True) gender = fields.Str(allow_none=True) birth_date = fields.DateTime(allow_none=True) ticket_id = fields.Str(allow_none=True) is_checked_in = fields.Boolean() device_name_checkin = fields.Str(allow_none=True) checkin_times = fields.Str(allow_none=True) checkout_times = fields.Str(allow_none=True, dump_only=True) attendee_notes = fields.Str(allow_none=True) is_checked_out = fields.Boolean() pdf_url = fields.Url(dump_only=True) event = Relationship(attribute='event', self_view='v1.attendee_event', self_view_kwargs={'id': '<id>'}, related_view='v1.event_detail', related_view_kwargs={'attendee_id': '<id>'}, schema='EventSchema', type_='event') user = Relationship(attribute='user', self_view='v1.attendee_user', self_view_kwargs={'id': '<id>'}, related_view='v1.user_detail', related_view_kwargs={'attendee_id': '<id>'}, schema='UserSchemaPublic', type_='user')
class ChannelSchema(Schema): class Meta: type_ = 'channels' self_view = 'channel_detail' self_view_kwargs = {'id': '<id>'} self_view_many = 'channel_list' id = fields.Integer(dump_only=True) created_at = fields.DateTime(dump_only=True) updated_at = fields.DateTime(dump_only=True) name = fields.String(required=True) description = fields.String(required=True) subscribers = Relationship(self_view='channel_subscribers', self_view_kwargs={'id': '<id>'}, related_view='subscription_list', related_view_kwargs={'channel_id': '<id>'}, many=True, schema='SubscriptionSchema', type_='subscriptions') posts = Relationship(self_view='channel_posts', self_view_kwargs={'id': '<id>'}, related_view='post_list', related_view_kwargs={'channel_id': '<id>'}, many=True, schema='PostSchema', type_='posts')
def test_serialize_external(self, app, post): field = Relationship( related_view='posts_comments', related_view_kwargs={'post_id': '<id>', '_external': True}, ) result = field.serialize('comments', post) related = result['links']['related'] assert related == url_for('posts_comments', post_id=post.id, _external=True)
def test_empty_relationship(self, app, post_with_null_author): field = Relationship( related_view='author_detail', related_view_kwargs={'author_id': '<author>'} ) result = field.serialize('author', post_with_null_author) assert not result
def test_serialize_self_link(self, app, post): field = Relationship( self_view='posts_comments', self_view_kwargs={'post_id': '<id>'}, ) result = field.serialize('comments', post) assert 'comments' in result related = result['comments']['links']['self'] assert related == url_for('posts_comments', post_id=post.id)
def test_serialize_basic(self, app, post): field = Relationship( related_view='posts_comments', related_view_kwargs={'post_id': '<id>'}, ) result = field.serialize('comments', post) assert 'links' in result assert 'related' in result['links'] related = result['links']['related'] assert related == url_for('posts_comments', post_id=post.id)