Esempio n. 1
0
def _api_close_event(request):
    if not 'id' in request.REQUEST:
        return JsonHttpResponse({'error': 'missing argument'})
    e = subscr_Es.event_by_id(request.REQUEST['id'])
    if not e:
        raise Http404
    if not e.has_write_access(request.user):
        raise PermissionDenied
    e.is_open = False
    e.save()
    return JsonHttpResponse({'success': True})
Esempio n. 2
0
def _api_close_event(request):
    if not 'id' in request.REQUEST:
        return JsonHttpResponse({'error': 'missing argument'})
    e = subscr_Es.event_by_id(request.REQUEST['id'])
    if not e:
        raise Http404
    if not e.has_write_access(request.user):
        raise PermissionDenied
    e.is_open = False
    e.save()
    return JsonHttpResponse({'success': True})
Esempio n. 3
0
def _api_get_email_addresses(request):
    if 'id' not in request.POST:
        return JsonHttpResponse({'error': 'missing arguments'})
    event = subscr_Es.event_by_id(request.POST['id'])
    if not event:
        raise Http404
    if (not event.has_public_subscriptions and
            not event.has_read_access(request.user)):
        raise PermissionDenied
    # XXX We can optimize this query
    return JsonHttpResponse({
        'success': True,
        'addresses': [s.user.canonical_full_email
                      for s in event.listSubscribed]})
Esempio n. 4
0
def _api_get_email_addresses(request):
    if 'id' not in request.POST:
        return JsonHttpResponse({'error': 'missing arguments'})
    event = subscr_Es.event_by_id(request.POST['id'])
    if not event:
        raise Http404
    if (not event.has_public_subscriptions
            and not event.has_read_access(request.user)):
        raise PermissionDenied
    # XXX We can optimize this query
    return JsonHttpResponse({
        'success':
        True,
        'addresses':
        [s.user.canonical_full_email for s in event.listSubscribed]
    })
Esempio n. 5
0
def _api_confirm_subscription(request):
    if not 'id' in request.REQUEST:
        return JsonHttpResponse({'error': 'missing argument'})
    # Find the event and subscription
    event = subscr_Es.event_by_id(request.REQUEST['id'])
    if event is None:
        return JsonHttpResponse({'error': 'event not found'})
    subscription = event.get_subscription_of(request.user)
    if subscription is None:
        return JsonHttpResponse({'error': 'subscription not found'})
    # Confirm, if not confirmed already
    if subscription.confirmed:
        return JsonHttpResponse({'error': 'already confirmed'})
    subscription.confirmed = True
    subscription.dateConfirmed = datetime.datetime.now()
    subscription.save()
    return JsonHttpResponse({'success': True})
Esempio n. 6
0
def _api_confirm_subscription(request):
    if not 'id' in request.REQUEST:
        return JsonHttpResponse({'error': 'missing argument'})
    # Find the event and subscription
    event = subscr_Es.event_by_id(request.REQUEST['id'])
    if event is None:
        return JsonHttpResponse({'error': 'event not found'})
    subscription = event.get_subscription_of(request.user)
    if subscription is None:
        return JsonHttpResponse({'error': 'subscription not found'})
    if not event.is_open:
        return JsonHttpResponse({'error': 'event is closed'})
    # Confirm, if not confirmed already
    if subscription.confirmed:
        return JsonHttpResponse({'error': 'already confirmed'})
    subscription.confirmed = True
    subscription.dateConfirmed = datetime.datetime.now()
    subscription.save()
    return JsonHttpResponse({'success': True})
Esempio n. 7
0
def _api_event_set_opened(request):
    if ('id' not in request.POST
            or not isinstance(request.POST['id'], six.string_types)):
        return JsonHttpResponse({'error': 'invalid or missing argument "id"'})
    e = subscr_Es.event_by_id(request.POST['id'])
    if not e:
        raise Http404
    if not e.has_write_access(request.user):
        raise PermissionDenied

    opened = {'true': True, 'false': False}.get(request.POST.get('opened'))
    if opened is True:
        e.open(request.user)
    elif opened is False:
        e.close(request.user)
    else:
        return JsonHttpResponse(
            {'error': 'invalid or missing argument "opened"'})

    return JsonHttpResponse({'success': True})
Esempio n. 8
0
def _api_event_set_opened(request):
    if ('id' not in request.POST
            or not isinstance(request.POST['id'], six.string_types)):
        return JsonHttpResponse({'error': 'invalid or missing argument "id"'})
    e = subscr_Es.event_by_id(request.POST['id'])
    if not e:
        raise Http404
    if not e.has_write_access(request.user):
        raise PermissionDenied

    opened = {'true': True, 'false': False}.get(request.POST.get('opened'))
    if opened is True:
        e.open(request.user)
    elif opened is False:
        e.close(request.user)
    else:
        return JsonHttpResponse({
            'error': 'invalid or missing argument "opened"'
        })

    return JsonHttpResponse({'success': True})