Exemplo n.º 1
0
def user_annotations(request, user_id):
    user = get_object_or_404(User, id=user_id)
    num_sounds_ok = Sound.objects.filter(user=user,
                                         moderation_state="OK").count()
    num_sounds_pending = Sound.objects.filter(user=user).exclude(
        moderation_state="OK").count()
    if request.method == 'POST':
        form = UserAnnotationForm(request.POST)
        if form.is_valid():
            ua = UserAnnotation(sender=request.user,
                                user=user,
                                text=form.cleaned_data['text'])
            ua.save()
    else:
        form = UserAnnotationForm()
    annotations = UserAnnotation.objects.filter(user=user)

    tvars = {
        "user": user,
        "num_sounds_ok": num_sounds_ok,
        "num_sounds_pending": num_sounds_pending,
        "form": form,
        "annotations": annotations
    }

    return render(request, 'tickets/user_annotations.html', tvars)
Exemplo n.º 2
0
def user_annotations(request, user_id):
    user = get_object_or_404(User, id=user_id)
    num_sounds_ok = Sound.objects.filter(user=user, moderation_state="OK").count()
    num_sounds_pending = Sound.objects.filter(user=user).exclude(moderation_state="OK").count()
    if request.method == 'POST':
        form = UserAnnotationForm(request.POST)
        if form.is_valid():
            ua = UserAnnotation(sender=request.user,
                                user=user,
                                text=form.cleaned_data['text'])
            ua.save()
    else:
        form = UserAnnotationForm()
    annotations = UserAnnotation.objects.filter(user=user)

    tvars = {"user": user,
             "num_sounds_ok": num_sounds_ok,
             "num_sounds_pending": num_sounds_pending,
             "form": form,
             "annotations": annotations}

    return render(request, 'tickets/user_annotations.html', tvars)