from app.api.helpers.helpers import (can_create, can_update, can_delete, replace_event_id) from app.api.helpers.helpers import save_db_model, get_object_in_event, \ model_custom_form, requires_auth, parse_args from app.api.helpers.special_fields import SessionLanguageField, SessionStateField from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN api = Namespace('sessions', description='Sessions', path='/') # Create models SESSION_TRACK = api.model( 'SessionTrack', { 'id': fields.Integer(required=True), 'name': fields.String(), 'color': fields.Color(), 'font_color': fields.Color(), }) SESSION_SPEAKER = api.model( 'SessionSpeaker', { 'id': fields.Integer(required=True), 'name': fields.String(), 'organisation': fields.String(), 'city': fields.String(), 'short_biography': fields.String(), 'long_biography': fields.String(), 'heard_from': fields.String(), 'speaking_experience': fields.String(), 'sponsorship_required': fields.String(),
from flask.ext.restplus import Namespace from app.models.microlocation import Microlocation as MicrolocationModel from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import (can_create, can_update, can_delete, requires_auth) from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN 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
from flask.ext.restplus import Namespace from app.helpers.ticketing import TicketingManager from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import (requires_auth, replace_event_id) from app.api.helpers.utils import POST_RESPONSES from app.api.helpers.utils import Resource from app.helpers.data_getter import DataGetter api = Namespace('tickets', description='Tickets', path='/') ORDER = api.model( 'Order', { 'id': fields.Integer(), 'identifier': fields.String(), 'amount': fields.Float(), 'paid_via': fields.String(), 'invoice_number': fields.String(), 'payment_mode': fields.String(), 'status': fields.String(), 'completed_at': fields.DateTime(), }) TICKET = api.model( 'Ticket', { 'id': fields.Integer(), 'name': fields.String(), 'description': fields.String(), 'type': fields.String(), 'price': fields.Float(), 'quantity': fields.Integer(),
from app.api.tickets import ORDER, TICKET from app.helpers.ticketing import TicketingManager from app.api.helpers.helpers import (requires_auth, can_access, replace_event_id) from app.api.helpers.utils import POST_RESPONSES from app.api.helpers.utils import Resource from app.api.helpers import custom_fields as fields api = Namespace('attendees', description='Attendees', path='/') ATTENDEE = api.model( 'TicketHolder', { 'id': fields.Integer(), 'firstname': fields.String(), 'lastname': fields.String(), 'email': fields.Email(), 'checked_in': fields.Boolean(), 'order': fields.Nested(ORDER, allow_null=False), 'ticket': fields.Nested(TICKET, allow_null=False) }) @api.route('/events/<string:event_id>/attendees/') class AttendeesList(Resource): @requires_auth @replace_event_id @can_access @api.doc('check_in_toggle', responses=POST_RESPONSES) @api.marshal_list_with(ATTENDEE)
from app.models.user import ORGANIZER from app.models.users_events_roles import UsersEventsRoles from helpers.special_fields import EventTypeField, EventTopicField, \ EventPrivacyField, EventSubTopicField, EventStateField from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import requires_auth, parse_args, \ can_access, fake_marshal_with, fake_marshal_list_with, erase_from_dict, replace_event_id from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN api = Namespace('events', description='Events') EVENT_COPYRIGHT = api.model( 'EventCopyright', { 'holder': fields.String(), 'holder_url': fields.Uri(), 'licence': fields.String(), 'licence_url': fields.Uri(), 'year': fields.Integer(), 'logo': fields.String() }) EVENT_CFS = api.model( 'EventCFS', { 'announcement': fields.String(), 'start_date': fields.DateTime(), 'end_date': fields.DateTime(), 'timezone': fields.String(), 'privacy': EventPrivacyField() # [public, private]
from app.helpers.data_getter import DataGetter from app.models.speaker import Speaker as SpeakerModel from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import (can_create, can_update, can_delete, replace_event_id) from app.api.helpers.helpers import model_custom_form, requires_auth from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN api = Namespace('speakers', description='Speakers', path='/') SPEAKER_SESSION = api.model('SpeakerSession', { 'id': fields.Integer(), 'title': fields.String(), }) SPEAKER = api.model( 'Speaker', { 'id': fields.Integer(required=True), 'name': fields.String(required=True), 'photo': fields.Upload(), 'small': fields.Upload(), 'thumbnail': fields.Upload(), 'icon': fields.Upload(), 'short_biography': fields.String(), 'long_biography': fields.String(), 'email': fields.Email(required=True), 'mobile': fields.String(),
class SponsorTypesList(Resource): @api.doc('list_sponsor_types', model=[fields.String()]) @api.header(*ETAG_HEADER_DEFN) def get(self, event_id): """List all sponsor types""" return DAO.list_types(event_id)
import json from flask.ext.restplus import Resource, Namespace from flask_jwt import JWTError from app.api.helpers import custom_fields as fields from app.api.helpers.errors import NotAuthorizedError api = Namespace('login', description='Login') LOGIN = api.model('Login', { 'email': fields.Email(required=True), 'password': fields.String(required=True) }) TOKEN = api.model('Token', {'access_token': fields.String()}) @api.route('') class Login(Resource): @api.doc('get_token') @api.expect(LOGIN) @api.marshal_with(TOKEN) @api.response(401, 'Authentication Failed') def post(self): from .. import jwt try: response = jwt.auth_request_callback() return json.loads(response.data) except JWTError as e: raise NotAuthorizedError(
from flask.ext.restplus import Namespace from app.models.sponsor import Sponsor as SponsorModel from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import (can_create, can_update, can_delete, requires_auth) from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN 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
from app.helpers.data import DataManager, record_activity from app.helpers.data_getter import DataGetter from app.models.role import Role from app.models.user import User as UserModel, ATTENDEE from app.models.user_detail import UserDetail as UserDetailModel from app.models.users_events_roles import UsersEventsRoles from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import requires_auth, can_access_account, staff_only from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, BaseDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES api = Namespace('users', description='Users', path='/') USER_DETAIL = api.model( 'UserDetail', { 'firstname': fields.String(), 'lastname': fields.String(), 'details': fields.String(), 'avatar': fields.Upload(), '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)
from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import ( can_create, can_update, can_delete, requires_auth, replace_event_id) from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN 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)) })
from app.helpers.data import DataManager from app.helpers.data_getter import DataGetter from app.models.notifications import Notification as NotificationModel from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import (can_create, requires_auth, replace_event_id) from app.api.helpers.utils import PAGINATED_MODEL, ServiceDAO, \ POST_RESPONSES from app.api.helpers.utils import Resource 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
from app.models.social_link import SocialLink as SocialLinkModel from app.models.user import ORGANIZER from app.models.users_events_roles import UsersEventsRoles from helpers.special_fields import EventTypeField, EventTopicField, \ EventPrivacyField, EventSubTopicField, EventStateField from app.api.helpers import custom_fields as fields from app.api.helpers.helpers import requires_auth, parse_args, \ can_access, fake_marshal_with, fake_marshal_list_with, erase_from_dict from app.api.helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO from app.api.helpers.utils import Resource, ETAG_HEADER_DEFN api = Namespace('events', description='Events') EVENT_COPYRIGHT = api.model('EventCopyright', { 'holder': fields.String(), 'holder_url': fields.Uri(), 'licence': fields.String(), 'licence_url': fields.Uri(), 'year': fields.Integer(), 'logo': fields.String() }) EVENT_CFS = api.model('EventCFS', { 'announcement': fields.String(), 'start_date': fields.DateTime(), 'end_date': fields.DateTime(), 'timezone': fields.String(), 'privacy': EventPrivacyField() # [public, private] })