Example #1
0
def banner_site(request, name):
    try:
        file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'static_data/items.json'))
        banners = json.loads(open(file_path).read())

        file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'static_data/banner.json'))
        banner_list = json.loads(open(file_path).read())
    except:
        data = {'success': False, 'error_id': 2, 'error_msg:': 'IO Error', 'directory': file_path}
        return HttpResponse(json.dumps(data), 'application/json')

    if name in banners.keys():
        banner = json.dumps(banners[name])
    else:
        return render(request, '404.html', {'base_url': get_base_url()})

    return render(request, 'banner.html', {'base_url': get_base_url(), 'title': name.replace('-', ' ').title(), 'banner_name': name, 'banner': banner, 'banners': json.dumps(banner_list)})
Example #2
0
def error_page(request):
    try:
        file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'static_data/banner.json'))
        banners = json.loads(open(file_path).read())
    except:
        data = {'success': False, 'error_id': 2, 'error_msg:': 'IO Error', 'directory': file_path}
        return HttpResponse(json.dumps(data), 'application/json')

    return render(request, '404.html', {'base_url': get_base_url(), 'banners': json.dumps(banners)})
Example #3
0
def category(request, name):
    return render(request, 'category.html', {'base_url': get_base_url(), 'title': name.title()})
Example #4
0
def search(request):
    return render(request, 'result.html', {'base_url': get_base_url(), 'q': request.GET['q']})