Compare commits
9 Commits
master
...
deploy_bra
| Author | SHA1 | Date |
|---|---|---|
|
|
16c3c60a6f | 7 months ago |
|
|
f16ea7c748 | 7 months ago |
|
|
06a3b105d3 | 7 months ago |
|
|
8294db9189 | 7 months ago |
|
|
f501be9794 | 7 months ago |
|
|
9167092f27 | 7 months ago |
|
|
75b3adfc71 | 7 months ago |
|
|
13c4c324fc | 7 months ago |
|
|
e824e87953 | 7 months ago |
@ -0,0 +1,33 @@
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Docker
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
docker-compose.dev.yml
|
||||
docker-compose-deploy.yml
|
||||
docker-compose with volume.yml
|
||||
dockerfile
|
||||
*.tar
|
||||
|
||||
# Python
|
||||
.venv
|
||||
__pycache__
|
||||
*.pyc
|
||||
|
||||
# Database
|
||||
db.sqlite3
|
||||
*.bak
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
production.env
|
||||
|
||||
# Other
|
||||
gemini.cmd - Shortcut.lnk
|
||||
|
||||
images/
|
||||
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="PY-242.23339.19">
|
||||
<data-source name="depot@localhost" uuid="2186be09-0cb1-4210-bad0-d279af5e6702">
|
||||
<database-info product="PostgreSQL" version="17.4" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.7.3" dbms="POSTGRES" exact-version="17.4" exact-driver-version="42.7">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
</database-info>
|
||||
<case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" />
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<user-name>postgres</user-name>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="database" qname="@">
|
||||
<node kind="schema" qname="@" />
|
||||
</node>
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="depot@localhost" uuid="2186be09-0cb1-4210-bad0-d279af5e6702">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://localhost:5432/depot</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
#n:depot
|
||||
@ -0,0 +1,2 @@
|
||||
#n:information_schema
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||
@ -0,0 +1,2 @@
|
||||
#n:pg_catalog
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||
@ -0,0 +1,2 @@
|
||||
#n:public
|
||||
!<md> [1114, 0, null, null, -2147483648, -2147483648]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,247 @@
|
||||
"""
|
||||
Django settings for DepoT project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.2.3.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/5.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import environ
|
||||
from minio_backend.storage import MinioStaticStorage, MinioMediaStorage
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
env = environ.Env()
|
||||
env.read_env(os.path.join(BASE_DIR, 'production.env'))
|
||||
|
||||
SECRET_KEY = "django-insecure-g%187p84o9^rr)3#9@r3n^o2v1i%@6=+puxm7hlodg+kbsk%n#"
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['192.168.24.43', '127.0.0.1', 'localhost', 'depot.kikimor.com', ]
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ['https://depot.kikimor.com']
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
||||
|
||||
PROJECT_APPS = [
|
||||
'accounts',
|
||||
"booking",
|
||||
"common",
|
||||
"containers",
|
||||
'preinfo',
|
||||
'payments',
|
||||
]
|
||||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"rest_framework",
|
||||
"damages_api",
|
||||
"django_minio_backend",
|
||||
"minio_backend",
|
||||
] + PROJECT_APPS
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "DepoT.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [BASE_DIR / 'templates']
|
||||
,
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = "DepoT.wsgi.application"
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
||||
|
||||
# DATABASES = {
|
||||
# "default": {
|
||||
# "ENGINE": "django.db.backends.sqlite3",
|
||||
# "NAME": BASE_DIR / "db.sqlite3",
|
||||
# }
|
||||
# }
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": env("DB_NAME"),
|
||||
"USER": env("DB_USER"),
|
||||
"PASSWORD": env("DB_PASSWORD"),
|
||||
"HOST": env("DB_HOST"),
|
||||
"PORT": env("DB_PORT"),
|
||||
}
|
||||
}
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_USER_MODEL = 'accounts.DepotUser'
|
||||
|
||||
LOGIN_URL = '/user/login/'
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
]
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = "static/"
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / 'static'
|
||||
]
|
||||
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
|
||||
TEMP_FILE_FOLDER = "/tmp/damages_photos"
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
|
||||
OWNCLOUD_URL = env('OWNCLOUD_URL')
|
||||
OWNCLOUD_USER = env('OWNCLOUD_USER')
|
||||
OWNCLOUD_PASSWORD = env('OWNCLOUD_PASSWORD')
|
||||
OWNCLOUD_DAMAGES_FOLDER = env('OWNCLOUD_DAMAGES_FOLDER')
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_HOST = env("EMAIL_HOST", cast=str, default=None)
|
||||
EMAIL_PORT = env("EMAIL_PORT", cast=str, default='587') # Recommended
|
||||
EMAIL_HOST_USER = env("EMAIL_HOST_USER", cast=str, default=None)
|
||||
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD", cast=str, default=None)
|
||||
EMAIL_USE_TLS = env("EMAIL_USE_TLS", cast=bool, default=True) # Use EMAIL_PORT 587 for TLS
|
||||
EMAIL_USE_SSL = env("EMAIL_USE_SSL", cast=bool, default=False) # EUse MAIL_PORT 465 for SSL
|
||||
|
||||
ADMIN_USER_NAME=env("ADMIN_USER_NAME")
|
||||
ADMIN_USER_PASSWORD=env("ADMIN_USER_PASSWORD")
|
||||
ADMIN_USER_EMAIL=env("ADMIN_USER_EMAIL")
|
||||
|
||||
MANAGERS=[]
|
||||
ADMINS=[]
|
||||
if all([ADMIN_USER_NAME, ADMIN_USER_EMAIL]):
|
||||
ADMINS +=[
|
||||
(f'{ADMIN_USER_NAME}', f'{ADMIN_USER_EMAIL}')
|
||||
]
|
||||
MANAGERS=ADMINS
|
||||
|
||||
|
||||
MINIO_ENDPOINT = env('MINIO_ENDPOINT')
|
||||
AWS_S3_CUSTOM_DOMAIN = env('AWS_S3_CUSTOM_DOMAIN')
|
||||
MINIO_SERVER_URL = env('MINIO_SERVER_URL')
|
||||
MINIO_EXTERNAL_ENDPOINT = AWS_S3_CUSTOM_DOMAIN
|
||||
MINIO_EXTERNAL_ENDPOINT_USE_HTTPS = True
|
||||
AWS_S3_URL_PROTOCOL = env('AWS_S3_URL_PROTOCOL')
|
||||
MINIO_ACCESS_KEY = env('MINIO_ACCESS_KEY')
|
||||
MINIO_SECRET_KEY = env('MINIO_SECRET_KEY')
|
||||
MINIO_BUCKET_NAME = env('MINIO_BUCKET_NAME')
|
||||
MINIO_SECURE = False # Set to True if using HTTPS
|
||||
MINIO_USE_HTTPS = False # Add this line
|
||||
MINIO_STATIC_BUCKET = env('MINIO_STATIC_BUCKET_NAME')
|
||||
|
||||
# django-minio-backend settings
|
||||
MINIO_STORAGE_ENDPOINT = AWS_S3_CUSTOM_DOMAIN
|
||||
MINIO_STORAGE_PORT = 443 if MINIO_SECURE else 80 # Add this line
|
||||
MINIO_STORAGE_ACCESS_KEY = env('MINIO_ACCESS_KEY')
|
||||
MINIO_STORAGE_SECRET_KEY = env('MINIO_SECRET_KEY')
|
||||
MINIO_STORAGE_USE_HTTPS = True
|
||||
MINIO_STORAGE_MEDIA_BUCKET_NAME = env('MINIO_BUCKET_NAME') # For user-uploaded media
|
||||
MINIO_STORAGE_STATIC_BUCKET_NAME = env('MINIO_STATIC_BUCKET_NAME') # For static files
|
||||
MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET = True
|
||||
MINIO_STORAGE_AUTO_CREATE_STATIC_BUCKET = True
|
||||
MINIO_STORAGE_AUTO_CREATE_POLICY = True
|
||||
MINIO_STORAGE_MEDIA_BASE_URL = f'{AWS_S3_URL_PROTOCOL}://{AWS_S3_CUSTOM_DOMAIN}/{env("MINIO_BUCKET_NAME")}/'
|
||||
MINIO_STORAGE_STATIC_BASE_URL = f'{AWS_S3_URL_PROTOCOL}://{AWS_S3_CUSTOM_DOMAIN}/{env("MINIO_STATIC_BUCKET_NAME")}/'
|
||||
|
||||
MINIO_PRIVATE_BUCKETS = [] # If you have any private buckets
|
||||
|
||||
MINIO_PUBLIC_BUCKETS = [
|
||||
env('MINIO_BUCKET_NAME'), # Just the bucket name as a string
|
||||
env('MINIO_STATIC_BUCKET_NAME') # Just the bucket name as a string
|
||||
]
|
||||
|
||||
MINIO_POLICY_ACTIONS = {
|
||||
'GET': ['get_object'],
|
||||
'PUT': ['put_object'],
|
||||
'DELETE': ['delete_object'],
|
||||
'LIST': ['list_multipart_uploads',
|
||||
'list_parts',
|
||||
'list_objects'],
|
||||
}
|
||||
|
||||
STORAGES = {
|
||||
"default": {
|
||||
"BACKEND": "minio_backend.storage.MinioMediaStorage",
|
||||
},
|
||||
"staticfiles": {
|
||||
"BACKEND": "minio_backend.storage.MinioStaticStorage",
|
||||
},
|
||||
}
|
||||
|
||||
DEFAULT_FILE_STORAGE = 'minio_backend.storage.MinioMediaStorage'
|
||||
STATICFILES_STORAGE = 'minio_backend.storage.MinioStaticStorage'
|
||||
STATIC_URL = f'{AWS_S3_URL_PROTOCOL}://{AWS_S3_CUSTOM_DOMAIN}/{env("MINIO_STATIC_BUCKET_NAME")}/'
|
||||
STATICFILES_LOCATION = 'static'
|
||||
MEDIA_ROOT = BASE_DIR / 'mediafiles'
|
||||
MEDIA_URL = f'{AWS_S3_URL_PROTOCOL}://{AWS_S3_CUSTOM_DOMAIN}/{env("MINIO_BUCKET_NAME")}/'
|
||||
@ -0,0 +1,5 @@
|
||||
FROM minio/mc:latest
|
||||
RUN test -f init_minio_buckets.sh && echo "init_minio_buckets.sh found in build context!" || (echo "init_minio_buckets.sh NOT found in build context!" && exit 1)
|
||||
COPY init_minio_buckets.sh /usr/local/bin/init_minio_buckets.sh
|
||||
RUN chmod +x /usr/local/bin/init_minio_buckets.sh
|
||||
ENTRYPOINT ["/usr/local/bin/init_minio_buckets.sh"]
|
||||
@ -0,0 +1,5 @@
|
||||
FROM alpine/git
|
||||
WORKDIR /build_context
|
||||
COPY . .
|
||||
RUN ls -la
|
||||
CMD ["echo", "Build context listed."]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def has_company_perm(user, perm_codename):
|
||||
return user.has_company_perm(perm_codename)
|
||||
|
||||
@register.filter
|
||||
def has_employee_perm(user, perm_codename):
|
||||
return user.has_employee_perm(perm_codename)
|
||||
@ -1,14 +1,18 @@
|
||||
from django.contrib.auth.views import LogoutView
|
||||
from django.urls import path, include
|
||||
from django.contrib.auth import views as auth_views
|
||||
from accounts import views
|
||||
from accounts.views import CustomPasswordChangeView
|
||||
|
||||
urlpatterns = [
|
||||
path('', include([
|
||||
path('', views.UserListView.as_view(), name='user_list'),
|
||||
path('register/', views.RegisterView.as_view(), name='user_register'),
|
||||
path('login/', views.DepotLoginView.as_view(), name='login'),
|
||||
path('relogin/', auth_views.logout_then_login, name='relogin'),
|
||||
path('change-password/', views.UserChangePasswordView.as_view(), name='change_password'),
|
||||
# path('relogin/', auth_views.logout_then_login, name='relogin'),
|
||||
path('relogin/', LogoutView.as_view(next_page='login'), name='relogin'),
|
||||
path('change-password/', CustomPasswordChangeView.as_view(), name='change_password'),
|
||||
|
||||
path('<int:pk>/update/', views.UserUpdateView.as_view(), name='user_update'),
|
||||
path('<int:pk>/active/', views.UserActiveView.as_view(), name='user_active'),
|
||||
])),
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,99 @@
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, Client
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
# Create your tests here.
|
||||
from accounts.models import ClientPermission
|
||||
from booking.models import Booking
|
||||
from common.models import LinesModel, ContainerTypeModel, CompanyModel
|
||||
|
||||
|
||||
class BookingViewsTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.company = CompanyModel.objects.create(name='Test Company')
|
||||
self.line = LinesModel.objects.create(name='Test Line', company_id=self.company.id)
|
||||
self.container_type = ContainerTypeModel.objects.get(name='20GP')
|
||||
|
||||
self.user_password = 'password'
|
||||
self.client = Client()
|
||||
DepotUser = get_user_model()
|
||||
|
||||
self.user_client_no_rights = DepotUser.objects.create_user(username='user_client_no_rights', password=self.user_password, user_type='CL', email='user_client_no_rights@gmail.com')
|
||||
|
||||
self.user_client_all_rights = DepotUser.objects.create_user(username='user_client_all_rights', password=self.user_password, user_type='CL', email='user_client_all_rights@gmail.com', line=self.line, company=self.company)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_view_booking').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_manage_booking').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_view_preinfo').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_manage_preinfo').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_view_payment').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_manage_payment').id)
|
||||
self.user_client_all_rights.company_permissions.add(ClientPermission.objects.get(codename='can_manage_company_users').id)
|
||||
|
||||
|
||||
self.user_employee_no_rights = DepotUser.objects.create_user(username='user_employee_no_rights', password=self.user_password, user_type='EM', email='user_employee_no_rights@gmail.com')
|
||||
|
||||
self.user_employee_all_rights = DepotUser.objects.create_user(username='user_employee_all_rights', password=self.user_password, user_type='EM', email='user_employee_all_rights@gmail.com')
|
||||
self.user_employee_all_rights.employee_permissions.add(1)
|
||||
self.user_employee_all_rights.employee_permissions.add(2)
|
||||
self.user_employee_all_rights.employee_permissions.add(3)
|
||||
self.user_employee_all_rights.employee_permissions.add(4)
|
||||
self.user_employee_all_rights.employee_permissions.add(5)
|
||||
|
||||
self.booking = Booking.objects.create(
|
||||
number='BOOK123',
|
||||
container_type=self.container_type,
|
||||
container_count=10,
|
||||
line=self.line,
|
||||
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):
|
||||
response = self.client.get(reverse_lazy('employee_bookings'))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_employee_booking_list_view__client_user_login__expect_forbidden_403(self):
|
||||
self.client.login(username=self.user_client_no_rights.username, password=self.user_password)
|
||||
response = self.client.get(reverse_lazy('employee_bookings'))
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_employee_booking_list_view__user_login__expect_redirect_200(self):
|
||||
self.client.login(username=self.user_employee_no_rights.username, password=self.user_password)
|
||||
response = self.client.get(reverse_lazy('employee_bookings'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_booking_list_view__user_all_rights__expect_OK(self):
|
||||
self.client.login(username=self.user_employee_all_rights.username, password=self.user_password)
|
||||
response = self.client.get(reverse_lazy('employee_bookings'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
self.assertTemplateUsed(response, 'employee/booking-list.html')
|
||||
self.assertContains(response, self.booking.number)
|
||||
|
||||
def test_client_create_booking__expect_redirect_to_booking_list_and_booking_in_db(self):
|
||||
self.assertTrue( self.user_client_all_rights.has_company_perm('can_manage_booking'))
|
||||
self.client.login(username=self.user_client_all_rights.username, password=self.user_password)
|
||||
|
||||
response = self.client.post(reverse('client_booking_create'), {
|
||||
'number': 'BOOK456',
|
||||
'container_type': self.container_type.id,
|
||||
'container_count': 5,
|
||||
'line': self.line.id,
|
||||
'vehicles': 'Truck1,Truck2',
|
||||
'vehicles_left': 'Truck1,Truck2',
|
||||
})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertTrue(Booking.objects.filter(number='BOOK456').exists())
|
||||
|
||||
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',
|
||||
'container_type': self.container_type.id,
|
||||
'container_count': 15,
|
||||
'line': self.line.id,
|
||||
})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.booking.refresh_from_db()
|
||||
self.assertEqual(self.booking.number, 'BOOK123-UPDATED')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue