From 74cba0aefabb3e103ea5577556546a28a132ac12 Mon Sep 17 00:00:00 2001 From: andrei Date: Fri, 19 Apr 2024 18:55:58 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B2=D0=B0=D1=80=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=83=D1=8E=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=81=20=D1=84=D0=B8=D0=BB=D1=8C=D0=BC=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CineSync/films/models.py | 12 +++++- CineSync/films/views.py | 2 +- CineSync/static/css/films/films_list.css | 51 ++++++++++++++++++++++++ CineSync/static/css/home/homepage.css | 3 ++ CineSync/templates/films/films_list.html | 24 ++++++++++- CineSync/templates/home/homepage.html | 7 ++-- CineSync/templates/users/profile.html | 2 +- 7 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 CineSync/static/css/films/films_list.css diff --git a/CineSync/films/models.py b/CineSync/films/models.py index 41c9d7b..bbfc5d5 100644 --- a/CineSync/films/models.py +++ b/CineSync/films/models.py @@ -8,7 +8,7 @@ from django.db.models import ( IntegerField, DateField, ManyToManyField, - Manager, ImageField, + Manager, ImageField, Min, ) from django.utils import timezone from django.core.validators import MinValueValidator @@ -22,6 +22,16 @@ class FilmManager(Manager): release_date__lt=timezone.now(), ) + def will_be_shown(self): + current_datetime = timezone.now() + films_with_sessions = super().get_queryset().filter( + sessions__start_datetime__gte=current_datetime, + ).annotate( + nearest_session=Min('sessions__start_datetime') + ).order_by('nearest_session') + + return films_with_sessions + def on_main(self): current_datetime = timezone.now() end_datetime = current_datetime + timedelta(days=5) diff --git a/CineSync/films/views.py b/CineSync/films/views.py index 117f9ec..c3346af 100644 --- a/CineSync/films/views.py +++ b/CineSync/films/views.py @@ -5,7 +5,7 @@ from films.models import Film def films_list(request: HttpResponse) -> HttpResponse: - films = Film.objects.released() + films = Film.objects.will_be_shown() return render( request, 'films/films_list.html', diff --git a/CineSync/static/css/films/films_list.css b/CineSync/static/css/films/films_list.css new file mode 100644 index 0000000..0bb2953 --- /dev/null +++ b/CineSync/static/css/films/films_list.css @@ -0,0 +1,51 @@ +.film_preview_card { + width: 18vw; + height: 25vw; + margin: 1vw; + border-radius: 3vw; + display: flex; + align-items: flex-end; + justify-content: center; + background-size: cover; + background-position: center; + position: relative; +} + +.film_preview_card_text_block { + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 40%; + background-color: rgba(13, 29, 58, 0.8); + padding: 1vw; + border-bottom-left-radius: 3vw; + border-bottom-right-radius: 3vw; + color: #eaeaea; + opacity: 0; + transition: opacity 0.5s ease; +} + +.film_preview_card_text_block h3 { + margin-top: 0; + margin-bottom: 0.5vw; + font-size: 1.5vw; + font-weight: bold; +} + +.film_preview_card_text_block p { + margin-top: 0; + margin-bottom: 0; + font-size: 1vw; +} +.films_list { + width: 84%; + margin-left: 12%; + margin-right: 12%; +} +.films_block { + margin-top: 5vw; +} +.film_preview_card:hover .film_preview_card_text_block { + opacity: 1; +} \ No newline at end of file diff --git a/CineSync/static/css/home/homepage.css b/CineSync/static/css/home/homepage.css index 0facf6f..9e33a99 100644 --- a/CineSync/static/css/home/homepage.css +++ b/CineSync/static/css/home/homepage.css @@ -6,4 +6,7 @@ .carousel-item-next, .carousel-item-prev, .carousel-item.active { display: flex; justify-content: center; +} +.carousel_title { + margin-top: 5vw; } \ No newline at end of file diff --git a/CineSync/templates/films/films_list.html b/CineSync/templates/films/films_list.html index 63913c1..f712878 100644 --- a/CineSync/templates/films/films_list.html +++ b/CineSync/templates/films/films_list.html @@ -1 +1,23 @@ -{% extends "base.html" %} \ No newline at end of file +{% extends "base.html" %} +{% load static %} +{% block title %} +Фильмы +{% endblock title %} +{% block content %} + + +
+

Смотрите в прокате

+ +
+{% endblock %} \ No newline at end of file diff --git a/CineSync/templates/home/homepage.html b/CineSync/templates/home/homepage.html index 99d3804..a0896a5 100644 --- a/CineSync/templates/home/homepage.html +++ b/CineSync/templates/home/homepage.html @@ -65,12 +65,12 @@ aria-labelledby="tab-{{ date }}" aria-selected="{% if forloop.counter0 == 0 %} true {% else %} false {% endif %}"> {% for film, session in sessions.items %} -
+
{% if film.image %} Фотография фильма не найдена {% else %} - Картинки нет :( +

Картинки нет :(

{% endif %}
@@ -79,7 +79,7 @@ @@ -96,5 +96,4 @@
- {% endblock %} \ No newline at end of file diff --git a/CineSync/templates/users/profile.html b/CineSync/templates/users/profile.html index 291c499..16b327a 100644 --- a/CineSync/templates/users/profile.html +++ b/CineSync/templates/users/profile.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% load static %} -{% block title %}{{ user.username }}: изменить профиль{% endblock %} +{% block title %}{{ user.username }}: Профиль{% endblock %} {% block content %}