diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d928493..425775e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,18 +5,12 @@ - - - - - - - - + + + - @@ -96,7 +92,7 @@ - + - + + + + - + - + + + - + + - @@ -253,7 +273,7 @@ - + - + + + diff --git a/booking/__pycache__/models.cpython-313.pyc b/booking/__pycache__/models.cpython-313.pyc index 6fc7a81..375e9de 100644 Binary files a/booking/__pycache__/models.cpython-313.pyc and b/booking/__pycache__/models.cpython-313.pyc differ diff --git a/booking/models.py b/booking/models.py index 8d6fe63..8f60b0b 100644 --- a/booking/models.py +++ b/booking/models.py @@ -34,9 +34,9 @@ class Booking(models.Model): container_number = ContainerNumberField(max_length=11, blank=True, null=True) vehicles_left = models.CharField(blank=True, null=True) created_on = models.DateTimeField(auto_now_add=True) - created_by = models.ForeignKey(DepotUser, related_name='booking_user', on_delete=models.CASCADE) + created_by = models.ForeignKey(DepotUser, related_name='booking_created_user', on_delete=models.CASCADE) updated_on = models.DateTimeField(auto_now=True) - updated_by = models.ForeignKey(DepotUser, related_name='booking_user', on_delete=models.CASCADE) + updated_by = models.ForeignKey(DepotUser, related_name='booking_updated_user', on_delete=models.CASCADE) status = models.CharField( max_length=10, choices=STATUS_CHOICES, diff --git a/booking/tests.py b/booking/tests.py index a282b7c..2256c4d 100644 --- a/booking/tests.py +++ b/booking/tests.py @@ -43,11 +43,10 @@ class BookingViewsTestCase(TestCase): container_type=self.container_type, container_count=10, line=self.line, - created_by=self.user_employee_all_rights.id, - updated_by=self.user_employee_all_rights.id, + created_by=self.user_client_all_rights, + updated_by=self.user_client_all_rights, vehicles='K1,J2,K3', vehicles_left='K1,J2,K3', - ) def test_employee_booking_list_view__anonymouse_user__expect_redirect_302(self): @@ -87,7 +86,7 @@ class BookingViewsTestCase(TestCase): self.assertEqual(response.status_code, 302) self.assertTrue(Booking.objects.filter(number='BOOK456').exists()) - def test_booking_update_view(self): + def test_booking_update_view__expect_redirect_and_booking_updated_in_db(self): self.client.login(username=self.user_client_all_rights.username, password=self.user_password) response = self.client.post(reverse('client_booking_update', args=[self.booking.id]), { 'number': 'BOOK123-updated', @@ -97,4 +96,4 @@ class BookingViewsTestCase(TestCase): }) self.assertEqual(response.status_code, 302) self.booking.refresh_from_db() - self.assertEqual(self.booking.number, 'BOOK123-updated') + self.assertEqual(self.booking.number, 'BOOK123-UPDATED') diff --git a/booking/views/__pycache__/client_views.cpython-313.pyc b/booking/views/__pycache__/client_views.cpython-313.pyc index 70fec42..102a0db 100644 Binary files a/booking/views/__pycache__/client_views.cpython-313.pyc and b/booking/views/__pycache__/client_views.cpython-313.pyc differ diff --git a/booking/views/client_views.py b/booking/views/client_views.py index 22abb77..2a4623b 100644 --- a/booking/views/client_views.py +++ b/booking/views/client_views.py @@ -1,6 +1,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.urls import reverse_lazy -from django.views.generic import CreateView, ListView +from django.views.generic import CreateView, ListView, UpdateView from DepoT.mixins.LineFiltweFormMixin import LineFilterFormMixin from booking.forms import BookingCreateForm, BookingUpdateForm @@ -38,8 +38,8 @@ class CreateBookingView(LoginRequiredMixin, UserPassesTestMixin, LineFilterFormM def form_valid(self, form): # todo more validation - form.instance.created_by = self.request.user.id - form.instance.updated_by = self.request.user.id + form.instance.created_by = self.request.user + form.instance.updated_by = self.request.user form.instance.vehicles_left = form.cleaned_data.get('vehicles') return super().form_valid(form) @@ -47,7 +47,7 @@ class CreateBookingView(LoginRequiredMixin, UserPassesTestMixin, LineFilterFormM return self.request.user.has_company_perm('can_manage_booking') or self.request.user.user_type == 'CA' -class ClientBookingUpdateView(LoginRequiredMixin, UserPassesTestMixin, LineFilterFormMixin, CreateView): +class ClientBookingUpdateView(LoginRequiredMixin, UserPassesTestMixin, LineFilterFormMixin, UpdateView): template_name = 'client/booking-edit.html' model = Booking form_class = BookingUpdateForm @@ -55,7 +55,7 @@ class ClientBookingUpdateView(LoginRequiredMixin, UserPassesTestMixin, LineFilte def form_valid(self, form): # todo more validation - form.instance.updated_by = self.request.user.id + form.instance.updated_by = self.request.user return super().form_valid(form) def test_func(self): diff --git a/common/__pycache__/models.cpython-313.pyc b/common/__pycache__/models.cpython-313.pyc index e800876..6323835 100644 Binary files a/common/__pycache__/models.cpython-313.pyc and b/common/__pycache__/models.cpython-313.pyc differ diff --git a/containers/__pycache__/models.cpython-313.pyc b/containers/__pycache__/models.cpython-313.pyc index 2f163fd..696fb25 100644 Binary files a/containers/__pycache__/models.cpython-313.pyc and b/containers/__pycache__/models.cpython-313.pyc differ diff --git a/containers/tests.py b/containers/tests.py index 60ebdf7..7ce503c 100644 --- a/containers/tests.py +++ b/containers/tests.py @@ -1,48 +1,3 @@ -from django.test import TestCase, Client -from django.urls import reverse -from django.contrib.auth import get_user_model -from containers.models import Container -from common.models import LinesModel, ContainerTypeModel -from preinfo.models import Preinfo +from django.test import TestCase -class ContainerViewsTestCase(TestCase): - def setUp(self): - self.client = Client() - DepotUser = get_user_model() - self.user = DepotUser.objects.create_user(username='testuser', password='password', user_type='E') - self.client.login(username='testuser', password='password') - self.line = LinesModel.objects.create(name='Test Line') - self.container_type = ContainerTypeModel.objects.create(name='20ft') - self.preinfo = Preinfo.objects.create(number='PRE123', line=self.line, container_type=self.container_type) - self.container = Container.objects.create( - number='TEST1234567', - line=self.line, - container_type=self.container_type, - received_by=self.user, - preinfo=self.preinfo - ) - - def test_container_list_view(self): - response = self.client.get(reverse('container-list')) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'containers/container-list.html') - self.assertContains(response, self.container.number) - - def test_container_receive_view(self): - response = self.client.post(reverse('container-receive'), { - 'number': 'TEST7654321', - 'line': self.line.id, - 'container_type': self.container_type.id, - 'preinfo': self.preinfo.id, - }) - self.assertEqual(response.status_code, 302) - self.assertTrue(Container.objects.filter(number='TEST7654321').exists()) - - def test_container_expedition_view(self): - response = self.client.post(reverse('container-expedition', args=[self.container.id]), { - 'expedition_vehicle': 'TRUCK123', - }) - self.assertEqual(response.status_code, 302) - self.container.refresh_from_db() - self.assertTrue(self.container.expedited) - self.assertEqual(self.container.expedition_vehicle, 'TRUCK123') \ No newline at end of file +# Create your tests here. diff --git a/payments/__pycache__/models.cpython-313.pyc b/payments/__pycache__/models.cpython-313.pyc index 7d3f5e6..298a232 100644 Binary files a/payments/__pycache__/models.cpython-313.pyc and b/payments/__pycache__/models.cpython-313.pyc differ diff --git a/preinfo/__pycache__/models.cpython-313.pyc b/preinfo/__pycache__/models.cpython-313.pyc index 09e5cfb..96bff3f 100644 Binary files a/preinfo/__pycache__/models.cpython-313.pyc and b/preinfo/__pycache__/models.cpython-313.pyc differ diff --git a/readme.md b/readme.md index ff4d241..7a9738d 100644 --- a/readme.md +++ b/readme.md @@ -23,13 +23,16 @@ DepoT е софтуер за управление на контейнерно д Проектът е структуриран по модулен начин, което позволява лесно добавяне на нови функционалности и поддръжка на съществуващите. ## Инсталация -За пускане на проекта е необходимо да се вдигне контейнер, в който са инсталирани PostgreSQL и minIO. MinIO е S3 съвместим bucket storage, който се използва за съхранение на снимки и други файлове, които се прикачват към контейнерите. Той е идеален за разработка, тъй като може да се използва локално и е съвместим с AWS S3 API. +За пускане на проекта локално е необходимо да се вдигне контейнер, в който са инсталирани PostgreSQL и minIO. MinIO е S3 съвместим bucket storage, който се използва за съхранение на снимки и други файлове, които се прикачват към контейнерите. Той е идеален за разработка, тъй като може да се използва локално и е съвместим с AWS S3 API. Това става с docker-compose.dev.yml, който е в корена на проекта. след това трябва да се пуснат миграциите, за да се попълни базата данни с основни номенклатури и други данни, които са необходими за работата на проекта, както и има създаден суперпотребител: username: kikimor password: shushunka1 +В конфигурацията на проекта трябва да се добави environment vairable: DJANGO_SETTINGS_MODULE=DepoT.settings.development +Това е необходимо, за да се заредят development настройките на проекта, които са в DepoT/settings/development.py. + След стартиране на системата, се отваря landing страницата на DepoT. В нея има малко информация за депото, login бутон и бутон за таблото за шофьорите. При логване, в зависимост от типа на потребителя, се отваря различен dashboard. За служители и клиенти той изглежда почти еднакво, а за операторите е различен, тъй като те ползват таблети и интерфейса трябва да е по-опростен и удобен за работа с пръст(ръкавици). @@ -38,4 +41,4 @@ password: shushunka1 В repository (https://git.kikimor.com) има нов branch (deploy_branch). В него има docker-compose-deploy.yml,с който се стартират всички контейнери (postgres, minio, createbuckets и самото приложение). Тук в контейнера се прави collectstatic, след което се качват в bucket "static" на minio и се сервират през него. -P.S.Тъй като не остана много време, не знам дали ще успея да обединя двата branch-а, затова последните промени засега ще са само в deploy_branch, който вие няма да можете да стартирате. \ No newline at end of file +P.S.Тъй като не остана много време, не знам дали ще успея да обединя двата branch-а, затова последните промени засега ще са само в deploy_branch, който вие няма да можете да стартирате.