Ejemplo n.º 1
0
def topic_interaction(request):
    data = dict(request.POST.items())
    user = request.user
    data['user'] = user.id
    form = TopicInteractionForm(data)
    if form.is_valid():
        if not has_watched_any_topic(user):
            remove_tags(user.email, 'never-watched-video')
        form.save()
        return JsonResponse({'msg': 'ok'})
Ejemplo n.º 2
0
def topic_interaction(request):
    data = dict(request.POST.items())
    user = request.user
    data['user'] = user.id
    form = TopicInteractionForm(data)
    if form.is_valid():
        if not has_watched_any_topic(user):
            user_facade.activate_user(user, None)

        form.save()
        return JsonResponse({'msg': 'ok'})
Ejemplo n.º 3
0
def topic_interaction(request):
    data = dict(request.POST.items())
    user = request.user
    data['user'] = user.id
    form = TopicInteractionForm(data)
    if form.is_valid():
        if not has_watched_any_topic(user):
            user_facade.activate_user(user, None)
        topic_id = int(request.POST['topic'])
        current_topic_duration = Topic.objects.values('duration').get(id=topic_id)['duration']
        maybe_new_topic_duration = form.cleaned_data['topic_duration']
        if current_topic_duration != maybe_new_topic_duration:
            Topic.objects.filter(id=topic_id).update(duration=maybe_new_topic_duration)
        form.save()
        return JsonResponse({'msg': 'ok'})
Ejemplo n.º 4
0
def topic_interaction(request):
    data = dict(request.POST.items())
    user = request.user
    data['user'] = user.id
    form = TopicInteractionForm(data)
    if form.is_valid():
        if not has_watched_any_topic(user):
            user_domain.activate_user(user, None)
        topic_id = int(request.POST['topic'])
        current_topic_duration = Topic.objects.values('duration').get(
            id=topic_id)['duration']
        maybe_new_topic_duration = form.cleaned_data['topic_duration']
        if current_topic_duration != maybe_new_topic_duration:
            Topic.objects.filter(id=topic_id).update(
                duration=maybe_new_topic_duration)
        form.save()
        data = form.cleaned_data
        if data['max_watched_time'] >= data['topic_duration']:
            content_statistics_domain.tag_newly_completed_contents.delay(
                user.id, topic_id)
        return JsonResponse({'msg': 'ok'})