def publish_event(event_id):
    event = DataGetter.get_event(event_id)
    if string_empty(event.location_name):
        flash(
            "Your event was saved. To publish your event please review the highlighted fields below.",
            "warning")
        return redirect(url_for('.edit_view',
                                event_id=event.id) + "#highlight=location_name")
    if not current_user.can_publish_event():
        flash("You don't have permission to publish event.")
        return redirect(url_for('.details_view', event_id=event_id))
    event.state = 'Published'
    save_to_db(event, 'Event Published')
    organizers = DataGetter.get_user_event_roles_by_role_name(event_id, 'organizer')
    speakers = DataGetter.get_user_event_roles_by_role_name(event_id, 'speaker')
    link = url_for('.details_view', event_id=event_id, _external=True)

    for organizer in organizers:
        send_event_publish(organizer.user.email, event.name, link)
    for speaker in speakers:
        send_event_publish(speaker.user.email, event.name, link)

    record_activity('publish_event', event_id=event.id, status='published')
    flash("Your event has been published.", "success")
    return redirect(url_for('.details_view', event_id=event_id))
def publish_event(event_id):
    event = DataGetter.get_event(event_id)
    if string_empty(event.location_name):
        flash(
            "Your event was saved. To publish your event please review the highlighted fields below.",
            "warning")
        return redirect(
            url_for('.edit_view', event_id=event.id) +
            "#highlight=location_name")
    if not current_user.can_publish_event():
        flash("You don't have permission to publish event.")
        return redirect(url_for('.details_view', event_id=event_id))
    event.state = 'Published'
    save_to_db(event, 'Event Published')
    organizers = DataGetter.get_user_event_roles_by_role_name(
        event_id, 'organizer')
    speakers = DataGetter.get_user_event_roles_by_role_name(
        event_id, 'speaker')
    link = url_for('.details_view', event_id=event_id, _external=True)

    for organizer in organizers:
        send_event_publish(organizer.user.email, event.name, link)
    for speaker in speakers:
        send_event_publish(speaker.user.email, event.name, link)

    record_activity('publish_event', event_id=event.id, status='published')
    flash("Your event has been published.", "success")
    event_json_modified.send(current_app._get_current_object(),
                             event_id=event_id)
    return redirect(url_for('.details_view', event_id=event_id))
def details_view(event_id):
    event = DataGetter.get_event(event_id)
    checklist = {"": ""}

    if fields_not_empty(event,
                        ['name', 'start_time', 'end_time', 'location_name',
                         'organizer_name', 'organizer_description']):
        checklist["1"] = 'success'
    elif fields_not_empty(event, ['name', 'start_time', 'end_time']):
        checklist["1"] = 'missing_some'
    else:
        checklist["1"] = 'missing_main'

    call_for_speakers = DataGetter.get_call_for_papers(event_id).first()
    if call_for_speakers:
        if fields_not_empty(call_for_speakers,
                            ['announcement', 'start_date', 'end_date']):
            checklist["4"] = "success"
        elif fields_not_empty(call_for_speakers,
                              ['start_date', 'end_date']):
            checklist["4"] = "missing_some"
        else:
            checklist["4"] = 'missing_main'
    else:
        checklist["4"] = "optional"

    sponsors = DataGetter.get_sponsors(event_id).all()
    if not sponsors:
        checklist["2"] = 'optional'
    else:
        for sponsor in sponsors:
            if fields_not_empty(sponsor, ['name', 'description', 'url', 'level', 'logo']):
                checklist["2"] = 'success'
                break
            else:
                checklist["2"] = 'missing_some'
    if event.has_session_speakers:
        session_types = DataGetter.get_session_types_by_event_id(event_id)
        tracks = DataGetter.get_tracks(event_id)
        microlocations = DataGetter.get_microlocations(event_id)

        if not session_types and not tracks and not microlocations:
            checklist["3"] = 'optional'
        elif not session_types or not tracks or not microlocations:
            checklist["3"] = 'missing_main'
        else:
            for session_type in session_types:
                if fields_not_empty(session_type, ['name', 'length']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'
            for microlocation in microlocations:
                if fields_not_empty(microlocation, ['name']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'
            for tracks in tracks:
                if fields_not_empty(tracks, ['name', 'color']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'

        checklist["5"] = 'success'
    else:
        checklist["3"] = 'optional'
        checklist["4"] = 'optional'
        checklist["5"] = 'optional'

    if not current_user.can_publish_event() and not AuthManager.is_verified_user():
        flash(Markup('To make your event live, please verify your email by '
                     'clicking on the confirmation link that has been emailed to you.<br>'
                     'Did not get the email? Please <a href="/resend_email/" class="alert-link"> click here to '
                     'resend the confirmation.</a>'))

    sessions = {'pending': get_count(DataGetter.get_sessions_by_state_and_event_id('pending', event_id)),
                'accepted': get_count(DataGetter.get_sessions_by_state_and_event_id('accepted', event_id)),
                'rejected': get_count(DataGetter.get_sessions_by_state_and_event_id('rejected', event_id)),
                'draft': get_count(DataGetter.get_sessions_by_state_and_event_id('draft', event_id))}

    return render_template('gentelella/users/events/details/details.html',
                           event=event,
                           checklist=checklist,
                           sessions=sessions,
                           settings=get_settings())
def details_view(event_id):
    event = DataGetter.get_event(event_id)
    orders = TicketingManager.get_orders(event_id)
    checklist = {"": ""}

    if fields_not_empty(event, [
            'name', 'start_time', 'end_time', 'location_name',
            'organizer_name', 'organizer_description'
    ]):
        checklist["1"] = 'success'
    elif fields_not_empty(event, ['name', 'start_time', 'end_time']):
        checklist["1"] = 'missing_some'
    else:
        checklist["1"] = 'missing_main'

    call_for_speakers = DataGetter.get_call_for_papers(event_id).first()
    if call_for_speakers:
        if fields_not_empty(call_for_speakers,
                            ['announcement', 'start_date', 'end_date']):
            checklist["4"] = "success"
        elif fields_not_empty(call_for_speakers, ['start_date', 'end_date']):
            checklist["4"] = "missing_some"
        else:
            checklist["4"] = 'missing_main'
    else:
        checklist["4"] = "optional"

    sponsors = DataGetter.get_sponsors(event_id).all()
    if not sponsors:
        checklist["2"] = 'optional'
    else:
        for sponsor in sponsors:
            if fields_not_empty(
                    sponsor, ['name', 'description', 'url', 'level', 'logo']):
                checklist["2"] = 'success'
                break
            else:
                checklist["2"] = 'missing_some'
    if event.has_session_speakers:
        session_types = DataGetter.get_session_types_by_event_id(event_id)
        tracks = DataGetter.get_tracks(event_id)
        microlocations = DataGetter.get_microlocations(event_id)

        if not session_types and not tracks and not microlocations:
            checklist["3"] = 'optional'
        elif not session_types or not tracks or not microlocations:
            checklist["3"] = 'missing_main'
        else:
            for session_type in session_types:
                if fields_not_empty(session_type, ['name', 'length']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'
            for microlocation in microlocations:
                if fields_not_empty(microlocation, ['name']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'
            for tracks in tracks:
                if fields_not_empty(tracks, ['name', 'color']):
                    checklist["3"] = 'success'
                    break
                else:
                    checklist["3"] = 'missing_some'

        checklist["5"] = 'success'
    else:
        checklist["3"] = 'optional'
        checklist["4"] = 'optional'
        checklist["5"] = 'optional'

    if not current_user.can_publish_event(
    ) and not AuthManager.is_verified_user():
        flash(
            Markup(
                'To make your event live, please verify your email by '
                'clicking on the confirmation link that has been emailed to you.<br>'
                'Did not get the email? Please <a href="/resend_email/" class="alert-link"> click here to '
                'resend the confirmation.</a>'))

    sessions = {
        'pending':
        get_count(
            DataGetter.get_sessions_by_state_and_event_id('pending',
                                                          event_id)),
        'accepted':
        get_count(
            DataGetter.get_sessions_by_state_and_event_id(
                'accepted', event_id)),
        'rejected':
        get_count(
            DataGetter.get_sessions_by_state_and_event_id(
                'rejected', event_id)),
        'draft':
        get_count(
            DataGetter.get_sessions_by_state_and_event_id('draft', event_id))
    }
    tickets_summary = {}

    for ticket in event.tickets:
        tickets_summary[str(ticket.id)] = {
            'name': ticket.name,
            'quantity': ticket.quantity,
            'completed': {
                'tickets_count': 0,
                'sales': 0
            },
            'placed': {
                'tickets_count': 0,
                'sales': 0
            },
            'pending': {
                'tickets_count': 0,
                'sales': 0
            },
            'expired': {
                'class': 'danger',
                'tickets_count': 0,
                'sales': 0
            },
            'deleted': {
                'tickets_count': 0,
                'sales': 0
            },
            'cancelled': {
                'tickets_count': 0,
                'sales': 0
            },
        }

    orders_summary = {
        'completed': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        },
        'placed': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        },
        'pending': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        },
        'expired': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        },
        'deleted': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        },
        'cancelled': {
            'tickets_count': 0,
            'orders_count': 0,
            'total_sales': 0
        }
    }

    for order in orders:
        if order.status == 'initialized':
            order.status = 'pending'
        fees = DataGetter.get_fee_settings_by_currency(
            DataGetter.get_event(order.event_id).payment_currency)
        orders_summary[str(order.status)]['orders_count'] += 1
        orders_summary[str(order.status)]['total_sales'] += order.amount

        for order_ticket in order.tickets:
            discount = TicketingManager.get_discount_code(
                event_id, order.discount_code_id)
            orders_summary[str(
                order.status)]['tickets_count'] += order_ticket.quantity
            ticket = get_ticket(order_ticket.ticket_id)
            tickets_summary[str(ticket.id)][str(
                order.status)]['tickets_count'] += order_ticket.quantity
            ticket_price = ticket.price
            if fees and not ticket.absorb_fees:
                order_fee = fees.service_fee * (ticket.price *
                                                order_ticket.quantity) / 100.0
                if order_fee > fees.maximum_fee:
                    ticket_price = ticket.price + fees.maximum_fee / order_ticket.quantity
                else:
                    ticket_price = ticket.price + fees.service_fee * ticket.price / 100.0

            if order.paid_via != 'free' and order.amount > 0:
                if discount and str(ticket.id) in discount.tickets.split(","):
                    if discount.type == "amount":
                        tickets_summary[str(ticket.id)][str(
                            order.status
                        )]['sales'] += order_ticket.quantity * (ticket_price -
                                                                discount.value)
                    else:
                        tickets_summary[str(ticket.id)][str(
                            order.status
                        )]['sales'] += order_ticket.quantity * (
                            ticket_price -
                            discount.value * ticket_price / 100.0)
                else:
                    tickets_summary[str(ticket.id)][str(
                        order.status
                    )]['sales'] += order_ticket.quantity * ticket_price
    return render_template('gentelella/users/events/details/details.html',
                           event=event,
                           checklist=checklist,
                           sessions=sessions,
                           tickets_summary=tickets_summary,
                           orders_summary=orders_summary,
                           settings=get_settings())
Example #5
0
    def details_view(self, event_id):
        event = DataGetter.get_event(event_id)
        checklist = {"": ""}

        if fields_not_empty(event, [
                'name', 'start_time', 'end_time', 'location_name',
                'organizer_name', 'organizer_description'
        ]):
            checklist["1"] = 'success'
        elif fields_not_empty(event, ['name', 'start_time', 'end_time']):
            checklist["1"] = 'missing_some'
        else:
            checklist["1"] = 'missing_main'

        call_for_speakers = DataGetter.get_call_for_papers(event_id).first()
        if call_for_speakers:
            if fields_not_empty(call_for_speakers,
                                ['announcement', 'start_date', 'end_date']):
                checklist["4"] = "success"
            elif fields_not_empty(call_for_speakers,
                                  ['start_date', 'end_date']):
                checklist["4"] = "missing_some"
            else:
                checklist["4"] = 'missing_main'
        else:
            checklist["4"] = "optional"

        sponsors = DataGetter.get_sponsors(event_id).all()
        if not sponsors:
            checklist["2"] = 'optional'
        else:
            for sponsor in sponsors:
                if fields_not_empty(
                        sponsor,
                    ['name', 'description', 'url', 'level', 'logo']):
                    checklist["2"] = 'success'
                    break
                else:
                    checklist["2"] = 'missing_some'
        if event.has_session_speakers:
            session_types = DataGetter.get_session_types_by_event_id(event_id)
            tracks = DataGetter.get_tracks(event_id)
            microlocations = DataGetter.get_microlocations(event_id)

            if not session_types and not tracks and not microlocations:
                checklist["3"] = 'optional'
            elif not session_types or not tracks or not microlocations:
                checklist["3"] = 'missing_main'
            else:
                for session_type in session_types:
                    if fields_not_empty(session_type, ['name', 'length']):
                        checklist["3"] = 'success'
                        break
                    else:
                        checklist["3"] = 'missing_some'
                for microlocation in microlocations:
                    if fields_not_empty(microlocation, ['name']):
                        checklist["3"] = 'success'
                        break
                    else:
                        checklist["3"] = 'missing_some'
                for tracks in tracks:
                    if fields_not_empty(tracks, ['name', 'color']):
                        checklist["3"] = 'success'
                        break
                    else:
                        checklist["3"] = 'missing_some'

            checklist["5"] = 'success'
        else:
            checklist["3"] = 'optional'
            checklist["4"] = 'optional'
            checklist["5"] = 'optional'

        if not current_user.can_publish_event() and not is_verified_user():
            flash(
                Markup(
                    'To make your event live, please verify your email by '
                    'clicking on the confirmation link that has been emailed to you.<br>'
                    'Did not get the email? Please <a href="/resend_email/" class="alert-link"> click here to resend the confirmation.</a>'
                ))

        sessions = {
            'pending':
            DataGetter.get_sessions_by_state_and_event_id('pending',
                                                          event_id).count(),
            'accepted':
            DataGetter.get_sessions_by_state_and_event_id(
                'accepted', event_id).count(),
            'rejected':
            DataGetter.get_sessions_by_state_and_event_id(
                'rejected', event_id).count(),
            'draft':
            DataGetter.get_sessions_by_state_and_event_id('draft',
                                                          event_id).count()
        }

        return self.render('/gentelella/admin/event/details/details.html',
                           event=event,
                           checklist=checklist,
                           sessions=sessions,
                           settings=get_settings())