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 flask.ext.restplus import Resource, Namespace

from open_event.models.speaker import Speaker as SpeakerModel

from .helpers.helpers import get_paginated_list, requires_auth, \
    model_custom_form
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO,\
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES
from .helpers import custom_fields as fields
from open_event.helpers.data_getter import DataGetter


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.ext.restplus import Namespace, marshal_with
from flask_login import current_user

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(),
from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('events', description='Events')

EVENT = api.model('Event', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'email': fields.String,
    'color': fields.String,
    'logo': fields.String,
    'start_time': fields.DateTime,
    'end_time': fields.DateTime,
    'latitude': fields.Float,
    'longitude': fields.Float,
    'slogan': fields.String,
    'url': fields.String,
    'location_name': fields.String,
})

EVENT_PAGINATED = api.clone('EventPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(EVENT))
})


@api.route('/<int:event_id>')
@api.param('event_id')
@api.response(404, 'Event not found')
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.special_fields import SessionStateField
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(),
    'state': SessionStateField(),
})

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(),
from flask.ext.restplus import Namespace

from app.models.microlocation import Microlocation as MicrolocationModel
from .helpers import custom_fields as fields
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.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']
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 app.models.user import User as UserModel
from app.models.user_detail import UserDetail as UserDetailModel
from app.helpers.data import DataManager, record_activity

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
from .helpers import custom_fields as fields

api = Namespace("users", description="Users", path="/")


USER_DETAIL = api.model(
    "UserDetail",
    {
        "fullname": 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(),
from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.session import Level as LevelModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('levels', description='levels', path='/')

LEVEL = api.model('Level', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'label_en': fields.String,
})

LEVEL_PAGINATED = api.clone('LevelPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(LEVEL))
})


@api.route('/events/<int:event_id>/levels/<int:level_id>')
@api.response(404, 'Level not found')
@api.response(400, 'Object does not belong to event')
class Level(Resource):
    @api.doc('get_level')
    @api.marshal_with(LEVEL)
    def get(self, event_id, level_id):
        """Fetch a level given its id"""
        return get_object_in_event(LevelModel, level_id, event_id)
Example #10
0
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'

Example #11
0
from app.models.users_events_roles import UsersEventsRoles
from app.models.event_copyright import EventCopyright
from app.models.role import Role
from app.models.user import ORGANIZER
from app.helpers.data import save_to_db, update_version, record_activity

from .helpers.helpers import requires_auth, parse_args, \
    can_access, fake_marshal_with, fake_marshal_list_with, erase_from_dict
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
from .helpers.utils import Resource
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField, \
    EventPrivacyField, EventSubTopicField

api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

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()
})
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
from app.api.helpers.custom_fields import Licence

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(),
Example #13
0
from sqlalchemy.orm.collections import InstrumentedList

from open_event.models.session import Session as SessionModel
from open_event.models.track import Track as TrackModel
from open_event.models.microlocation import Microlocation as MicrolocationModel
from open_event.models.speaker import Speaker as SpeakerModel
from open_event.models.session_type import SessionType as SessionTypeModel

from .helpers.helpers import get_paginated_list, requires_auth, \
    save_db_model, get_object_in_event
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.special_fields import SessionLanguageField, SessionStateField

api = Namespace('sessions', description='Sessions', path='/')

# Create models
SESSION_TRACK = api.model('SessionTrack', {
    'id': fields.Integer(required=True),
    'name': fields.String(),
})

SESSION_SPEAKER = api.model(
    'SessionSpeaker', {
        'id': fields.Integer(required=True),
        'name': fields.String(),
        'organisation': fields.String()
    })

SESSION_MICROLOCATION = api.model('SessionMicrolocation', {
from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.session import Language as LanguageModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('languages', description='languages', path='/')

LANGUAGE = api.model('Language', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'label_en': fields.String,
    'label_de': fields.String,
})

LANGUAGE_PAGINATED = api.clone('LanguagePaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(LANGUAGE))
})


@api.route('/events/<int:event_id>/languages/<int:language_id>')
@api.response(404, 'Language not found')
@api.response(400, 'Object does not belong to event')
class Language(Resource):
    @api.doc('get_language')
    @api.marshal_with(LANGUAGE)
    def get(self, event_id, language_id):
        """Fetch a language given its id"""
        return get_object_in_event(LanguageModel, language_id, event_id)
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 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']
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'

from open_event.models.track import Track as TrackModel
from open_event.models.microlocation import Microlocation as MicrolocationModel
from open_event.models.speaker import Speaker as SpeakerModel
from open_event.models.session_type import SessionType as SessionTypeModel
from open_event.helpers.data import record_activity
from open_event.helpers.data_getter import DataGetter

from .helpers.helpers import get_paginated_list, requires_auth, \
    save_db_model, get_object_in_event, model_custom_form
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.special_fields import SessionLanguageField, SessionStateField


api = Namespace('sessions', description='Sessions', path='/')

# Create models
SESSION_TRACK = api.model('SessionTrack', {
    'id': fields.Integer(required=True),
    'name': fields.String(),
})

SESSION_SPEAKER = api.model('SessionSpeaker', {
    'id': fields.Integer(required=True),
    'name': fields.String(),
    'organisation': fields.String()
})

SESSION_MICROLOCATION = api.model('SessionMicrolocation', {
    'id': fields.Integer(required=True),
from flask.ext.restplus import Namespace

from app.helpers.ticketing import TicketingManager
from app.models.sponsor import Sponsor as SponsorModel
from app.models.ticket_holder import TicketHolder

from .helpers.helpers import (can_create, can_update, can_delete,
                              requires_auth, can_access)
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES, BaseDAO
from .helpers.utils import Resource, ETAG_HEADER_DEFN
from .helpers import custom_fields as fields

api = Namespace('ticketing', description='Ticketing', path='/')

ORDER = api.model(
    'Order', {
        'id': fields.Integer(),
        'identifier': fields.String(),
        'amount': fields.Float(),
        'paid_via': 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(),
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.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)
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/<int:event_id>/attendees/')
class AttendeesList(Resource):
    @requires_auth
    @can_access
    @api.doc('check_in_toggle', responses=POST_RESPONSES)
    @api.marshal_list_with(ATTENDEE)
"""
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.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(),
})

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(),
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.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 import g

from open_event.models.event import Event as EventModel
from open_event.models.users_events_roles import UsersEventsRoles
from open_event.models.role import Role
from open_event.models.user import ORGANIZER
from open_event.helpers.data import save_to_db, update_version

from .helpers.helpers import get_paginated_list, requires_auth, parse_args
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField


api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

EVENT = api.model('Event', {
    'id': fields.Integer(required=True),
    'name': fields.String(required=True),
    'email': fields.Email(),
    'color': fields.Color(),
    'logo': fields.ImageUri(),
    'start_time': fields.DateTime(required=True),
    'end_time': fields.DateTime(required=True),
    'latitude': fields.Float(),
Example #26
0
from flask.ext.restplus import Namespace

from app.models.track import Track as TrackModel

from .helpers.helpers import (
    can_create,
    can_update,
    can_delete
)
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

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)),
})
from flask.ext.restplus import Resource, Namespace

from app.api.events import EVENT
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.helpers.data import DataManager, record_activity
from app.helpers.data_getter import DataGetter
from app.models.users_events_roles import UsersEventsRoles

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
from .helpers import custom_fields as fields

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),
Example #28
0
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 app.helpers.ticketing import TicketingManager
from app.models.sponsor import Sponsor as SponsorModel
from app.models.ticket_holder import TicketHolder

from .helpers.helpers import (
    can_create,
    can_update,
    can_delete,
    requires_auth,
    can_access)
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, ServiceDAO, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, SERVICE_RESPONSES, BaseDAO
from .helpers.utils import Resource, ETAG_HEADER_DEFN
from .helpers import custom_fields as fields

api = Namespace('ticketing', description='Ticketing', path='/')

ORDER = api.model('Order', {
    'id': fields.Integer(),
    'identifier': fields.String(),
    'amount': fields.Float(),
    'paid_via': 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(),
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
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 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,
    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('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)
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
Example #34
0
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(),
})
Example #35
0
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)
import json
from flask.ext.restplus import Resource, Namespace
from flask_jwt import JWTError

from .helpers.errors import NotAuthorizedError
from .helpers import custom_fields as fields

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:
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(),
import os

from flask import send_file, make_response, jsonify, url_for, current_app
from flask.ext.restplus import Resource, Namespace, marshal

from app.helpers.data import record_activity
from helpers import custom_fields as fields
from helpers.export_helpers import export_event_json, create_export_job, send_export_mail
from helpers.helpers import nocache, can_access, requires_auth, replace_event_id
from helpers.utils import TASK_RESULTS

api = Namespace('exports', description='Exports', path='/')

EXPORT_SETTING = api.model('ExportSetting', {
    'image': fields.Boolean(default=False),
    'video': fields.Boolean(default=False),
    'document': fields.Boolean(default=False),
    'audio': fields.Boolean(default=False)
})


@nocache
@api.route('/events/<string:event_id>/export/json')
@api.hide
class EventExportJson(Resource):
    @requires_auth
    @replace_event_id
    @can_access
    @api.expect(EXPORT_SETTING)
    def post(self, event_id):
        from helpers.tasks import export_event_task
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(),
Example #40
0
from flask.ext.restplus import Resource, Namespace, reqparse
from flask import g

from open_event.models.event import Event as EventModel
from open_event.models.users_events_roles import UsersEventsRoles
from open_event.models.role import Role
from open_event.models.user import ORGANIZER
from open_event.helpers.data import save_to_db, update_version

from .helpers.helpers import get_paginated_list, requires_auth, parse_args
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField

api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

EVENT = api.model(
    'Event', {
        'id': fields.Integer(required=True),
        'name': fields.String(required=True),
        'email': fields.Email(),
        'color': fields.Color(),
        'logo': fields.ImageUri(),
        'start_time': fields.DateTime(required=True),
        'end_time': fields.DateTime(required=True),
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 Resource, Namespace, fields

from open_event.models.session import Session as SessionModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('sessions', description='Sessions', path='/')

SESSION_TRACK = api.model('SessionTrack', {
    'id': fields.Integer(required=True),
    'name': fields.String,
})

SESSION_SPEAKER = api.model('SessionSpeaker', {
    'id': fields.Integer(required=True),
    'name': fields.String,
})

SESSION_LEVEL = api.model('SessionLevel', {
    'id': fields.Integer(required=True),
    'label_en': fields.String,
})

SESSION_LANGUAGE = api.model('SessionLanguage', {
    'id': fields.Integer(required=True),
    'label_en': fields.String,
    'label_de': fields.String,
})
from flask.ext.restplus import Resource, Namespace, fields

from open_event.models.sponsor import Sponsor as SponsorModel
from open_event.models.event import Event as EventModel
from .helpers import get_object_list, get_object_or_404, get_object_in_event,\
    get_paginated_list
from utils import PAGINATED_MODEL, PaginatedResourceBase

api = Namespace('sponsors', description='sponsors', path='/')

SPONSOR = api.model('Sponsor', {
    'id': fields.Integer(required=True),
    'name': fields.String,
    'url': fields.String,
    'logo': fields.String,
})

SPONSOR_PAGINATED = api.clone('SponsorPaginated', PAGINATED_MODEL, {
    'results': fields.List(fields.Nested(SPONSOR))
})


@api.route('/events/<int:event_id>/sponsors/<int:sponsor_id>')
@api.response(404, 'Sponsor not found')
@api.response(400, 'Object does not belong to event')
class Sponsor(Resource):
    @api.doc('get_sponsor')
    @api.marshal_with(SPONSOR)
    def get(self, event_id, sponsor_id):
        """Fetch a sponsor given its id"""
        return get_object_in_event(SponsorModel, sponsor_id, event_id)
from open_event.models.event import Event as EventModel
from open_event.models.social_link import SocialLink as SocialLinkModel
from open_event.models.users_events_roles import UsersEventsRoles
from open_event.models.event_copyright import EventCopyright
from open_event.models.role import Role
from open_event.models.user import ORGANIZER
from open_event.helpers.data import save_to_db, update_version, record_activity

from .helpers.helpers import get_paginated_list, requires_auth, parse_args
from .helpers.utils import PAGINATED_MODEL, PaginatedResourceBase, \
    PAGE_PARAMS, POST_RESPONSES, PUT_RESPONSES, BaseDAO, ServiceDAO
from .helpers import custom_fields as fields
from helpers.special_fields import EventTypeField, EventTopicField, \
    EventPrivacyField, EventSubTopicField

api = Namespace('events', description='Events')

EVENT_CREATOR = api.model('EventCreator', {
    'id': fields.Integer(),
    'email': fields.Email()
})

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()
})