コード例 #1
0
ファイル: views.py プロジェクト: pvgupta24/SpeakInOut
def register_view(request):
    # Authentication check. Users logged in cannot view this page.
    if request.user.is_authenticated:
        return HttpResponseRedirect('/dashboard/')
    elif User.objects.all().count() == 0:
        return HttpResponseRedirect('/setup/')
    # Get template data from session
    template_data = parse_session(request, {'form_button': "Register"})
    # Proceed with rest of the view
    if request.method == 'POST':
        form = AccountRegisterForm(request.POST)
        if form.is_valid():
            register_user(
                form.cleaned_data['email'],
                form.cleaned_data['password_first'],
                form.cleaned_data['firstname'],
                form.cleaned_data['lastname']
            )
            user = authenticate(
                username = form.cleaned_data['email'].lower(),
                password = form.cleaned_data['password_first']
            )
            login(request,user)
            return HttpResponseRedirect('/dashboard/')
    else:
        form = AccountRegisterForm()
    template_data['form'] = form
    return render(request,'signup.html',template_data)
コード例 #2
0
ファイル: views.py プロジェクト: pvgupta24/SpeakInOut
def setup_view(request):
    if User.objects.all().count() > 0:
        return HttpResponseRedirect('/')
    # Get template data from the session
    template_data = parse_session(request,{'form_button':"Register"})
    # Proceed with rest of the view
    if request.method == 'POST':
        form = AccountRegisterForm(request.POST)
        if form.is_valid():
            register_user(
                form.cleaned_data['email'],
                form.cleaned_data['password_first'],
                form.cleaned_data['firstname'],
                form.cleaned_data['lastname']
            )
            user = authenticate(
                username=form.cleaned_data['email'].lower(),  # Make sure it's lowercase
                password=form.cleaned_data['password_first']
            )
            login(request, user)
            return HttpResponseRedirect('/dashboard/')
    else:
        form = AccountRegisterForm()
    template_data['form'] = form
    return render(request, 'setup.html', template_data)
コード例 #3
0
ファイル: views.py プロジェクト: pvgupta24/SpeakInOut
def login_view(request):
    # Authentication check. Users currently logged in cannot view this page.
    if request.user.is_authenticated:
        return HttpResponseRedirect('/dashboard/')
    elif User.objects.all().count() == 0:
        return HttpResponseRedirect('/setup/')
    # get template data from session
    template_data = parse_session(request, {'form_button':"Login"})
    # Proceed with the rest of view
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            user = authenticate(
                username = form.cleaned_data['email'].lower(),
                password = form.cleaned_data['password']
            )
            userInfo = User.objects.get(username=form.cleaned_data['email'].lower())
            if userInfo is not None:
                login(request,user)
                return HttpResponseRedirect('/dashboard/')
            else:
                return HttpResponseRedirect('/register/')
    else:
        form = LoginForm()
    template_data['form'] = form
    return render(request, 'login.html', template_data)
コード例 #4
0
def dashboard_view(request):
    # Authentication check. Users currently logged in cannot view this page.
    authentication_result = authentication_check(request)
    if authentication_result is not None:
        return authentication_result
    template_data = parse_session(request)
    # get template data from session
    template_data['profile'] = User.objects.get(username=request.user)
    template_data['dashboard'] = True
    if request.method == "POST":
        vd = request.FILES.get("audiovideo", None)
        name = request.POST.get("name")
        print(type(vd))
        path = default_storage.save('video/' + '123' + '.mp4',
                                    ContentFile(vd.read()))
        request.session['video_name'] = name
        # task = ThreadTask()
        # task.save()
        t = threading.Thread(target=longTask, args=[path, request, name])
        t.setDaemon(True)
        t.start()

        return HttpResponse(status=200)
    else:
        name = request.session['video_name']
        obj = Speech.objects.get(name=name, user=request.user)
        print("Printing")
        print(obj)
        template_data['obj'] = obj
        print(template_data['obj'].name)
        return render(request, 'dashboard.html', template_data)
コード例 #5
0
def myvideos(request):
    authentication_result = authentication_check(request)
    if authentication_result is not None:
        return authentication_result
    template_data = parse_session(request)
    template_data['myvideos'] = True
    all_speeches = Speech.objects.filter(user=request.user)
    template_data['videos'] = all_speeches
    return render(request, 'myvideos.html', template_data)
コード例 #6
0
def upload_manuscript(request):
    authentication_result = authentication_check(request)
    if authentication_result is not None:
        return authentication_result
    template_data = parse_session(request)
    video_name = template_data['video_name']
    if request.method == 'POST':
        speech_obj = Speech.objects.get(name=video_name)
        speech_obj.manuscript = request.POST.get('manuscript_text')
        speech_obj.text_sim = compareTranscripts(speech_obj.speech2text,speech_obj.manuscript)*100
        speech_obj.save()
        return HttpResponse(status=200)
コード例 #7
0
def show_analysis(request):
    authentication_result = authentication_check(request)
    if authentication_result is not None:
        return authentication_result
    template_data = parse_session(request)
    # get template data from session
    template_data['profile'] = User.objects.get(username=request.user)
    template_data['dashboard'] = True
    
    name = template_data['video_name']
    obj = Speech.objects.get(name = name, user = request.user)
    print("Printing")
    print(obj)
    template_data['obj'] = obj
    template_data['obj'].generated_questions_string = obj.generated_questions.split(",")
    print(template_data['obj'].name)
   
    return render(request, 'dashboard.html', template_data)