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('/')
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))
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))
def about_us(request): return render_to_response('about_us.html', content.genSuper())
def logout(request): auth_logout(request) context = content.genSuper() context = content.addSubTitleStrings(context) return render_to_response('loggedOutBase.html', content.addGoodLogoutNoti(context))
def invalid_login(request): c = {} c.update(csrf(request)) c.update(content.genSuper()) return render_to_response('login.html', content.addFailedLoginNoti(c))
def login(request): c = {} c.update(csrf(request)) c.update(content.genSuper()) return render_to_response('login.html',c)