Example #1
0
def bookadmin(request):
    if not request.user.is_authenticated():
        return redirect("/")
    elif not request.user.is_superuser:
        return redirect("/")

    books = models.Book.objects.all()

    columns = divide_into_columns(4, books)

    context = {"col_1": columns[0], "col_2": columns[1], "col_3": columns[2], "col_4": columns[3], "books": books}

    return render(request, "cobalt/bookadmin.html", context)
Example #2
0
def userpublicprofile(request, username):
    user = get_object_or_404(models.User, username=username)
    user_art = models.Art.objects.filter(user=user).all()

    columns = divide_into_columns(4, user_art)

    context = {
        'user': user,
        'user_art': user_art,
        "col_1": columns[0],
        "col_2": columns[1],
        "col_3": columns[2],
        "col_4": columns[3],
    }
    return render(request, 'cobalt/userpublicprofile.html', context)
Example #3
0
def index(request):
    template = loader.get_template('cobalt/index.html')

    book_count = models.Book.objects.count()

    # 3 popular pieces of art that have a scene attached (i.e not a generic)
    all_media = list(models.Art.objects.all())
    all_media.extend(list(models.Book.front_page.all()))
    shuffle(all_media)

    columns = divide_into_columns(4, all_media)

    context = {
        "col_1": columns[0],
        "col_2": columns[1],
        "col_3": columns[2],
        "col_4": columns[3],
        "book_count": book_count,
    }
    return render(request, 'cobalt/index.html', context)