доделал страницу выбора мест, изменил базу
This commit is contained in:
parent
b116bc18b9
commit
72e025bb34
@ -7,7 +7,7 @@
|
|||||||
border-radius: 3vw;
|
border-radius: 3vw;
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 46%;
|
width: 46%;
|
||||||
max-height: 50vw;
|
max-height: 50vw !important ;
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -15,6 +15,7 @@
|
|||||||
}
|
}
|
||||||
.table_card {
|
.table_card {
|
||||||
margin: 3vw;
|
margin: 3vw;
|
||||||
|
margin-top: 1.5vw;
|
||||||
}
|
}
|
||||||
.seat_checkbox {
|
.seat_checkbox {
|
||||||
display: none;
|
display: none;
|
||||||
@ -34,8 +35,9 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.buy_btn {
|
.buy_btn {
|
||||||
float: bottom;
|
margin-top: 2vw;
|
||||||
margin-top: 1.5vw;
|
margin-left: 2vw;
|
||||||
|
margin-right: 2vw;
|
||||||
}
|
}
|
||||||
.ticket_film_image {
|
.ticket_film_image {
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
@ -105,4 +107,14 @@
|
|||||||
.film_info_description::-webkit-scrollbar-thumb {
|
.film_info_description::-webkit-scrollbar-thumb {
|
||||||
background-color: #eaeaea;
|
background-color: #eaeaea;
|
||||||
border-radius: 5vw;
|
border-radius: 5vw;
|
||||||
|
}
|
||||||
|
.horizontal_line {
|
||||||
|
margin-left: 2vw;
|
||||||
|
margin-right: 2vw;
|
||||||
|
border-top: 10px solid;
|
||||||
|
}
|
||||||
|
.display_title {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.2vw;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
document.querySelectorAll('.seat_checkbox').forEach(function(checkbox) {
|
document.querySelectorAll('.seat_checkbox').forEach(function(checkbox) {
|
||||||
checkbox.addEventListener('change', function() {
|
checkbox.addEventListener('change', function() {
|
||||||
var filmSession = checkbox.closest('.film_session');
|
var filmSession = checkbox.closest('.film_session');
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
@ -7,4 +7,31 @@
|
|||||||
filmSession.classList.remove('selected');
|
filmSession.classList.remove('selected');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const form = document.querySelector('.seats_card');
|
||||||
|
const checkboxes = form.querySelectorAll('.seat_checkbox');
|
||||||
|
const buyButton = form.querySelector('.buy_btn');
|
||||||
|
|
||||||
|
function checkSelected() {
|
||||||
|
let atLeastOneSelected = false;
|
||||||
|
checkboxes.forEach(function(checkbox) {
|
||||||
|
if (checkbox.checked) {
|
||||||
|
atLeastOneSelected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (atLeastOneSelected) {
|
||||||
|
buyButton.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
buyButton.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkboxes.forEach(function(checkbox) {
|
||||||
|
checkbox.addEventListener('change', checkSelected);
|
||||||
|
});
|
||||||
|
|
||||||
|
checkSelected();
|
||||||
|
});
|
||||||
|
|||||||
@ -23,7 +23,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form class="seats_card" method="post" style="height: {{ height }}vw;">
|
<form class="seats_card" method="post" style="height: {{ height }}vw;">
|
||||||
|
<button type="submit" class="btn btn-primary buy_btn">Купить билет</button>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<hr class="horizontal_line">
|
||||||
|
<p class="display_title">Экран</p>
|
||||||
<table class="table_card">
|
<table class="table_card">
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for row in session.auditorium.rows.all %}
|
{% for row in session.auditorium.rows.all %}
|
||||||
@ -43,6 +46,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
<button type="submit" class="btn btn-primary buy_btn">Купить билет</button>
|
|
||||||
<script src="{% static 'js/timetable/session.js' %}"></script>
|
<script src="{% static 'js/timetable/session.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
# Generated by Django 4.2 on 2024-04-20 17:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("timetable", "0006_remove_auditorium_row_count"),
|
||||||
|
("users", "0003_remove_profile_genres_profile_genres"),
|
||||||
|
("tickets", "0005_alter_ticket_options_alter_ticket_table"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="ticket",
|
||||||
|
name="profile",
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="ticket",
|
||||||
|
name="session",
|
||||||
|
),
|
||||||
|
migrations.AlterModelTable(
|
||||||
|
name="ticket",
|
||||||
|
table="tickets_tickets",
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Order",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"datetime_order",
|
||||||
|
models.DateField(
|
||||||
|
help_text="Дата и время оформления заказа",
|
||||||
|
verbose_name="Дата и время оформления заказа",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"profile",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="orders",
|
||||||
|
related_query_name="orders",
|
||||||
|
to="users.profile",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"session",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="orders",
|
||||||
|
related_query_name="orders",
|
||||||
|
to="timetable.filmsession",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Заказ",
|
||||||
|
"verbose_name_plural": "Заказы",
|
||||||
|
"db_table": "tickets_orders",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="ticket",
|
||||||
|
name="order",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
default="",
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="tickets",
|
||||||
|
related_query_name="tickets",
|
||||||
|
to="tickets.order",
|
||||||
|
),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -1,21 +1,40 @@
|
|||||||
from django.db.models import ForeignKey, CASCADE, Model, IntegerField
|
from django.db.models import ForeignKey, CASCADE, Model, IntegerField, DateField
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
|
|
||||||
from timetable.models import FilmSession
|
from timetable.models import FilmSession
|
||||||
from users.models import Profile
|
from users.models import Profile
|
||||||
|
|
||||||
|
|
||||||
class Ticket(Model):
|
class Order(Model):
|
||||||
session = ForeignKey(
|
session = ForeignKey(
|
||||||
FilmSession,
|
FilmSession,
|
||||||
on_delete=CASCADE,
|
on_delete=CASCADE,
|
||||||
related_name='tickets',
|
related_name='orders',
|
||||||
related_query_name='tickets',
|
related_query_name='orders',
|
||||||
)
|
)
|
||||||
|
|
||||||
profile = ForeignKey(
|
profile = ForeignKey(
|
||||||
Profile,
|
Profile,
|
||||||
on_delete=CASCADE,
|
on_delete=CASCADE,
|
||||||
|
related_name='orders',
|
||||||
|
related_query_name='orders',
|
||||||
|
)
|
||||||
|
|
||||||
|
datetime_order = DateField(
|
||||||
|
verbose_name='Дата и время оформления заказа',
|
||||||
|
help_text='Дата и время оформления заказа',
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'tickets_orders'
|
||||||
|
verbose_name = 'Заказ'
|
||||||
|
verbose_name_plural = 'Заказы'
|
||||||
|
|
||||||
|
|
||||||
|
class Ticket(Model):
|
||||||
|
order = ForeignKey(
|
||||||
|
Order,
|
||||||
|
on_delete=CASCADE,
|
||||||
related_name='tickets',
|
related_name='tickets',
|
||||||
related_query_name='tickets',
|
related_query_name='tickets',
|
||||||
)
|
)
|
||||||
@ -35,6 +54,6 @@ class Ticket(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'tickets_ticket'
|
db_table = 'tickets_tickets'
|
||||||
verbose_name = 'Билет'
|
verbose_name = 'Билет'
|
||||||
verbose_name_plural = 'Билеты'
|
verbose_name_plural = 'Билеты'
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 4.2 on 2024-04-20 16:49
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("timetable", "0005_filmsession_end_datetime"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="auditorium",
|
||||||
|
name="row_count",
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -48,10 +48,6 @@ def session_view(request, sess_id):
|
|||||||
id=sess_id,
|
id=sess_id,
|
||||||
)
|
)
|
||||||
height = round(session.auditorium.rows.count() * 4 + 7)
|
height = round(session.auditorium.rows.count() * 4 + 7)
|
||||||
row_with_most_seats = Row.objects.filter(auditorium=session.auditorium).only('column_count').annotate(
|
|
||||||
max_seats=Max('column_count')
|
|
||||||
).order_by('-max_seats').first()
|
|
||||||
width = round(row_with_most_seats.column_count * 4 + 3)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = SeatSelectionForm(request.POST, auditorium=session.auditorium)
|
form = SeatSelectionForm(request.POST, auditorium=session.auditorium)
|
||||||
@ -65,7 +61,6 @@ def session_view(request, sess_id):
|
|||||||
'session': session,
|
'session': session,
|
||||||
'height': height,
|
'height': height,
|
||||||
'form': form,
|
'form': form,
|
||||||
'width': width
|
|
||||||
}
|
}
|
||||||
template = 'timetable/session.html'
|
template = 'timetable/session.html'
|
||||||
return render(request, template, context)
|
return render(request, template, context)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user