Обновление зависимостей
This commit is contained in:
parent
192988eeeb
commit
d4f50d8894
@ -1,4 +1,5 @@
|
||||
from checkpoint.models import CheckpointPass
|
||||
from checkpoint.models.checkpoint_pass import CheckpointPass
|
||||
from checkpoint.models.entrance import Entrance
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@ -8,3 +9,8 @@ class CheckpointPassAdmin(admin.ModelAdmin):
|
||||
|
||||
def car(self, obj: CheckpointPass):
|
||||
return str(obj.car_manufacturer + obj.car_model + obj.car_registration_number)
|
||||
|
||||
|
||||
@admin.register(Entrance)
|
||||
class EntranceAdmin(admin.ModelAdmin):
|
||||
list_display = ('checkpoint_pass', 'date_in', 'date_out')
|
||||
|
||||
15
app/checkpoint/api/views.py
Normal file
15
app/checkpoint/api/views.py
Normal file
@ -0,0 +1,15 @@
|
||||
from checkpoint.models.checkpoint_pass import CheckpointPass
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.utils import timezone
|
||||
from project.generics.base_view import base_view
|
||||
|
||||
|
||||
@base_view
|
||||
def get_passes(request):
|
||||
qs = CheckpointPass.objects.values()
|
||||
return JsonResponse(qs)
|
||||
|
||||
|
||||
def current_time(request):
|
||||
now = timezone.now()
|
||||
return HttpResponse(f'Current server time: {now}')
|
||||
0
app/checkpoint/models/__init__.py
Normal file
0
app/checkpoint/models/__init__.py
Normal file
@ -4,7 +4,7 @@ from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
def calculate_default_pass_end_value(self):
|
||||
def calculate_default_pass_end_value():
|
||||
return timezone.now() + timedelta(hours=24)
|
||||
|
||||
|
||||
@ -19,16 +19,19 @@ class CheckpointPass(models.Model):
|
||||
pass_end - хранит конец срока действия пропуска
|
||||
(по умолчанию текущее время + 24 часа - на случай если пропуск разовый)
|
||||
"""
|
||||
car_manufacturer = models.CharField(max_length=128)
|
||||
car_model = models.CharField(max_length=128)
|
||||
car_manufacturer = models.CharField(max_length=128, blank=True)
|
||||
car_model = models.CharField(max_length=128, blank=True)
|
||||
car_registration_number = models.CharField(max_length=10)
|
||||
pass_start = models.DateTimeField(default=timezone.now)
|
||||
pass_end = models.DateTimeField(default=calculate_default_pass_end_value)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Пропуск'
|
||||
verbose_name_plural = 'Пропуски'
|
||||
verbose_name_plural = 'Пропуска'
|
||||
indexes = (
|
||||
models.Index(fields=['car_registration_number']),
|
||||
models.Index(fields=['pass_start', 'pass_end'])
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.car_registration_number}: {self.pass_start.date()}:{self.pass_end.date()}'
|
||||
18
app/checkpoint/models/entrance.py
Normal file
18
app/checkpoint/models/entrance.py
Normal file
@ -0,0 +1,18 @@
|
||||
from checkpoint.models.checkpoint_pass import CheckpointPass
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Entrance(models.Model):
|
||||
"""
|
||||
Модель въезда через КПП. Отображает время въезда и выезда.
|
||||
checkpoint_pass - хранит ссылку на id пропуска
|
||||
date_in - хранит время въезда
|
||||
date_out - хранит время выезда
|
||||
"""
|
||||
checkpoint_pass = models.ForeignKey(CheckpointPass, on_delete=models.CASCADE)
|
||||
date_in = models.DateTimeField(auto_now=True)
|
||||
date_out = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Въезд'
|
||||
verbose_name_plural = 'Въезды'
|
||||
@ -1,3 +1,4 @@
|
||||
from checkpoint.api.views import current_time
|
||||
from checkpoint.views import checkpoint_view, operator_view
|
||||
from django.urls import path
|
||||
|
||||
@ -6,4 +7,5 @@ app_name = 'checkpoint'
|
||||
urlpatterns = [
|
||||
path('checkpoint/', checkpoint_view, name='checkpoint_view'),
|
||||
path('operator/', operator_view, name='operator_view'),
|
||||
path('time/', current_time, name='time')
|
||||
]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.shortcuts import render
|
||||
from project.generics.group_checkers import is_guard, is_operator
|
||||
@ -6,6 +7,7 @@ from project.generics.group_checkers import is_guard, is_operator
|
||||
# from project.generics.base_view import base_view
|
||||
@user_passes_test(is_guard)
|
||||
def checkpoint_view(request):
|
||||
messages.add_message(request, messages.INFO, 'Hello world.')
|
||||
return render(request, 'checkpoint/checkpoint.html')
|
||||
|
||||
|
||||
|
||||
30
app/poetry.lock
generated
30
app/poetry.lock
generated
@ -258,6 +258,17 @@ files = [
|
||||
[package.extras]
|
||||
cli = ["click (>=5.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pytz"
|
||||
version = "2024.1"
|
||||
description = "World timezone definitions, modern and historical"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"},
|
||||
{file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
version = "6.0.2"
|
||||
@ -346,6 +357,23 @@ files = [
|
||||
{file = "tzdata-2024.1.tar.gz", hash = "sha256:2674120f8d891909751c38abcdfd386ac0a5a1127954fbc332af6b5ceae07efd"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tzlocal"
|
||||
version = "5.2"
|
||||
description = "tzinfo object for the local timezone"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "tzlocal-5.2-py3-none-any.whl", hash = "sha256:49816ef2fe65ea8ac19d19aa7a1ae0551c834303d5014c6d5a62e4cbda8047b8"},
|
||||
{file = "tzlocal-5.2.tar.gz", hash = "sha256:8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
tzdata = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
|
||||
[package.extras]
|
||||
devenv = ["check-manifest", "pytest (>=4.3)", "pytest-cov", "pytest-mock (>=3.3)", "zest.releaser"]
|
||||
|
||||
[[package]]
|
||||
name = "virtualenv"
|
||||
version = "20.26.3"
|
||||
@ -369,4 +397,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "34f4557cc35743505418ac68d8165ff5230061f47ec09656b3ace5badc79baf6"
|
||||
content-hash = "f64fadfc7b976f253ae32c75dc31278d39d4a7d60ffa3097281d681c4d4973ed"
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
from dotenv import load_dotenv
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@ -12,7 +11,7 @@ if os.path.exists(dotenv_path):
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
SECRET_KEY = get_random_secret_key()
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY')
|
||||
|
||||
DEBUG = True
|
||||
|
||||
@ -117,7 +116,6 @@ LANGUAGE_CODE = 'ru'
|
||||
TIME_ZONE = 'Asia/Krasnoyarsk'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = False
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
@ -13,6 +13,8 @@ python-dotenv = "^1.0.1"
|
||||
psycopg2-binary = "^2.9.9"
|
||||
gunicorn = "^22.0.0"
|
||||
pre-commit = "^3.8.0"
|
||||
pytz = "^2024.1"
|
||||
tzlocal = "^5.2"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
||||
@ -4,3 +4,5 @@ POSTGRES_USER=checkpoint_user
|
||||
POSTGRES_DB=checkpoint
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
|
||||
SECRET_KEY=izr*z9=%fidp7p2cueju7iulv$u$cav3m2=^!2h!c=uhjb^%^^
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user