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.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
class MicrolocationDAO(ServiceDAO):
 'name':
 fields.String(required=True),
 'event_url':
 fields.Uri(),
 'email':
 fields.Email(),
 'logo':
 fields.Upload(),
 'start_time':
 fields.DateTime(required=True),
 'end_time':
 fields.DateTime(required=True),
 'timezone':
 fields.String(),
 'latitude':
 fields.Float(),
 'longitude':
 fields.Float(),
 'background_image':
 fields.Upload(attribute='background_url'),
 'placeholder_url':
 fields.PlaceHolder(attribute=lambda event: event),
 'description':
 fields.String(),
 'location_name':
 fields.String(),
 'searchable_location_name':
 fields.String(),
 'organizer_name':
 fields.String(),
 'organizer_description':