Beispiel #1
0
def rate(request):
    user = request.user
    assertion_id = get_parameter(request.POST, 'assertion_id', int)
    rating_value = get_parameter(request.POST, 'rating_value')

    activity, created = Activity.objects.get_or_create(name='commons/rating_button')

    assertion = Assertion.objects.get(id=assertion_id)
    assertion.set_rating(user, rating_values.get(rating_value, 0), activity)

    # FIXME: hard-coding the 10 items.
    get_top_torate.invalidate(assertion.language_id, 10)

    return {'text': _('Statement rated.')}
Beispiel #2
0
def add_from_frame(request):
    frame = Frame.objects.get(id=get_parameter(request.POST, 'frame_id', int))
    text1 = get_parameter(request.POST, 'text1')
    text2 = get_parameter(request.POST, 'text2')
    rating = rating_values[get_parameter(request.POST, 'rating')]

    if len(text1) == 0 or len(text2) == 0:
        raise InputError(_('One of the slots was not filled in.'))
    activity_name = get_parameter(request.POST, 'activity')

    user = request.user
    activity, created = Activity.objects.get_or_create(name=activity_name)
    assertion = add_assertion(request, request.user, frame, text1, text2,
    activity, rating)

    return {'text': _('Knowledge accepted.'), 'id': assertion.id}