Exemplo n.º 1
0
def process_request(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/')
    if request.urlparams[0] == "logout":
        logout(request)
        return HttpResponseRedirect('/')
    form = LoginForm()
    createForm = CreateUserForm()
    if request.urlparams[0] == "1":
        createForm = CreateUserForm(request.POST)
        if createForm.is_valid():
            newUser = m.User()
            newUser.username = createForm.cleaned_data['username']
            newUser.email = createForm.cleaned_data['email']
            newUser.password = createForm.cleaned_data['password']
            newUser.save()
            return HttpResponseRedirect('/')
    else:
        if request.method == "POST":
            form = LoginForm(request.POST)
            if form.is_valid():
                userN = form.cleaned_data['username'].lower()
                user = authenticate(username=userN,
                                    password=form.cleaned_data['password'])
                if user is not None:
                    login(request, user)
                else:
                    raise forms.ValidationError("Please Enter a username")
                return HttpResponseRedirect('/')

    tvars = {
        'form': form,
        'createForm': createForm,
    }
    return templater.render_to_response(request, 'tutorial.html', tvars)
Exemplo n.º 2
0
def process_request(request):
    if request.urlparams[0] == "logout":
        logout(request)
        return HttpResponseRedirect('/')
    if request.user.is_authenticated():
        return HttpResponseRedirect('/homePage/hotspots')
    createForm = CreateUserForm()
    if request.method == "POST":
        createForm = CreateUserForm(request.POST)
        if createForm.is_valid():
            newUser = m.User()
            newUser.username = createForm.cleaned_data['username'].lower()
            newUser.email = createForm.cleaned_data['email']
            newUser.set_password(createForm.cleaned_data['password'])
            newUser.save()
            # userN = createForm.cleaned_data['username'].lower()
            userN = m.User.objects.get(username = createForm.cleaned_data['username'].lower())
            #allows users to authenticate and to be logged in
            userN.backend = 'django.contrib.auth.backends.ModelBackend'
            login(request, userN)
            return HttpResponseRedirect('/homePage/hotspots/')
    if request.urlparams[0] == "about":
        return templater.render_to_response(request, 'about.html')

    tvars = {
        'form' : createForm,
    }
    return templater.render_to_response(request, 'create_user.html', tvars)
Exemplo n.º 3
0
def process_request(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login')
    if request.urlparams[0] == "logout":
        logout(request)
        return HttpResponseRedirect('/')
    form = LoginForm()
    createForm = CreateUserForm()
    if request.urlparams[0] == "1":
        createForm = CreateUserForm(request.POST)
        if createForm.is_valid():
            newUser = m.User()
            newUser.username = createForm.cleaned_data['username']
            newUser.email = createForm.cleaned_data['email']
            newUser.password = createForm.cleaned_data['password']
            newUser.save()
            return HttpResponseRedirect('/')
    else:
        if request.method == "POST":
            form = LoginForm(request.POST)
            if form.is_valid():
                userN = form.cleaned_data['username'].lower()
                user = authenticate(username=userN,
                                    password=form.cleaned_data['password'])
                if user is not None:
                    login(request, user)
                else:
                    raise forms.ValidationError("Please Enter a username")
                return HttpResponseRedirect('/')
    #for the main webpage
    tablets = m.Tablet.objects.get(name="KUG03-obv-01")
    characters = m.AssyrianChar.objects.filter(Tablet_id=tablets.id)
    sign = m.Sign.objects.all()[:20]
    #only get identified characters if user is logged in
    if request.user.is_authenticated():
        identifiedChars = m.IdentifiedCharacter.objects.filter(
            user=request.user)
        if not identifiedChars:
            identifiedChars = 'no characters'
    else:
        identifiedChars = 'no characters'

    tvars = {
        'tablets': tablets,
        'sign': sign,
        'form': form,
        'createForm': createForm,
        'identifiedChars': identifiedChars,
        'characters': characters,
    }
    return templater.render_to_response(request, 'hotspots.html', tvars)
Exemplo n.º 4
0
def process_request(request):
    if request.urlparams[0] == "logout":
        logout(request)
        return HttpResponseRedirect('/')
    if request.user.is_authenticated():
        return HttpResponseRedirect('/homePage/hotspots')
    form = LoginForm()
    createForm = CreateUserForm()
    if request.urlparams[0] == "1":
        createForm = CreateUserForm(request.POST)
        if createForm.is_valid():
            newUser = m.User()
            newUser.username = createForm.cleaned_data['username']
            newUser.email = createForm.cleaned_data['email']
            newUser.password = createForm.cleaned_data['password']
            newUser.save()
            return HttpResponseRedirect('/homePage/tutorial')
    else:
        if request.method == "POST":
            form = LoginForm(request.POST)
            if form.is_valid():
                userN = form.cleaned_data['username'].lower()
                user = authenticate(username = userN, password = form.cleaned_data['password'])
                if user is not None:
                    login(request, user)
                else:
                    raise forms.ValidationError("Please Enter a username") 
                return HttpResponseRedirect('/')
    if request.urlparams[0] == "about":
        tvars = {
            #'tablets': tablets,
            'form' : form,
            'createForm' : createForm,
        }
        return templater.render_to_response(request, 'about.html', tvars)
    if request.user.is_authenticated():
        identifiedChars = m.IdentifiedCharacter.objects.filter(user = request.user)
    else:
        identifiedChars = 'no characters'
    tvars = {
        #'tablets': tablets,
        'form' : form,
        'createForm' : createForm,
        'identifiedChars' : identifiedChars,
	}
    return templater.render_to_response(request, 'index.html', tvars)
Exemplo n.º 5
0
def process_request(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login')
    if request.urlparams[0] == "logout":
        logout(request)
        return HttpResponseRedirect('/')
    form = LoginForm()
    createForm = CreateUserForm()
    if request.urlparams[0] == "1":
        createForm = CreateUserForm(request.POST)
        if createForm.is_valid():
            newUser = m.User()
            newUser.username = createForm.cleaned_data['username']
            newUser.email = createForm.cleaned_data['email']
            newUser.password = createForm.cleaned_data['password']
            newUser.save()
            return HttpResponseRedirect('/')
    else:
        if request.method == "POST":
            form = LoginForm(request.POST)
            if form.is_valid():
                userN = form.cleaned_data['username'].lower()
                user = authenticate(username=userN,
                                    password=form.cleaned_data['password'])
                if user is not None:
                    login(request, user)
                else:
                    raise forms.ValidationError("Please Enter a username")
                return HttpResponseRedirect('/')
    #for the main webpage
    tablets = m.Tablet.objects.get(name="VS 26 47")
    # for x in range(1,15):
    #     lines = m.Line()
    #     lines.tablet = tablets
    #     lines.side = "obv"
    #     lines.lineNumber = x
    #     lines.save()

    # newTablet = m.Tablet()
    # newTablet.name = 'VS 26 47'
    # newTablet.imagePath = '/static/homepage/images/VS_26_47.png'
    # newTablet.save()
    # newChar = m.MatchingCharacter()
    # newChar.filepath = "/static/homepage/images/8-01.png"
    # newChar.name = "8-01"
    # newChar.mimeType = "8-01"
    # newChar.save()
    #line = m.Line.objects.get(lineNumber = 1)
    characters = m.AssyrianChar.objects.filter(line=2)
    sign = m.Sign.objects.all()[:20]
    #only get identified characters if user is logged in
    if request.user.is_authenticated():
        identifiedChars = m.IdentifiedCharacter.objects.filter(
            user=request.user)
        if not identifiedChars:
            identifiedChars = 'no characters'
    else:
        identifiedChars = 'no characters'

    tvars = {
        'tablets': tablets,
        'sign': sign,
        'form': form,
        'createForm': createForm,
        'identifiedChars': identifiedChars,
        'characters': characters,
    }
    return templater.render_to_response(request, 'hotspots.html', tvars)