Example #1
0
 def post(self, *args, **kwargs):
     form = CommentForm(self.request.POST)
     if form.is_valid():
         self.request.event.comment = form.cleaned_data.get('comment')
         self.request.event.save()
         self.request.event.log_action(
             'pretix.event.comment',
             user=self.request.user,
             data={'new_comment': form.cleaned_data.get('comment')})
         messages.success(self.request, _('The comment has been updated.'))
     else:
         messages.error(self.request, _('Could not update the comment.'))
     return redirect(self.get_success_url())
Example #2
0
def event_index(request, organizer, event):
    widgets = []
    for r, result in event_dashboard_widgets.send(sender=request.event):
        widgets.extend(result)

    can_change_orders = request.user.has_event_permission(request.organizer, request.event, 'can_change_orders')
    qs = request.event.logentry_set.all().select_related('user', 'content_type').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'):
        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'):
        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],
        'actions': a_qs[:5] if can_change_orders else [],
        'comment_form': CommentForm(initial={'comment': request.event.comment})
    }

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

    return render(request, 'pretixcontrol/event/index.html', ctx)
Example #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

    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').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],
        'actions': a_qs[:5] if can_change_orders else [],
        'comment_form': CommentForm(initial={'comment': request.event.comment})
    }

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

    return render(request, 'pretixcontrol/event/index.html', ctx)
Example #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],
        '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)

    return render(request, 'pretixcontrol/event/index.html', ctx)
Example #5
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
Example #6
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_orders = request.user.has_event_permission(request.organizer,
                                                          request.event,
                                                          'can_change_orders',
                                                          request=request)
    can_change_event_settings = request.user.has_event_permission(
        request.organizer,
        request.event,
        'can_change_event_settings',
        request=request)
    can_view_vouchers = request.user.has_event_permission(request.organizer,
                                                          request.event,
                                                          'can_view_vouchers',
                                                          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)

    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 can_view_orders:
        qs = qs.exclude(content_type=ContentType.objects.get_for_model(Order))
    if not can_view_vouchers:
        qs = qs.exclude(
            content_type=ContentType.objects.get_for_model(Voucher))
    if not can_change_event_settings:
        allowed_types = [
            ContentType.objects.get_for_model(Voucher),
            ContentType.objects.get_for_model(Order)
        ]
        if request.user.has_event_permission(request.organizer,
                                             request.event,
                                             'can_change_items',
                                             request=request):
            allowed_types += [
                ContentType.objects.get_for_model(Item),
                ContentType.objects.get_for_model(ItemCategory),
                ContentType.objects.get_for_model(Quota),
                ContentType.objects.get_for_model(Question),
            ]
        qs = qs.filter(content_type__in=allowed_types)

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

    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