Пример #1
0
def user_register(request):
    if request.user.is_anonymous():
        if request.method == 'POST':
            form = UserRegistrationForm(request.POST)
            if form.is_valid():
                userAccount = form.save()
                user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1'])
                if user is not None:
                    login(request, user)
                #send confirmation email
                sendMail(profileUtil.getProfileFromUser(userAccount), \
                    "Welcome aboard! ", "Thank you for registering with ToolCloud.")
                shedName = form.cleaned_data['username'] + "'s Shed"
                userProfile = profileUtil.getProfileFromUser(userAccount)
                newShedObject = Shed(name=shedName, owner=userProfile, location='location', sharezone=form.cleaned_data['zip_code'],\
                    status='status')
                newShedObject.save()
                newShedObject.members.add(userProfile)
                newShedObject.admins.add(userProfile)
                newShedObject.save()
                userProfile.personalShed = newShedObject
                context = {}
                context.update(content.genUserHome(request))
                context.update(content.addGoodRegisterNoti(dict()))
                return render_to_response('userHome.html', context)
        else:
            form = UserRegistrationForm()
        context = {}
        context.update(csrf(request))
        context['form'] = form
        context.update(content.genSuper())
        #Pass the context to a template
        return render_to_response('register.html', context)
    else:
        return HttpResponseRedirect('/')
Пример #2
0
def home(request):
    file = open("homePageText.txt", "r")
    strings = file.readlines()
    context = {}
    context['strings'] = strings
    context.update(content.genSuper())
    if request.user.is_anonymous():
        return render(request, 'loggedOutBase.html', context)
    return render_to_response('userHome.html', content.genUserHome(request))
Пример #3
0
def home(request):
    file = open("homePageText.txt","r")
    strings = file.readlines()
    context = {}
    context['strings'] = strings
    context.update(content.genSuper())
    if request.user.is_anonymous():
        return render(request, 'loggedOutBase.html', context)
    return render_to_response('userHome.html', content.genUserHome(request))
Пример #4
0
def user_register(request):
    if request.user.is_anonymous():
        if request.method == 'POST':
            form = UserRegistrationForm(request.POST)
            if form.is_valid():
                userAccount = form.save()
                user = authenticate(username=form.cleaned_data['username'],
                                    password=form.cleaned_data['password1'])
                if user is not None:
                    login(request, user)
                #send confirmation email
                sendMail(profileUtil.getProfileFromUser(userAccount), \
                    "Welcome aboard! ", "Thank you for registering with ToolCloud.")
                shedName = form.cleaned_data['username'] + "'s Shed"
                userProfile = profileUtil.getProfileFromUser(userAccount)
                newShedObject = Shed(name=shedName, owner=userProfile, location='location', sharezone=form.cleaned_data['zip_code'],\
                    status='status')
                newShedObject.save()
                newShedObject.members.add(userProfile)
                newShedObject.admins.add(userProfile)
                newShedObject.save()
                userProfile.personalShed = newShedObject
                context = {}
                context.update(content.genUserHome(request))
                context.update(content.addGoodRegisterNoti(dict()))
                return render_to_response('userHome.html', context)
        else:
            form = UserRegistrationForm()
        context = {}
        context.update(csrf(request))
        context['form'] = form
        context.update(content.genSuper())
        #Pass the context to a template
        return render_to_response('register.html', context)
    else:
        return HttpResponseRedirect('/')
Пример #5
0
def about_us(request):
    return render_to_response('about_us.html', content.genSuper())
Пример #6
0
def logout(request):
	auth_logout(request)
	context = content.genSuper()
	context = content.addSubTitleStrings(context)
	return render_to_response('loggedOutBase.html', content.addGoodLogoutNoti(context))
Пример #7
0
def invalid_login(request):
	c = {}
	c.update(csrf(request))
	c.update(content.genSuper())
	return render_to_response('login.html', content.addFailedLoginNoti(c))
Пример #8
0
def login(request):
	c = {}
	c.update(csrf(request))
	c.update(content.genSuper())
	return render_to_response('login.html',c)
Пример #9
0
def about_us(request):
    return render_to_response('about_us.html', content.genSuper())