def get(self, request, *args, **kwargs): try: context = self.get_context_data(**kwargs) return self.render_to_response(context) except ObjectDoesNotExist, e: name = kwargs['name'] return responseutils.getHttpResponseNotFoundHTML( '%s Not Found' % name, request.user, name, urlutils.getOperatingSystemURL(name))
def get(self, request, *args, **kwargs): try: context = self.get_context_data(**kwargs) return self.render_to_response(context) except ObjectDoesNotExist: ref = kwargs['ref'] return responseutils.getHttpResponseNotFoundHTML( '%s Not Found' % ref, request.user, ref, urlutils.getComponentURL(ref))
def createReview(request, ref): try: datautils.createComponentReview(ref, request.user, request.POST['rating'], request.POST['comment']) return HttpResponseRedirect(urlutils.getComponentURL(ref)) except ObjectDoesNotExist: return responseutils.getHttpResponseNotFoundHTML('%s Not Found' % ref, request.user, ref, urlutils.getComponentURL(ref))
def registerUser(request): if request.method == 'POST': uf = UserCreationForm(request.POST, prefix='user') upf = forms.UserProfileForm(request.POST, prefix='userprofile') if uf.is_valid() and upf.is_valid(): user = uf.save() userprofile = upf.save(commit=False) userprofile.user = user userprofile.save() # Get form user data to automatically authenticate it authuser = authenticate(username = request.POST['user-username'], password = request.POST['user-password1']) login(request, authuser) return HttpResponseRedirect(urlutils.getUserURL()) else: context = { 'pagetitle' : 'New User Registration', 'userform' : uf, 'userprofileform' : upf, 'csrf_token' : csrf.get_token(request) } response_str = render_to_string('registration/register.html', context) return HttpResponse(response_str, content_type='text/html') elif request.method == 'GET': uf = UserCreationForm(prefix='user') upf = forms.UserProfileForm(prefix='userprofile') context = { 'pagetitle' : 'New User Registration', 'userform' : uf, 'userprofileform' : upf, 'csrf_token' : csrf.get_token(request) } response_str = render_to_string('registration/register.html', context) return HttpResponse(response_str, content_type='text/html') else: return responseutils.getHttpResponseNotFoundHTML('WTF', request.user, 'YOU', 'JERK')