예제 #1
0
def test_event_dates(event):
    tl = timeline_for_event(event)
    assert one([
        e for e in tl
        if e.event == event and e.datetime == event.date_from and e.description == 'Your event starts'
    ])
    assert one([
        e for e in tl
        if e.event == event and e.datetime == event.date_to and e.description == 'Your event ends'
    ])
예제 #2
0
def event_index(request, organizer, event):
    subevent = None
    if request.GET.get("subevent", "") != "" and request.event.has_subevents:
        i = request.GET.get("subevent", "")
        try:
            subevent = request.event.subevents.get(pk=i)
        except SubEvent.DoesNotExist:
            pass

    widgets = []
    for r, result in event_dashboard_widgets.send(sender=request.event, subevent=subevent, lazy=True):
        widgets.extend(result)

    can_change_orders = request.user.has_event_permission(request.organizer, request.event, 'can_change_orders',
                                                          request=request)
    qs = request.event.logentry_set.all().select_related('user', 'content_type', 'api_token', 'oauth_application',
                                                         'device').order_by('-datetime')
    qs = qs.exclude(action_type__in=OVERVIEW_BANLIST)
    if not request.user.has_event_permission(request.organizer, request.event, 'can_view_orders', request=request):
        qs = qs.exclude(content_type=ContentType.objects.get_for_model(Order))
    if not request.user.has_event_permission(request.organizer, request.event, 'can_view_vouchers', request=request):
        qs = qs.exclude(content_type=ContentType.objects.get_for_model(Voucher))

    a_qs = request.event.requiredaction_set.filter(done=False)

    ctx = {
        'widgets': rearrange(widgets),
        'logs': qs[:5],
        'subevent': subevent,
        'actions': a_qs[:5] if can_change_orders else [],
        'comment_form': CommentForm(initial={'comment': request.event.comment})
    }

    ctx['has_overpaid_orders'] = Order.annotate_overpayments(request.event.orders).filter(
        Q(~Q(status=Order.STATUS_CANCELED) & Q(pending_sum_t__lt=0))
        | Q(Q(status=Order.STATUS_CANCELED) & Q(pending_sum_rc__lt=0))
    ).exists()
    ctx['has_pending_orders_with_full_payment'] = Order.annotate_overpayments(request.event.orders).filter(
        Q(status__in=(Order.STATUS_EXPIRED, Order.STATUS_PENDING)) & Q(pending_sum_t__lte=0) & Q(require_approval=False)
    ).exists()
    ctx['has_pending_refunds'] = OrderRefund.objects.filter(
        order__event=request.event,
        state__in=(OrderRefund.REFUND_STATE_CREATED, OrderRefund.REFUND_STATE_EXTERNAL)
    ).exists()
    ctx['has_pending_approvals'] = request.event.orders.filter(
        status=Order.STATUS_PENDING,
        require_approval=True
    ).exists()

    for a in ctx['actions']:
        a.display = a.display(request)

    ctx['timeline'] = [
        {
            'date': t.datetime.astimezone(request.event.timezone).date(),
            'entry': t,
            'time': t.datetime.astimezone(request.event.timezone)
        }
        for t in timeline_for_event(request.event, subevent)
    ]
    ctx['today'] = now().astimezone(request.event.timezone).date()
    ctx['nearly_now'] = now().astimezone(request.event.timezone) - timedelta(seconds=20)
    resp = render(request, 'pretixcontrol/event/index.html', ctx)
    # resp['Content-Security-Policy'] = "style-src 'unsafe-inline'"
    return resp
예제 #3
0
def event_index(request, organizer, event):
    subevent = None
    if request.GET.get("subevent", "") != "" and request.event.has_subevents:
        i = request.GET.get("subevent", "")
        try:
            subevent = request.event.subevents.get(pk=i)
        except SubEvent.DoesNotExist:
            pass

    can_view_orders = request.user.has_event_permission(request.organizer,
                                                        request.event,
                                                        'can_view_orders',
                                                        request=request)
    can_change_event_settings = request.user.has_event_permission(
        request.organizer,
        request.event,
        'can_change_event_settings',
        request=request)

    widgets = []
    if can_view_orders:
        for r, result in event_dashboard_widgets.send(sender=request.event,
                                                      subevent=subevent,
                                                      lazy=True):
            widgets.extend(result)

    ctx = {
        'widgets':
        rearrange(widgets),
        'subevent':
        subevent,
        'comment_form':
        CommentForm(initial={'comment': request.event.comment},
                    readonly=not can_change_event_settings),
    }

    ctx['has_overpaid_orders'] = can_view_orders and Order.annotate_overpayments(
        request.event.orders).filter(
            Q(~Q(status=Order.STATUS_CANCELED) & Q(pending_sum_t__lt=0))
            | Q(Q(status=Order.STATUS_CANCELED)
                & Q(pending_sum_rc__lt=0))).exists()
    ctx['has_pending_orders_with_full_payment'] = can_view_orders and Order.annotate_overpayments(
        request.event.orders).filter(
            Q(status__in=(Order.STATUS_EXPIRED, Order.STATUS_PENDING))
            & Q(pending_sum_t__lte=0) & Q(require_approval=False)).exists()
    ctx['has_pending_refunds'] = can_view_orders and OrderRefund.objects.filter(
        order__event=request.event,
        state__in=(OrderRefund.REFUND_STATE_CREATED,
                   OrderRefund.REFUND_STATE_EXTERNAL)).exists()
    ctx['has_pending_approvals'] = can_view_orders and request.event.orders.filter(
        status=Order.STATUS_PENDING, require_approval=True).exists()
    ctx['has_cancellation_requests'] = can_view_orders and CancellationRequest.objects.filter(
        order__event=request.event).exists()

    ctx['timeline'] = [{
        'date':
        t.datetime.astimezone(request.event.timezone).date(),
        'entry':
        t,
        'time':
        t.datetime.astimezone(request.event.timezone)
    } for t in timeline_for_event(request.event, subevent)]
    ctx['today'] = now().astimezone(request.event.timezone).date()
    ctx['nearly_now'] = now().astimezone(
        request.event.timezone) - timedelta(seconds=20)
    resp = render(request, 'pretixcontrol/event/index.html', ctx)
    # resp['Content-Security-Policy'] = "style-src 'unsafe-inline'"
    return resp
예제 #4
0
def event_index(request, organizer, event):
    subevent = None
    if request.GET.get("subevent", "") != "" and request.event.has_subevents:
        i = request.GET.get("subevent", "")
        try:
            subevent = request.event.subevents.get(pk=i)
        except SubEvent.DoesNotExist:
            pass

    widgets = []
    for r, result in event_dashboard_widgets.send(sender=request.event, subevent=subevent):
        widgets.extend(result)

    can_change_orders = request.user.has_event_permission(request.organizer, request.event, 'can_change_orders',
                                                          request=request)
    qs = request.event.logentry_set.all().select_related('user', 'content_type', 'api_token', 'oauth_application',
                                                         'device').order_by('-datetime')
    qs = qs.exclude(action_type__in=OVERVIEW_BLACKLIST)
    if not request.user.has_event_permission(request.organizer, request.event, 'can_view_orders', request=request):
        qs = qs.exclude(content_type=ContentType.objects.get_for_model(Order))
    if not request.user.has_event_permission(request.organizer, request.event, 'can_view_vouchers', request=request):
        qs = qs.exclude(content_type=ContentType.objects.get_for_model(Voucher))

    a_qs = request.event.requiredaction_set.filter(done=False)

    ctx = {
        'widgets': rearrange(widgets),
        'logs': qs[:5],
        'subevent': subevent,
        'actions': a_qs[:5] if can_change_orders else [],
        'comment_form': CommentForm(initial={'comment': request.event.comment})
    }

    ctx['has_overpaid_orders'] = Order.annotate_overpayments(request.event.orders).filter(
        Q(~Q(status=Order.STATUS_CANCELED) & Q(pending_sum_t__lt=0))
        | Q(Q(status=Order.STATUS_CANCELED) & Q(pending_sum_rc__lt=0))
    ).exists()
    ctx['has_pending_orders_with_full_payment'] = Order.annotate_overpayments(request.event.orders).filter(
        Q(status__in=(Order.STATUS_EXPIRED, Order.STATUS_PENDING)) & Q(pending_sum_t__lte=0) & Q(require_approval=False)
    ).exists()
    ctx['has_pending_refunds'] = OrderRefund.objects.filter(
        order__event=request.event,
        state__in=(OrderRefund.REFUND_STATE_CREATED, OrderRefund.REFUND_STATE_EXTERNAL)
    ).exists()
    ctx['has_pending_approvals'] = request.event.orders.filter(
        status=Order.STATUS_PENDING,
        require_approval=True
    ).exists()

    for a in ctx['actions']:
        a.display = a.display(request)

    ctx['timeline'] = [
        {
            'date': t.datetime.astimezone(request.event.timezone).date(),
            'entry': t,
            'time': t.datetime.astimezone(request.event.timezone)
        }
        for t in timeline_for_event(request.event, subevent)
    ]
    ctx['today'] = now().astimezone(request.event.timezone).date()
    ctx['nearly_now'] = now().astimezone(request.event.timezone) - timedelta(seconds=20)
    resp = render(request, 'pretixcontrol/event/index.html', ctx)
    # resp['Content-Security-Policy'] = "style-src 'unsafe-inline'"
    return resp