Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Hometask for lesson 6 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 21 additions & 42 deletions catalog/templates/catalog/detail.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Книжный магазин</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<header>
<nav class="nav">
<a href="#" class="nav__bar fa fa-solid bar"></a>
<a href="/" class="nav__logo">Книжный магазин</a>
<div class="spring"></div>
<a href="#" class="nav__basket fa fa-solid basket"></a>
</nav>
</header>
<main>
<div>
<div class="main">
<div class="main__book">
<div class="book-detail">
<div class="book-detail__cover book-detail-cover">
<img class="book-detail-cover__img" src="/static/books/lutz.png" alt="Название книги" >
</div>
<div class="book-detail__content">
<div class="book-detail-property">Название: <i>Нащвние книги</i></div>
<div class="book-detail-property">Название на английском: <i>Book name</i></div>
<div class="book-detail-property">Автор: <i>Автор</i></div>
<div class="book-detail-property">Количество страниц: <i>256</i></div>
<div class="book-detail-property">Год выпуска: <i>2018</i></div>
<div class="book-detail-description">Описание книги</div>
</div>
</div>
{% extends 'base.html' %}
{% load static %}

{% block content %}
<div>
<div class="main">
<div class="main__book">
<div class="book-detail">
<div class="book-detail__cover book-detail-cover">
<img class="book-detail-cover__img" src="{% static book.cover %}" alt="Название книги" >
</div>
<div class="book-detail__content">
<div class="book-detail-property">Название: <i>{{ book.name }}</i></div>
<div class="book-detail-property">Название на английском: <i>{{ book.name_eng }}</i></div>
<div class="book-detail-property">Автор: <i>{{ book.author }}</i></div>
<div class="book-detail-property">Количество страниц: <i>{{ book.pages }}</i></div>
<div class="book-detail-property">Год выпуска: <i>{{ book.pub_year }}</i></div>
<div class="book-detail-description">{{ book.description }}</div>
</div>
</div>
</div>
</main>
<footer>
<div class="footer">
<a href="#" class="footer__name">Курсы по питону 2018</a>
<div class="spring"></div>
<a href="mailto:[email protected]" class="footer__mailto">[email protected]</a>
</div>
</footer>
</body>
</html>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.shortcuts import render
from catalog.data import BOOKS


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def detail(request, id):
books = list(filter(lambda b: b['id'] == id, BOOKS))
if len(books) == 0:
Expand Down
56 changes: 20 additions & 36 deletions main/templates/main/index.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>Книжный магазин</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<header>
<nav class="nav">
<a href="#" class="nav__bar fa fa-solid bar"></a>
<a href="/" class="nav__logo">Книжный магазин</a>
<div class="spring"></div>
<a href="#" class="nav__basket fa fa-solid basket"></a>
</nav>
</header>
<main>
{% extends 'base.html' %}
{% load static %}

{% block content %}
<div>
<div class="main">
<div class="main__book">
{% for book in books %}
<div class="book-preview">
<img class="book-preview__img" src="/static/books/lutz.png" alt="Название книги">
<div class="book-preview__name">Название</div>
<div class="spring"></div>
<div class="book-preview__author">Автор</div>
<a href="/">Подробнее</a>
<div class="spring"></div>
<div class="book-preview-order">
<div class="book-preview-order__order button">Заказать</div>
<div class="book-preview-order__order button button--disable">Нет в наличии</div>
</div>
<img class="book-preview__img" alt="Название книги" src="{% static book.cover %}">
<div class="book-preview__name">{{ book.name }}</div>
<div class="spring"></div>
<div class="book-preview__author">{{ book.author }}</div>
<a href="{% url 'market-catalog-detail' book.id %}">Подробнее</a>
<div class="spring"></div>
<div class="book-preview-order">
{% if book.is_available %}
<div class="book-preview-order__order button">Заказать</div>
{% else %}
<div class="book-preview-order__order button button--disable">Нет в наличии</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</main>
<footer>
<div class="footer">
<a href="#" class="footer__name">Курсы по питону 2018</a>
<div class="spring"></div>
<a href="mailto:[email protected]" class="footer__mailto">[email protected]</a>
</div>
</footer>
</body>
</html>
{% endblock %}
2 changes: 1 addition & 1 deletion market/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down
28 changes: 28 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Книжный магазин</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/fonts.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<header>
<nav class="nav">
<a href="#" class="nav__bar fa fa-solid bar"></a>
<a href="/" class="nav__logo">Книжный магазин</a>
<div class="spring"></div>
<a href="#" class="nav__basket fa fa-solid basket"></a>
</nav>
</header>
<main>{% block content %}{% endblock %}</main>
<footer>
<div class="footer">
<a href="#" class="footer__name">Курсы по питону 2018</a>
<div class="spring"></div>
<a href="mailto:[email protected]" class="footer__mailto">[email protected]</a>
</div>
</footer>
</body>
</html>