desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'query method for social link
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(SocialLink)
query_ = event_query(self, query_, view_kwargs)
return query_
|
'query method for access code list
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(AccessCode)
query_ = event_query(self, query_, view_kwargs)
if view_kwargs.get('user_id'):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
query_ = query_.join(User).filter((User.id == user.id))
if view_kwargs.get('ticket_id'):
t... |
'method to add user_id to view_kwargs before post
:param args:
:param kwargs:
:param data:
:return:'
| def before_post(self, args, kwargs, data):
| kwargs['user_id'] = current_identity.id
|
'method to add user_id to view_kwargs before post
:param args:
:param kwargs:
:param data:
:return:'
| def before_post(self, args, kwargs, data):
| require_relationship(['event', 'user'], data)
if (not has_access('is_coorganizer', event_id=data['event'])):
event = safe_query(self, Event, 'id', data['event'], 'event_id')
if (event.state == 'draft'):
raise ObjectNotFound({'parameter': 'event_id'}, 'Event: {} not found'.fo... |
'query method for speakers list class
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(Speaker)
query_ = event_query(self, query_, view_kwargs)
if view_kwargs.get('user_id'):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
query_ = query_.join(User).filter((User.id == user.id))
if view_kwargs.get('session_id'):
ses... |
'query method for Discount Code List
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(DiscountCode)
if view_kwargs.get('user_id'):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
query_ = query_.join(User).filter((User.id == user.id))
if view_kwargs.get('event_identifier'):
event = safe_query(self, Event, 'identifier'... |
'query method for Discount Code detail
:param view_kwargs:
:return:'
| def before_get_object(self, view_kwargs):
| if view_kwargs.get('event_identifier'):
event = safe_query(self, Event, 'identifier', view_kwargs['event_identifier'], 'event_identifier')
view_kwargs['event_id'] = event.id
if (view_kwargs.get('event_id') and has_access('is_admin')):
event = safe_query(self, Event, 'id', view_kwargs['ev... |
'Method to edit object
:param discount:
:param data:
:param view_kwargs:
:return:'
| def before_update_object(self, discount, data, view_kwargs):
| if ('used_for' in data):
used_for = data['used_for']
else:
used_for = discount.used_for
if ((discount.used_for == 'ticket') and has_access('is_coorganizer', event_id=view_kwargs.get('event_id')) and (used_for != 'event')):
self.schema = DiscountCodeSchemaTicket
elif ((discount.us... |
'Method for Discount Code delete
:param discount:
:param view_kwargs:
:return:'
| def before_delete_object(self, discount, view_kwargs):
| if ((discount.used_for == 'ticket') and has_access('is_coorganizer', event_id=view_kwargs['event_id'])):
self.schema = DiscountCodeSchemaTicket
elif ((discount.used_for == 'event') and has_access('is_admin')):
self.schema = DiscountCodeSchemaEvent
else:
raise UnprocessableEntity({'so... |
'Method for get relationship
:param args:
:param kwargs:
:return:'
| def before_get(self, args, kwargs):
| discount = db.session.query(DiscountCode).filter_by(id=kwargs.get('id')).one()
if (not discount):
raise ObjectNotFound({'parameter': '{id}'}, 'DiscountCode: not found')
if ((discount.used_for == 'ticket') and has_access('is_coorganizer', event_id=discount.event_id)):
self.schema = ... |
'Method for get relationship
:param args:
:param kwargs:
:return:'
| def before_get(self, args, kwargs):
| discount = db.session.query(DiscountCode).filter_by(id=kwargs.get('id')).one()
if (not discount):
raise ObjectNotFound({'parameter': '{id}'}, 'DiscountCode: not found')
if ((discount.used_for == 'ticket') and has_access('is_coorganizer', event_id=discount.event_id)):
self.schema = ... |
'query method for Notifications list
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(Notification)
if view_kwargs.get('user_id'):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
query_ = query_.join(User).filter((User.id == user.id))
return query_
|
'method to create object before post
:param data:
:param view_kwargs:
:return:'
| def before_create_object(self, data, view_kwargs):
| if (view_kwargs.get('user_id') is not None):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
data['user_id'] = user.id
|
'query method for custom placeholders list
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(CustomPlaceholder)
if view_kwargs.get('event_sub_topic_id'):
event_sub_topic = safe_query(self, EventSubTopic, 'id', view_kwargs['event_sub_topic_id'], 'event_sub_topic_id')
query_ = query_.join(EventSubTopic).filter((EventSubTopic.id == event_sub_topic.id))
retur... |
'method to create object before post
:param data:
:param view_kwargs:
:return:'
| def before_create_object(self, data, view_kwargs):
| if view_kwargs.get('event_sub_topic_id'):
event_sub_topic = safe_query(self, EventSubTopic, 'id', view_kwargs['event_sub_topic_id'], 'event_sub_topic_id')
data['event_sub_topic_id'] = event_sub_topic.id
|
'query method for event sub-topics list
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(EventSubTopic)
if view_kwargs.get('event_topic_id'):
event_topic = safe_query(self, EventTopic, 'id', view_kwargs['event_topic_id'], 'event_topic_id')
query_ = query_.join(EventTopic).filter((EventTopic.id == event_topic.id))
return query_
|
'query method for event invoice list
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(EventInvoice)
query_ = event_query(self, query_, view_kwargs)
if view_kwargs.get('user_id'):
user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
query_ = query_.join(User).filter((User.id == user.id))
if view_kwargs.get('discount_code_id'):
... |
'method to check for required relationship with event
:param args:
:param kwargs:
:param data:
:return:'
| def before_post(self, args, kwargs, data):
| require_relationship(['event'], data)
|
'query method for different view_kwargs
:param view_kwargs:
:return:'
| def query(self, view_kwargs):
| query_ = self.session.query(CustomForms)
query_ = event_query(self, query_, view_kwargs)
return query_
|
'before create method for object
:param data:
:param view_kwargs:
:return:'
| def before_create_object(self, data, view_kwargs):
| event = None
if view_kwargs.get('event_id'):
event = safe_query(self, Event, 'id', view_kwargs['event_id'], 'event_id')
elif view_kwargs.get('event_identifier'):
event = safe_query(self, Event, 'identifier', view_kwargs['event_identifier'], 'event_identifier')
if event:
data['eve... |
'before get method
:param view_kwargs:
:return:'
| def before_get_object(self, view_kwargs):
| event = None
if view_kwargs.get('event_id'):
event = safe_query(self, Event, 'id', view_kwargs['event_id'], 'event_id')
elif view_kwargs.get('event_identifier'):
event = safe_query(self, Event, 'identifier', view_kwargs['event_identifier'], 'event_identifier')
if event:
custom_fo... |
'before get method for user object
:param view_kwargs:
:return:'
| def before_get_object(self, view_kwargs):
| if (view_kwargs.get('notification_id') is not None):
notification = safe_query(self, Notification, 'id', view_kwargs['notification_id'], 'notification_id')
if (notification.user_id is not None):
view_kwargs['id'] = notification.user_id
else:
view_kwargs['id'] = None
... |
'validate login
:param field:
:return:'
| def validate_login(self, field):
| user = self.get_user()
if (user is None):
raise validators.ValidationError('User does not exist.')
if (user.password != generate_password_hash(self.password.data, user.salt)):
raise validators.ValidationError('Credentials incorrect.')
if ((not user.is_admin) and (not user.is_... |
'/admin
:return:'
| @expose('/')
def index(self):
| if (not login.current_user.is_authenticated):
return redirect(url_for('.login_view'))
return super(MyAdminIndexView, self).index()
|
'login view for flask-admin
:return:'
| @expose('/login/', methods=('GET', 'POST'))
def login_view(self):
| form = LoginForm(request.form)
if admin_helpers.validate_form_on_submit(form):
user = form.get_user()
login.login_user(user)
if login.current_user.is_authenticated:
return redirect(url_for('.index'))
self._template_args['form'] = form
return super(MyAdminIndexView, self).inde... |
'Register blueprints
:param app: a flask app instance
:return:'
| @staticmethod
def register(app):
| app.register_blueprint(home_routes)
admin = Admin(app, name='Open Event API', template_mode='bootstrap3', index_view=MyAdminIndexView(), base_template='admin_base.html')
(classes, models, table_names) = ([], [], [])
for class_ in db.Model._decl_class_registry.values():
try:
tab... |
'Fixes the payload data.
Here converts string time from datetime obj'
| def fix_payload(self, data):
| datetime_fields = ['starts_at', 'ends_at', 'schedule_published_on']
for f in datetime_fields:
if (f in data):
data[f] = EVENT_POST[f].from_str(data.get(f))
if data.get('call_for_papers'):
for _ in ['start_date', 'end_date']:
if (_ in data['call_for_papers']):
... |
'Fetch an event given its id'
| @replace_event_id
@api.doc('get_event', params=SINGLE_EVENT_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@fake_marshal_with(EVENT_COMPLETE)
def get(self, event_id):
| includes = parse_args(self.event_parser).get('include', '').split(',')
return marshal(DAO.get(event_id), get_extended_event_model(includes))
|
'Delete an event given its id'
| @requires_auth
@replace_event_id
@can_access
@api.doc('delete_event')
@api.marshal_with(EVENT)
def delete(self, event_id):
| event = DAO.delete(event_id)
record_activity('delete_event', event_id=event_id)
return event
|
'Update an event given its id'
| @requires_auth
@replace_event_id
@can_access
@api.doc('update_event', responses=PUT_RESPONSES)
@api.marshal_with(EVENT)
@api.expect(EVENT_POST)
def put(self, event_id):
| event = DAO.update(event_id, self.api.payload)
record_activity('update_event', event_id=event_id)
return event
|
'Fetch an event given its id.
Alternate endpoint for fetching an event.'
| @api.doc('get_event_for_webapp')
@api.header(*ETAG_HEADER_DEFN)
@replace_event_id
@fake_marshal_with(EVENT_COMPLETE)
def get(self, event_id):
| includes = parse_args(self.event_parser).get('include', '').split(',')
return marshal(DAO.get(event_id), get_extended_event_model(includes))
|
'List all events'
| @api.doc('list_events', params=EVENT_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@fake_marshal_list_with(EVENT_COMPLETE)
def get(self):
| parsed_args = parse_args(self.event_parser)
includes = parsed_args.get('include', '').split(',')
erase_from_dict(parsed_args, 'include')
return marshal(DAO.list(**parsed_args), get_extended_event_model(includes))
|
'Create an event'
| @requires_auth
@api.doc('create_event', responses=POST_RESPONSES)
@api.marshal_with(EVENT)
@api.expect(EVENT_POST)
def post(self):
| item = DAO.create(self.api.payload, self.api.url_for(self))
record_activity('create_event', event_id=item[0].id)
return item
|
'List events in a paginated manner'
| @api.doc('list_events_paginated', params=PAGE_PARAMS)
@api.doc(params=EVENT_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(EVENT_PAGINATED)
def get(self):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, **parse_args(self.event_parser))
|
'List all social links'
| @api.doc('list_social_links')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(SOCIAL_LINK)
@replace_event_id
def get(self, event_id):
| return LinkDAO.list(event_id)
|
'Create a social link'
| @requires_auth
@replace_event_id
@can_access
@api.doc('create_social_link', responses=POST_RESPONSES)
@api.marshal_with(SOCIAL_LINK)
@api.expect(SOCIAL_LINK_POST)
def post(self, event_id):
| return LinkDAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'Delete a social link given its id'
| @requires_auth
@replace_event_id
@can_access
@api.doc('delete_social_link')
@api.marshal_with(SOCIAL_LINK)
def delete(self, event_id, link_id):
| return LinkDAO.delete(event_id, link_id)
|
'Update a social link given its id'
| @requires_auth
@replace_event_id
@can_access
@api.doc('update_social_link', responses=PUT_RESPONSES)
@api.marshal_with(SOCIAL_LINK)
@api.expect(SOCIAL_LINK_POST)
def put(self, event_id, link_id):
| return LinkDAO.update(event_id, link_id, self.api.payload)
|
'Fetch a social link given its id'
| @api.hide
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SOCIAL_LINK)
@replace_event_id
def get(self, event_id, link_id):
| return LinkDAO.get(event_id, link_id)
|
'Get tickets of the event'
| @requires_auth
@replace_event_id
@api.doc('tickets', responses=POST_RESPONSES)
@api.marshal_list_with(TICKET)
def get(self, event_id):
| return DataGetter.get_sales_open_tickets(event_id=event_id).all()
|
'Get information about a ticket'
| @requires_auth
@replace_event_id
@api.doc('ticket', responses=POST_RESPONSES)
@api.marshal_with(TICKET)
def get(self, event_id, ticket_id):
| return TicketingManager.get_ticket(ticket_id=ticket_id)
|
'Get information about a ticket'
| @requires_auth
@replace_event_id
@api.doc('order', responses=POST_RESPONSES)
@api.marshal_with(ORDER)
def get(self, event_id, identifier):
| return TicketingManager.get_order_by_identifier(identifier=identifier)
|
'Fetch a track given its id'
| @replace_event_id
@api.doc('get_track')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(TRACK)
def get(self, event_id, track_id):
| return DAO.get(event_id, track_id)
|
'Delete a track given its id'
| @requires_auth
@replace_event_id
@can_delete(DAO)
@api.doc('delete_track')
@api.marshal_with(TRACK)
def delete(self, event_id, track_id):
| return DAO.delete(event_id, track_id)
|
'Update a track given its id'
| @requires_auth
@replace_event_id
@can_update(DAO)
@api.doc('update_track', responses=PUT_RESPONSES)
@api.marshal_with(TRACK)
@api.expect(TRACK_POST)
def put(self, event_id, track_id):
| return DAO.update(event_id, track_id, self.api.payload)
|
'List all tracks'
| @replace_event_id
@api.doc('list_tracks')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(TRACK)
def get(self, event_id):
| return DAO.list(event_id)
|
'Create a track'
| @requires_auth
@replace_event_id
@can_create(DAO)
@api.doc('create_track', responses=POST_RESPONSES)
@api.marshal_with(TRACK)
@api.expect(TRACK_POST)
def post(self, event_id):
| return DAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'List tracks in a paginated manner'
| @replace_event_id
@api.doc('list_tracks_paginated', params=PAGE_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(TRACK_PAGINATED)
def get(self, event_id):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, event_id=event_id)
|
'Get CeleryTask status of an APIv2 based task'
| def get(self, task_id):
| if current_app.config.get('CELERY_ALWAYS_EAGER'):
state = TASK_RESULTS[task_id]['state']
info = TASK_RESULTS[task_id]['result']
else:
from app import celery
result = AsyncResult(id=task_id, app=celery)
state = result.state
info = result.info
if (state == 'SUCC... |
'Abstraction over validate with check_required set to False'
| def validate_put(self, data, model=None):
| return self.validate(data, model=model, check_required=False)
|
'Update version of the component of the event'
| def update_version(self, event_id):
| if self.version_key:
update_version(event_id, False, self.version_key)
|
'Safe delete fields from payload'
| def _del(self, data, fields):
| data_copy = data.copy()
for field in fields:
if (field in data):
del data_copy[field]
return data_copy
|
'format the text in database for output
works only for GET requests'
| def format(self, value):
| if (self.__schema_type__ == 'string'):
return unicode(value)
else:
return value
|
'Return when value is empty or null'
| def validate_empty(self):
| if self.required:
self.validation_error = 'Required field %s. Cannot be null or empty'
return False
else:
return True
|
'Validate the value. return True if valid'
| def validate(self, value):
| pass
|
'Fetch a microlocation given its id'
| @api.doc('get_microlocation')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(MICROLOCATION)
@replace_event_id
def get(self, event_id, microlocation_id):
| return DAO.get(event_id, microlocation_id)
|
'Delete a microlocation given its id'
| @requires_auth
@can_delete(DAO)
@api.doc('delete_microlocation')
@api.marshal_with(MICROLOCATION)
@replace_event_id
def delete(self, event_id, microlocation_id):
| return DAO.delete(event_id, microlocation_id)
|
'Update a microlocation given its id'
| @requires_auth
@can_update(DAO)
@api.doc('update_microlocation', responses=PUT_RESPONSES)
@api.marshal_with(MICROLOCATION)
@api.expect(MICROLOCATION_POST)
@replace_event_id
def put(self, event_id, microlocation_id):
| return DAO.update(event_id, microlocation_id, self.api.payload)
|
'List all microlocations'
| @api.doc('list_microlocations')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(MICROLOCATION)
@replace_event_id
def get(self, event_id):
| return DAO.list(event_id)
|
'Create a microlocation'
| @requires_auth
@can_create(DAO)
@api.doc('create_microlocation', responses=POST_RESPONSES)
@api.marshal_with(MICROLOCATION)
@api.expect(MICROLOCATION_POST)
@replace_event_id
def post(self, event_id):
| return DAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'List microlocations in a paginated manner'
| @api.doc('list_microlocations_paginated', params=PAGE_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(MICROLOCATION_PAGINATED)
@replace_event_id
def get(self, event_id):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, event_id=event_id)
|
'Get attendees of the event'
| @requires_auth
@replace_event_id
@can_access
@api.doc('check_in_toggle', responses=POST_RESPONSES)
@api.marshal_list_with(ATTENDEE)
def get(self, event_id):
| return TicketingManager.get_attendees(event_id)
|
'Toggle and Attendee\'s Checked in State'
| @requires_auth
@replace_event_id
@can_access
@api.doc('check_in_toggle', responses=POST_RESPONSES)
@api.marshal_with(ATTENDEE)
def post(self, event_id, holder_identifier):
| holder = TicketingManager.attendee_check_in_out(event_id, holder_identifier)
return (holder, 200)
|
'Check in attendee'
| @requires_auth
@replace_event_id
@can_access
@api.doc('check_in_toggle', responses=POST_RESPONSES)
@api.marshal_with(ATTENDEE)
def post(self, event_id, holder_identifier):
| holder = TicketingManager.attendee_check_in_out(event_id, holder_identifier, True)
return (holder, 200)
|
'Check out attendee'
| @requires_auth
@replace_event_id
@can_access
@api.doc('check_in_toggle', responses=POST_RESPONSES)
@api.marshal_with(ATTENDEE)
def post(self, event_id, holder_identifier):
| holder = TicketingManager.attendee_check_in_out(event_id, holder_identifier, False)
return (holder, 200)
|
'returns object (model). Checks if object is in same event'
| def get_object(self, model, sid, event_id):
| if (sid is None):
return None
return get_object_in_event(model, sid, event_id)
|
'Fixes payload of POST request'
| def fix_payload_post(self, event_id, data):
| if ('track_id' in data):
data['track'] = self.get_object(TrackModel, data.get('track_id'), event_id)
if ('microlocation_id' in data):
data['microlocation'] = self.get_object(MicrolocationModel, data.get('microlocation_id'), event_id)
if ('session_type_id' in data):
data['session_type... |
'Fetch a session given its id'
| @api.doc('get_session')
@replace_event_id
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SESSION)
def get(self, event_id, session_id):
| return DAO.get(event_id, session_id)
|
'Delete a session given its id'
| @requires_auth
@replace_event_id
@can_delete(DAO)
@api.doc('delete_session')
@api.marshal_with(SESSION)
def delete(self, event_id, session_id):
| return DAO.delete(event_id, session_id)
|
'Update a session given its id'
| @requires_auth
@replace_event_id
@can_update(DAO)
@api.doc('update_session', responses=PUT_RESPONSES)
@api.marshal_with(SESSION)
@api.expect(SESSION_POST)
def put(self, event_id, session_id):
| return DAO.update(event_id, session_id, self.api.payload)
|
'List all sessions'
| @replace_event_id
@api.doc('list_sessions', params=SESSIONS_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(SESSION)
def get(self, event_id):
| return DAO.list(event_id, **parse_args(self.session_parser))
|
'Create a session'
| @requires_auth
@replace_event_id
@can_create(DAO)
@api.doc('create_session', responses=POST_RESPONSES)
@api.marshal_with(SESSION)
@api.expect(SESSION_POST)
def post(self, event_id):
| item = DAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
record_activity('create_session', session=item[0], event_id=event_id)
return item
|
'List sessions in a paginated manner'
| @api.doc('list_sessions_paginated', params=PAGE_PARAMS)
@replace_event_id
@api.doc(params=SESSIONS_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SESSION_PAGINATED)
def get(self, event_id):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, event_id=event_id, **parse_args(self.session_parser))
|
'List all session types'
| @api.doc('list_session_types')
@replace_event_id
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(SESSION_TYPE)
def get(self, event_id):
| return TypeDAO.list(event_id)
|
'Create a session type'
| @requires_auth
@can_create(DAO)
@api.doc('create_session_type', responses=POST_RESPONSES)
@api.marshal_with(SESSION_TYPE)
@api.expect(SESSION_TYPE_POST)
def post(self, event_id):
| return TypeDAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'Delete a session type given its id'
| @requires_auth
@replace_event_id
@can_delete(DAO)
@api.doc('delete_session_type')
@api.marshal_with(SESSION_TYPE)
def delete(self, event_id, type_id):
| return TypeDAO.delete(event_id, type_id)
|
'Update a session type given its id'
| @requires_auth
@replace_event_id
@can_update(DAO)
@api.doc('update_session_type', responses=PUT_RESPONSES)
@api.marshal_with(SESSION_TYPE)
@api.expect(SESSION_TYPE_POST)
def put(self, event_id, type_id):
| return TypeDAO.update(event_id, type_id, self.api.payload)
|
'Fetch a session type given its id'
| @api.hide
@replace_event_id
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SESSION_TYPE)
def get(self, event_id, type_id):
| return TypeDAO.get(event_id, type_id)
|
'Fetch a sponsor given its id'
| @replace_event_id
@api.doc('get_sponsor')
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SPONSOR)
def get(self, event_id, sponsor_id):
| return DAO.get(event_id, sponsor_id)
|
'Delete a sponsor given its id'
| @requires_auth
@replace_event_id
@can_delete(DAO)
@api.doc('delete_sponsor')
@api.marshal_with(SPONSOR)
def delete(self, event_id, sponsor_id):
| return DAO.delete(event_id, sponsor_id)
|
'Update a sponsor given its id'
| @requires_auth
@replace_event_id
@can_update(DAO)
@api.doc('update_sponsor', responses=PUT_RESPONSES)
@api.marshal_with(SPONSOR)
@api.expect(SPONSOR_POST)
def put(self, event_id, sponsor_id):
| return DAO.update(event_id, sponsor_id, self.api.payload)
|
'List all sponsors'
| @api.doc('list_sponsors')
@replace_event_id
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_list_with(SPONSOR)
def get(self, event_id):
| return DAO.list(event_id)
|
'Create a sponsor'
| @requires_auth
@replace_event_id
@can_create(DAO)
@api.doc('create_sponsor', responses=POST_RESPONSES)
@api.marshal_with(SPONSOR)
@api.expect(SPONSOR_POST)
def post(self, event_id):
| return DAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'List all sponsor types'
| @replace_event_id
@api.doc('list_sponsor_types', model=[fields.String()])
@api.header(*ETAG_HEADER_DEFN)
def get(self, event_id):
| return DAO.list_types(event_id)
|
'List sponsors in a paginated manner'
| @replace_event_id
@api.doc('list_sponsors_paginated', params=PAGE_PARAMS)
@api.header(*ETAG_HEADER_DEFN)
@api.marshal_with(SPONSOR_PAGINATED)
def get(self, event_id):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, event_id=event_id)
|
'Fetch a speaker given its id'
| @replace_event_id
@api.doc('get_speaker', model=SPEAKER)
@api.header(*ETAG_HEADER_DEFN)
@speakers_marshal_with()
def get(self, event_id, speaker_id):
| return DAO.get(event_id, speaker_id)
|
'Delete a speaker given its id'
| @requires_auth
@replace_event_id
@can_delete(DAO)
@api.doc('delete_speaker', model=SPEAKER)
@speakers_marshal_with()
def delete(self, event_id, speaker_id):
| return DAO.delete(event_id, speaker_id)
|
'Update a speaker given its id'
| @requires_auth
@replace_event_id
@can_update(DAO)
@api.doc('update_speaker', responses=PUT_RESPONSES, model=SPEAKER)
@speakers_marshal_with()
@api.expect(SPEAKER_POST)
def put(self, event_id, speaker_id):
| return DAO.update(event_id, speaker_id, self.api.payload)
|
'List all speakers'
| @api.doc('list_speakers', model=[SPEAKER])
@replace_event_id
@api.header(*ETAG_HEADER_DEFN)
@speakers_marshal_with()
def get(self, event_id):
| return DAO.list(event_id)
|
'Create a speaker'
| @requires_auth
@replace_event_id
@can_create(DAO)
@api.doc('create_speaker', responses=POST_RESPONSES, model=SPEAKER)
@speakers_marshal_with()
@api.expect(SPEAKER_POST)
def post(self, event_id):
| return DAO.create(event_id, self.api.payload, self.api.url_for(self, event_id=event_id))
|
'List speakers in a paginated manner'
| @api.doc('list_speakers_paginated', params=PAGE_PARAMS)
@replace_event_id
@api.doc(model=SPEAKER_PAGINATED)
@api.header(*ETAG_HEADER_DEFN)
@speakers_marshal_with(fields=SPEAKER_PAGINATED, fields_private=SPEAKER_PAGINATED_PRIVATE)
def get(self, event_id):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args, event_id=event_id)
|
'Create user notification'
| @requires_auth
@replace_event_id
@can_create(DAO)
@api.doc('create_user_notification', responses=POST_RESPONSES)
@api.marshal_with(NOTIFICATION)
@api.expect(NOTIFICATION_POST)
def post(self, event_id):
| return (DAO.create_user_notify(self.api.payload), 201)
|
'Fetch a user given its id'
| @requires_auth
@can_access_account
@api.doc('get_user')
@api.marshal_with(USER)
def get(self, user_id):
| return DAO.get(user_id)
|
'Delete a user given its id'
| @requires_auth
@can_access_account
@api.doc('delete_user')
@api.marshal_with(USER)
def delete(self, user_id):
| return DAO.delete(user_id)
|
'Update a user given its id'
| @requires_auth
@can_access_account
@api.doc('update_user', responses=PUT_RESPONSES)
@api.marshal_with(USER)
@api.expect(USER_PUT)
def put(self, user_id):
| user = DAO.update(user_id, self.api.payload)
record_activity('update_user', user=user)
return user
|
'Fetch the current authenticated user'
| @requires_auth
@api.doc('get_self_user')
@api.marshal_with(USER)
def get(self):
| return (getattr(g, 'user', None), 200)
|
'Fetch the current authenticated user\'s events'
| @requires_auth
@api.doc('get_self_events')
@api.marshal_list_with(EVENT)
def get(self):
| user = getattr(g, 'user', None)
attendee_role = Role.query.filter_by(name=ATTENDEE).first()
events = DataGetter.get_user_events(user_id=user.id).filter((UsersEventsRoles.role_id != attendee_role.id)).all()
return (events, 200)
|
'List all users'
| @requires_auth
@staff_only
@api.doc('list_users')
@api.marshal_list_with(USER)
def get(self):
| return DAO.list()
|
'Create a user'
| @api.doc('create_user', responses=USER_POST_RESPONSES)
@api.marshal_with(USER)
@api.expect(USER_POST)
def post(self):
| return DAO.create(self.api.payload)
|
'List users in a paginated manner'
| @requires_auth
@staff_only
@api.doc('list_users_paginated', params=PAGE_PARAMS)
@api.marshal_with(USER_PAGINATED)
def get(self):
| args = self.parser.parse_args()
return DAO.paginated_list(args=args)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.