def anything(request, path): error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'), path) context = { 'message' : '<h1>The page doesn\'t seem to exist !</h1>', 'visitors' : 'Error' } return render(request, 'error.html', context)
def anything(request, path): error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'), path) context = { 'message' : '<h1>The page doesn\'t seem to exist !</h1>', 'visitors' : 'Error' } return render(request, 'error.html', context)
def project_handler(request, name): #Fetch project details from database try: proj = project.objects.get(folder = name, display_rank__gt=0) temp = os.path.join(os.path.join(settings.STATICFILES_DIRS[0], 'images'), 'projects') images_folder = os.path.join(temp, name) images = [] for image in os.listdir(images_folder): images.append('images/projects/' + name + '/' + image) vis = project_visit(ip=get_client_ip(request), user_agent=request.META.get('HTTP_USER_AGENT'), project=proj) vis.save() context = { 'page' : 'portofolio', 'project' : proj, 'images' : images, 'visitors' : project_visit.objects.filter(project=proj) .values('ip').distinct().count() } return render(request, name + '.html', context) except ObjectDoesNotExist: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + name) context = { 'message' : '''<h1>I have no knowledge about this project ! </h1> <h3 class="subheader"> <a href="/portofolio">Click here</a> to view all my projects ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context) except OSError: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + name) context = { 'message' : '''<h1>Page Currently Unavailable! </h1> <h3 class="subheader">The page is being updated ! Check back later !</h3> <h3 class="subheader"> <a href="/portofolio">Click here</a> to view all my projects ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context)
def project_handler(request, name): #Fetch project details from database try: proj = project.objects.get(folder = name, display_rank__gt=0) temp = os.path.join(os.path.join(settings.STATICFILES_DIRS[0], 'images'), 'projects') images_folder = os.path.join(temp, name) images = [] for image in os.listdir(images_folder): images.append('images/projects/' + name + '/' + image) vis = project_visit(ip=get_client_ip(request), user_agent=request.META.get('HTTP_USER_AGENT'), project=proj) vis.save() context = { 'page' : 'portofolio', 'project' : proj, 'images' : images, 'visitors' : project_visit.objects.filter(project=proj) .values('ip').distinct().count() } return render(request, name + '.html', context) except ObjectDoesNotExist: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + name) context = { 'message' : '''<h1>I have no knowledge about this project ! </h1> <h3 class="subheader"> <a href="/portofolio">Click here</a> to view all my projects ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context) except OSError: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + name) context = { 'message' : '''<h1>Page Currently Unavailable! </h1> <h3 class="subheader">The page is being updated ! Check back later !</h3> <h3 class="subheader"> <a href="/portofolio">Click here</a> to view all my projects ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context)
def blog_post(request, post_name): try: post = blog.objects.get(template_file=post_name) vis = blog_visit(ip=get_client_ip(request), user_agent=request.META.get('HTTP_USER_AGENT'), blog=post) vis.save() context = { 'page': 'blog', 'post': post, 'visitors': blog_visit.objects.filter( blog=post).values('ip').distinct().count() } return render(request, os.path.join('blog', post_name) + '.html', context) except ObjectDoesNotExist: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'), 'project/' + post_name) context = { 'message': '''<h1>I have not posted any such article ! </h1> <h3 class="subheader"> <a href="/blog">Click here</a> to view all my post ! </h3>''', 'visitors': 'Error' } return render(request, 'error.html', context) except OSError: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'), 'project/' + post_name) context = { 'message': '''<h1>Page Currently Unavailable! </h1> <h3 class="subheader">The page is being updated ! Check back later !</h3> <h3 class="subheader"> <a href="/blog">Click here</a> to view my blog ! </h3>''', 'visitors': 'Error' } return render(request, 'error.html', context)
def blog_post(request, post_name): try: post = blog.objects.get(template_file=post_name) vis = blog_visit(ip=get_client_ip(request), user_agent=request.META.get('HTTP_USER_AGENT'), blog=post) vis.save() context = { 'page' : 'blog', 'post' : post, 'visitors' : blog_visit.objects.filter(blog=post) .values('ip').distinct().count() } return render(request, os.path.join('blog', post_name) + '.html', context) except ObjectDoesNotExist: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + post_name) context = { 'message' : '''<h1>I have not posted any such article ! </h1> <h3 class="subheader"> <a href="/blog">Click here</a> to view all my post ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context) except OSError: error_404_visit.record_error(get_client_ip(request), request.META.get('HTTP_USER_AGENT'),'project/' + post_name) context = { 'message' : '''<h1>Page Currently Unavailable! </h1> <h3 class="subheader">The page is being updated ! Check back later !</h3> <h3 class="subheader"> <a href="/blog">Click here</a> to view my blog ! </h3>''', 'visitors' : 'Error' } return render(request, 'error.html', context)