From da83ae7afc6b0446ca21c366115469aed07b71a5 Mon Sep 17 00:00:00 2001 From: kikimor Date: Tue, 1 Jul 2025 11:43:16 +0300 Subject: [PATCH] Add IntelliJ IDEA project configuration files This commit adds IntelliJ IDEA-specific configuration files for the project, including module setup, version control integration, inspection profiles, and workspace settings. These files facilitate development environment configuration for contributors using IntelliJ IDEA. --- DepoT/urls.py | 1 + booking/forms.py | 19 ++++++++++ booking/models.py | 3 +- booking/urls.py | 7 ++++ booking/views.py | 37 +++++++++++++++---- containers/models.py | 2 +- templates/client-base.html | 2 +- templates/client-booking-content.html | 19 ++++++---- .../{sidebar.html => client-sidebar.html} | 6 +-- 9 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 booking/forms.py create mode 100644 booking/urls.py rename templates/{sidebar.html => client-sidebar.html} (94%) diff --git a/DepoT/urls.py b/DepoT/urls.py index 09540d6..6a78f4e 100644 --- a/DepoT/urls.py +++ b/DepoT/urls.py @@ -24,4 +24,5 @@ urlpatterns = [ path('user/', include('accounts.urls')), path('preinfo/', include('preinfo.urls')), path('container/', include('containers.urls')), + path('booking/', include('booking.urls')), ] diff --git a/booking/forms.py b/booking/forms.py new file mode 100644 index 0000000..4a3b74d --- /dev/null +++ b/booking/forms.py @@ -0,0 +1,19 @@ +from django import forms + +from booking.models import Booking + + +class BookingBaseForm(forms.ModelForm): + """ + Base form for booking-related forms. + This can be extended by other booking forms. + """ + + class Meta: + fields = '__all__' + model = Booking + +class BookingCreateForm(BookingBaseForm): + + class Meta(BookingBaseForm.Meta): + fields = ['number', 'vehicles', 'container_type', 'container_count', 'carrier', 'line', 'container_number'] diff --git a/booking/models.py b/booking/models.py index 1b168d1..a8e4262 100644 --- a/booking/models.py +++ b/booking/models.py @@ -2,7 +2,7 @@ from django.db import models from common.models import ContainerTypeModel, LinesModel, OperationModel # Create your models here. -class BookingModel(models.Model): +class Booking(models.Model): number = models.CharField(max_length=50, unique=True) vehicles = models.CharField(blank=True, null=True) container_type = models.ForeignKey( @@ -11,6 +11,7 @@ class BookingModel(models.Model): related_name='booking_container_types', ) container_count = models.IntegerField() + container_expedited_count = models.IntegerField(default=0) carrier = models.CharField(max_length=100, blank=True, null=True) line = models.ForeignKey( LinesModel, diff --git a/booking/urls.py b/booking/urls.py new file mode 100644 index 0000000..d411529 --- /dev/null +++ b/booking/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from booking.views import CreateBookingView + +urlpatterns = [ + path('client/', CreateBookingView.as_view(), name='client_booking'), +] \ No newline at end of file diff --git a/booking/views.py b/booking/views.py index 2e779ca..396ad54 100644 --- a/booking/views.py +++ b/booking/views.py @@ -1,14 +1,35 @@ from django.shortcuts import render +from django.urls import reverse_lazy from django.views.generic import CreateView +from booking.forms import BookingCreateForm +from booking.models import Booking +from common.utils import filter_queryset_by_user + # Create your views here. class CreateBookingView(CreateView): - template_name = 'create-booking.html' - extra_context = { - 'title': 'Create Booking', - 'description': 'This is the create booking page.', - } - - def get(self, request, *args, **kwargs): - return render(request, self.template_name, self.extra_context) \ No newline at end of file + template_name = 'client-booking-content.html' + model = Booking + form_class = BookingCreateForm + success_url = reverse_lazy('dashboard') + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + queryset = self.model.objects.all().order_by('-created_on') + user = self.request.user +# !!! important + queryset = filter_queryset_by_user( queryset, user)[:10] +# !!! important + + context['recent'] = queryset + return context + + + def form_valid(self, form): + # todo more validation + form.instance.created_by = self.request.user.id + form.instance.updated_by = self.request.user.id + if self.request.user.line: + form.instance.line = self.request.user.line + return super().form_valid(form) \ No newline at end of file diff --git a/containers/models.py b/containers/models.py index ae4b11a..976630d 100644 --- a/containers/models.py +++ b/containers/models.py @@ -43,7 +43,7 @@ class Container(models.Model): null=True ) booking = models.ForeignKey( - 'booking.BookingModel', + 'booking.Booking', on_delete=models.CASCADE, related_name='container_bookings', blank = True, diff --git a/templates/client-base.html b/templates/client-base.html index 8790747..7b379df 100644 --- a/templates/client-base.html +++ b/templates/client-base.html @@ -60,7 +60,7 @@ - {% include 'sidebar.html' %} + {% include 'client-sidebar.html' %}
diff --git a/templates/client-booking-content.html b/templates/client-booking-content.html index 0b12224..bc18e85 100644 --- a/templates/client-booking-content.html +++ b/templates/client-booking-content.html @@ -10,7 +10,7 @@
- {{ form.as_p }} + {{ form }} {% csrf_token %}
@@ -31,19 +31,24 @@ - + + - + +{# #} + - {% for preinfo in recent %} + {% for booking in recent %} - - - + + + + +
ContainerBooking №Container № TypeEst. ArrivalContainer countVehiclesVehicles Status Actions
{{ preinfo.container_number }}{{ preinfo.container_type }}{{ preinfo.created_on }}{{ booking.number }}{{ booking.container_number }}{{ booking.container_type }}{{ booking.container_count }}{{ booking.vehicles_left }} Pending diff --git a/templates/sidebar.html b/templates/client-sidebar.html similarity index 94% rename from templates/sidebar.html rename to templates/client-sidebar.html index a1b5803..0872187 100644 --- a/templates/sidebar.html +++ b/templates/client-sidebar.html @@ -19,7 +19,7 @@ Container Preinfo - + @@ -51,11 +51,11 @@

{{ request.user }}

{{ request.user.company }}

-
+