Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support event statistics in include #6745

Merged
merged 2 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions app/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@
'/events/<identifier>/relationships/orders')
api.route(EventRelationship, 'event_stripe_authorization', '/events/<int:id>/relationships/stripe-authorization',
'/events/<identifier>/relationships/stripe-authorization')
api.route(EventRelationship, 'event_order_statistics', '/events/<int:id>/relationships/order-statistics',
'/events/<identifier>/relationships/order-statistics')
api.route(EventRelationship, 'event_general_statistics', '/events/<int:id>/relationships/general-statistics',
'/events/<identifier>/relationships/general-statistics')
# Events -> roles:
api.route(EventRelationship, 'event_owner', '/events/<int:id>/relationships/owner',
'/events/<identifier>/relationships/owner')
Expand Down
12 changes: 12 additions & 0 deletions app/api/schema/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ def validate_timezone(self, data, original_data):
related_view_kwargs={'event_id': '<id>'},
schema='StripeAuthorizationSchema',
type_='stripe-authorization')
order_statistics = Relationship(self_view='v1.event_order_statistics',
self_view_kwargs={'id': '<id>'},
related_view='v1.order_statistics_event_detail',
related_view_kwargs={'id': '<id>'},
schema='OrderStatisticsEventSchema',
type_='order-statistics-event')
general_statistics = Relationship(self_view='v1.event_general_statistics',
self_view_kwargs={'id': '<id>'},
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
related_view='v1.event_statistics_general_detail',
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
related_view_kwargs={'id': '<id>'},
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
schema='EventStatisticsGeneralSchema',
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
type_='general-statistics-event')
iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved


class EventSchema(EventSchemaPublic):
Expand Down
9 changes: 9 additions & 0 deletions app/models/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import binascii
import os
from argparse import Namespace
from datetime import datetime

import flask_login as login
Expand Down Expand Up @@ -446,6 +447,14 @@ def has_sessions(self):
@property
def has_speakers(self):
return Speaker.query.filter_by(event_id=self.id).count() > 0

iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
@property
def order_statistics(self):
return Namespace(id=self.id)

iamareebjamal marked this conversation as resolved.
Show resolved Hide resolved
@property
def general_statistics(self):
return Namespace(id=self.id)


@event.listens_for(Event, 'after_update')
Expand Down