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
""" This file contains API v2 endpoints that are too small to be written as individual modules OR that are not important to the end-user """ from flask.ext.restplus import Resource, Namespace from celery.result import AsyncResult from flask import jsonify, current_app from helpers.utils import TASK_RESULTS api = Namespace('extras', description='Extras', path='/') @api.route('/tasks/<string:task_id>') @api.hide class CeleryTask(Resource): def get(self, task_id): """ Get CeleryTask status of an APIv2 based task """ # in case of always eager, get results. don't call AsyncResult # which rather looks in redis 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
from app.models.microlocation import Microlocation as MicrolocationModel from app.models.session import Session as SessionModel from app.models.session_type import SessionType as SessionTypeModel from app.models.speaker import Speaker as SpeakerModel from app.models.track import Track as TrackModel 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 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(),
from flask import g from flask.ext.restplus import Resource, Namespace from app.api.events import EVENT 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 .helpers import custom_fields as fields from .helpers.helpers import requires_auth, can_access_account, staff_only from .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(),
from flask.ext.restplus import Resource, Namespace from open_event.models.speaker import Speaker as SpeakerModel from .helpers.helpers import get_paginated_list, requires_auth from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from .helpers import custom_fields as fields 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(), 'photo': fields.ImageUri(), 'short_biography': fields.String(), 'long_biography': fields.String(), 'email': fields.Email(), 'mobile': fields.String(), 'website': fields.Uri(), 'twitter': fields.String(), # not sure for now whether uri or string field 'facebook': fields.String(), 'github': fields.String(),
from flask import g from flask import jsonify, url_for, current_app from flask.ext.restplus import Resource, Namespace, marshal from flask.ext.restplus import abort from app.helpers.data import record_activity from app.helpers.importers.ical import ICalImporter from app.helpers.importers.pentabarfxml import PentabarfImporter from events import EVENT from helpers.helpers import requires_auth from helpers.import_helpers import get_file_from_request, import_event_json, create_import_job, \ send_import_mail from helpers.utils import TASK_RESULTS api = Namespace('imports', description='Imports', path='/') @api.route('/events/import/<string:source_type>') @api.hide class EventImportJson(Resource): @requires_auth def post(self, source_type): if source_type == 'json': file_path = get_file_from_request(['zip']) elif source_type == 'pentabarf': file_path = get_file_from_request(['xml']) elif source_type == 'ical': file_path = get_file_from_request(['ical', 'ics']) else: file_path = None abort(404)
from flask import send_file, make_response from flask.ext.restplus import Resource, Namespace from helpers.export_helpers import export_event_json from helpers.helpers import nocache api = Namespace('exports', description='Exports', path='/') @nocache @api.route('/events/<int:event_id>/export/json') @api.hide class EventExportJson(Resource): def get(self, event_id): path = export_event_json(event_id) response = make_response(send_file(path)) response.headers['Content-Disposition'] = 'attachment; filename=event%d.zip' % event_id return response
from flask.ext.restplus import Namespace 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)
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(),
import json from flask.ext.restplus import Resource, Namespace from flask_jwt import JWTError from .helpers import custom_fields as fields from .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 app.models.event import Event as EventModel from app.models.event_copyright import EventCopyright from app.models.role import Role 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, 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(),
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 flask.ext.restplus import Namespace from app.helpers.data import DataManager from app.helpers.data_getter import DataGetter from app.models.notifications import Notification as NotificationModel from .helpers import custom_fields as fields from .helpers.helpers import (can_create, requires_auth) from .helpers.utils import PAGINATED_MODEL, ServiceDAO, \ POST_RESPONSES from .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']
from flask.ext.restplus import Namespace from app.models.track import Track as TrackModel from .helpers.helpers import (can_create, can_update, can_delete, requires_auth) from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \ PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES from .helpers import custom_fields as fields from .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 flask.ext.restplus import Namespace, fields from flask.ext.restplus.fields import Raw api = Namespace('errors', description='Error Responses') class NotFoundStatus(Raw): __schema_type__ = 'string' __schema_example__ = 'NOT_FOUND' class NotAuthorizedStatus(Raw): __schema_type__ = 'string' __schema_example__ = 'NOT_AUTHORIZED' class PermissionDeniedStatus(Raw): __schema_type__ = 'string' __schema_example__ = 'PERMISSION_DENIED' class ValidationStatus(Raw): __schema_type__ = 'string' __schema_example__ = 'INVALID_FIELD' class InvalidServiceStatus(Raw): __schema_type__ = 'string' __schema_example__ = 'INVALID_SERVICE'