Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
d3fe69b
second-prototype-update-authorization: groups: change create user wit…
IlyaKK Nov 4, 2021
1c1b899
second-prototype-update-authorization: groups: change serializing gro…
IlyaKK Nov 4, 2021
908715f
second-prototype-update-authorization: add model and fields
IlyaKK Nov 4, 2021
0faf237
second-prototype-update-authorization: change create superuser
IlyaKK Nov 4, 2021
db70276
second-prototype-update-authorization: resolve bag in create superuser
IlyaKK Nov 4, 2021
36f1f6f
second-prototype-update-authorization: change fields name for change …
IlyaKK Nov 4, 2021
eeffc6d
second-prototype-update-authorization: add log token
IlyaKK Nov 4, 2021
fef2770
second-prototype-update-authorization: add log token
IlyaKK Nov 4, 2021
e061453
second-prototype-update-authorization: edit change group user
IlyaKK Nov 5, 2021
5aa3d8f
second-prototype-update-authorization: edit fields for serializing
IlyaKK Nov 5, 2021
10f552e
second-prototype-update-authorization: update permission of group!=Ad…
IlyaKK Nov 5, 2021
e9b42e5
second-prototype-update-authorization: delete logging print token
IlyaKK Nov 5, 2021
1537f04
second-prototype-update-authorization: create users list
IlyaKK Nov 5, 2021
ce50c05
second-prototype-update-authorization: create fields for user
IlyaKK Nov 5, 2021
86127b9
second-prototype-update-authorization: delete group with fields
IlyaKK Nov 5, 2021
d055945
deploy: all together for the first time (accident, conveyor, auth, fr…
cactusFriday Nov 5, 2021
0523bd3
deploy: changed CORS_ORIGIN_WHITELIST
cactusFriday Nov 5, 2021
730dad5
deploy: changed url from localhost to heroku
cactusFriday Nov 5, 2021
d597178
deploy: changed request throttle rate for stability
cactusFriday Nov 5, 2021
55be512
deploy: fixed accident view
cactusFriday Nov 5, 2021
7960825
deploy: fixed accident view again
cactusFriday Nov 5, 2021
8c4a977
deploy:changed styles, added logout
Nov 5, 2021
052bc8f
updating deploy
Nov 5, 2021
8ac8d4b
Merge remote-tracking branch 'origin/deploy' into second-prototype-up…
IlyaKK Nov 5, 2021
0068968
second-prototype-update-authorization: added method decorator(ensure_…
IlyaKK Nov 5, 2021
72c5c7a
second-prototype-update-authorization: create get users with groups
IlyaKK Nov 6, 2021
e2868d6
Merge pull request #3 from cactusFriday/second-prototype-update-autho…
IlyaKK Nov 6, 2021
4e96954
deploy: added csrf decorators to accident views and CORS_ALLOW_LIST_A…
cactusFriday Nov 6, 2021
ff47121
deploy: added cors_allow_header Authorization
cactusFriday Nov 6, 2021
c604316
deploy: few fixes
cactusFriday Nov 6, 2021
aef5efd
front-accidentTable: modal window sends POST with accident to server …
cactusFriday Nov 6, 2021
64045fd
merged deploy and deploy-accidentTable
cactusFriday Nov 6, 2021
e6c30a9
deploy: fixed layouts
cactusFriday Nov 6, 2021
47b001f
deploy: fixes in monitoring.js
cactusFriday Nov 6, 2021
b4beb3c
deploy: changed id for post in first column of accident table
cactusFriday Nov 6, 2021
79fd955
deploy:fixed conveyortable
Nov 6, 2021
6c96849
deploy/monitoring.js: represent time strings and parse accident class…
cactusFriday Nov 6, 2021
f3381cc
deploy: changed title in index.html
cactusFriday Nov 6, 2021
4288496
Add files via upload
taunnol Nov 7, 2021
b608362
Update App.js
taunnol Nov 7, 2021
ac28d95
second-prototype-registration: changed menu
Nov 7, 2021
25a08fb
Merge pull request #4 from cactusFriday/second-prototype-registration
cactusFriday Nov 9, 2021
61fffd4
accidents: [back]added PATCH and last post filter, [front] modal load…
cactusFriday Nov 11, 2021
f5cdf04
deploy: changed url for last post accident
cactusFriday Nov 11, 2021
164e507
deploy: added editing and history modal windows, changed navbar, adde…
Nov 11, 2021
3686bfd
deploy: added register and menu item
Nov 11, 2021
570c5dd
deploy: conflict solved
Nov 11, 2021
1a1504d
deploy: added modal exit and close picture
Nov 11, 2021
b341f3b
deploy: modal fixed
Nov 11, 2021
e99b6a4
deploy: modal fixed
Nov 11, 2021
7778ac2
deploy: fixed time
Nov 11, 2021
2eefbbf
deploy: fixed conveyor numbers
Nov 11, 2021
4d34ccc
merge with deploy-accidents
cactusFriday Nov 12, 2021
8c8309d
deploy: added cursor: pointer to all links
cactusFriday Nov 12, 2021
d5b03dd
deploy: added time_solved
cactusFriday Nov 12, 2021
75aae4e
deploy: changed some styles
cactusFriday Nov 12, 2021
5c6fdc2
deploy: fixed dates, added field in editmodal window
Nov 12, 2021
8938800
deploy: added verbose description of accident classes
cactusFriday Nov 12, 2021
bc73716
Merge branch 'deploy' of github.com:cactusFriday/Tractor_factory_inte…
cactusFriday Nov 12, 2021
990fd79
deploy: changed url
cactusFriday Nov 12, 2021
93fd7b5
deploy: fixed field's length in modaledit
Nov 12, 2021
b7ae5c6
need to be merged
Nov 12, 2021
7877afe
Update AccidentTable.js
taunnol Nov 13, 2021
4efa3ee
Update Monitoring.js
taunnol Nov 13, 2021
663bfa9
add vertical scrolling
taunnol Nov 13, 2021
b586b80
deploy: added private routes
Nov 13, 2021
ce57af7
deploy: added button to unauthorized, changed history table styles
Nov 14, 2021
036c22e
deploy-synhronization-post-buttons: created model buttons with many t…
IlyaKK Nov 14, 2021
e5565f3
deploy-synhronization-post-buttons: change procfile for create new ta…
IlyaKK Nov 14, 2021
4a8ec56
deploy-synhronization-post-buttons: create working serializer for but…
IlyaKK Nov 15, 2021
1ce9072
deploy-configurator-front: created configurator HTML and logic, witho…
cactusFriday Nov 15, 2021
95bfdf6
merged with deploy and added PrivateRoute for config
cactusFriday Nov 15, 2021
980f7f9
deploy-configurator-front: async updating accident table with interval
cactusFriday Nov 15, 2021
90b5491
deploy: changed var names for right rendering with new responses from…
cactusFriday Nov 15, 2021
3266e8f
Merge pull request #5 from cactusFriday/deploy-configurator-front
cactusFriday Nov 15, 2021
03763b2
Merge pull request #6 from cactusFriday/deploy-synhronization-post-bu…
cactusFriday Nov 15, 2021
c1468b8
deploy-synhronization-post-buttons: change get posts with status
IlyaKK Nov 15, 2021
9587e19
deploy-synhronization-post-buttons: change type in serializer for get…
IlyaKK Nov 15, 2021
e221c4c
deploy-synhronization-post-buttons: edit change status of buttons block
IlyaKK Nov 15, 2021
e469c19
deploy-synhronization-post-buttons: create serializer for get buttons…
IlyaKK Nov 15, 2021
716862e
deploy-synhronization-post-buttons: create accident when button block…
IlyaKK Nov 15, 2021
bbc7022
deploy-synchronization-post-buttons: create change time solved when b…
IlyaKK Nov 15, 2021
d19d0bc
deploy-synchronization-post-buttons: create change configuration of b…
IlyaKK Nov 15, 2021
10bc554
deploy-synchronization-post-buttons: create bad request response
IlyaKK Nov 15, 2021
8d4883c
Merge branch 'deploy' into deploy-synhronization-post-buttons
IlyaKK Nov 15, 2021
dfebc38
deploy-synchronization-post-buttons: restore default procfile
IlyaKK Nov 15, 2021
6362335
Merge pull request #7 from cactusFriday/deploy-synhronization-post-bu…
IlyaKK Nov 15, 2021
7754233
deploy: change page size in queryset request
IlyaKK Nov 15, 2021
72ab4f4
deploy-configurator-front: finish with basic functionality of configu…
cactusFriday Nov 15, 2021
230f6f9
deploy-configurator-front: added route for configurator
cactusFriday Nov 15, 2021
c1e98d5
Merge pull request #9 from cactusFriday/deploy-configurator-front
cactusFriday Nov 15, 2021
eb87c58
deploy: changed modals and table for correct accidentClass displaying
cactusFriday Nov 16, 2021
a71f509
deploy-back-button: added back button to configurator page
cactusFriday Nov 16, 2021
9b9f08e
Merge pull request #10 from cactusFriday/deploy-back-button
cactusFriday Nov 16, 2021
34165a5
deploy-user-change-group-frontend: create users list with dropdown gr…
IlyaKK Nov 16, 2021
d658eb5
deploy-user-change-group-frontend: edit handler of change group
IlyaKK Nov 16, 2021
1b73d94
deploy-user-change-group-frontend: create item menu of users
IlyaKK Nov 16, 2021
5de0ceb
Update Register.js
taunnol Nov 16, 2021
ed2cf39
register styles fixed
taunnol Nov 16, 2021
2304749
deploy-user-change-group-frontend: delete unused menu item
IlyaKK Nov 16, 2021
1ba17e5
Merge branch 'deploy' into deploy-user-change-group-frontend
IlyaKK Nov 16, 2021
3d0007e
deploy-user-change-group-frontend: change urls for sever heroku
IlyaKK Nov 16, 2021
89ba8af
Merge pull request #11 from cactusFriday/deploy-user-change-group-fro…
IlyaKK Nov 16, 2021
e5da71e
deploy:add build and edit url for change user group
IlyaKK Nov 16, 2021
729ed37
deploy:change url get users and time update
IlyaKK Nov 16, 2021
8bc78c2
deploy:update page of users list with change group, add react dropdow…
IlyaKK Nov 16, 2021
1737680
deploy:change version of react bootstrap
IlyaKK Nov 16, 2021
25c2e95
deploy:change version of react bootstrap
IlyaKK Nov 16, 2021
3610ae2
deploy:update npm
IlyaKK Nov 16, 2021
2c63fd0
deploy-post-blocks: changed posts with posts_blocks and added toast-n…
cactusFriday Nov 18, 2021
10f52f8
deploy-post-blocks: added utils for post, added funcs from utils to e…
cactusFriday Nov 18, 2021
0e0dda5
deploy-post-blocks: added error notifications and some deletions
cactusFriday Nov 18, 2021
07f0fe8
deploy-post-blocks: fixed find function
cactusFriday Nov 18, 2021
e842655
Merge pull request #12 from cactusFriday/deploy-post-blocks
cactusFriday Nov 18, 2021
be04539
deploy-post-blocks: changed find function again
cactusFriday Nov 18, 2021
e708f6c
deploy-post-blocks: fixed acccident table. Displaying accident classe…
cactusFriday Nov 18, 2021
e5fe646
deploy-synhonization-post-buttons: update change posts for button block
IlyaKK Nov 18, 2021
9578bb6
deploy-synhonization-post-buttons: replace buttons to buttons_set for…
IlyaKK Nov 18, 2021
54b2716
Merge pull request #13 from cactusFriday/deploy-synhronization-post-b…
IlyaKK Nov 18, 2021
9c2742b
deploy-post-blocks: fixed issues with editing accidents and displayin…
cactusFriday Nov 18, 2021
37d253b
Merge pull request #14 from cactusFriday/deploy-post-blocks
cactusFriday Nov 18, 2021
2ccaa0d
deploy-synhonization-post-buttons: add save for object of table database
IlyaKK Nov 18, 2021
0a82ca0
Merge branch 'deploy' into deploy-synhronization-post-buttons
IlyaKK Nov 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions accident/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
## Accient endpoints
--------------------
##### Content
[Endpoints](#methods)
[1.1. List all accidents in system](#list_accidents)
[1.2. Create accident](#create_accident)
[1.3. Get accident with id](#id_accident)
[1.4. Delete certain accident](#id_accident_delete)
[2.1. List the history of editing accidents](#list_history)
[2.2. Create a history record (Edit existing accident)](#create_history)


<a name="methods"><h4>Endpoints</h4></a>
Method|Endpoint|Description|
--------|--------------------|-----------|
`GET` |`api/v1/accident/` |Return all existing accidents|
`POST` |`api/v1/accident/` |Create accident|
`GET` |`api/v1/accident/1` |Return accident with `id=1`|
`DELETE`|`api/v1/accident/` |Delete accident with `id=1` and all edit history|
`GET` |`api/v1/accident/history/`|Return all edit hitory of all accidents|
`POST` |`api/v1/accident/history/`|Create accident history record (edit existing accident)|

### 1. Accident
<a name="list_accidents"><h4>1. List all accidents in system</h4></a>
Request
`GET` `api/v1/accident/`
Response
```json
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"user": "admin",
"time_appeared": "2020-01-07T19:28:40Z",
"time_solved": null,
"post": 11,
"accident_class": 3,
"description": "Инцидент изменен. Класс изменен на 3",
"accident_history": [
{
"id": 1,
"time_changed": "2021-10-31T15:11:57.332716Z",
"accident_id": 1,
"accident_class": null,
"description": "Тестовый инцидент"
}
]
}
]
}
```
Or you can add **search parameters** for **filtering**
`GET` `api/v1/accident/?sort=ASC&dateStart=2020-02-02&dateEnd=2020-09-09&accClass=2`
`sort = ASC/DESC`
`dateStart=YYYY-MM-DD`
`accClass=null` or `accClass=1%3B2%3B3` == `1;2;3`

<a name="create_accident"><h4>2. Create accident</h4></a>

Request
`POST` `api/v1/accident/`

Body
```json
{
"time_appeared": "2021-03-08 19:28:40+00:00",
"time_solved": null,
"post": 11,
"accident_class": 1,
"description": "Test accident"
}
```
Response
```json
{
"id": 6,
"user": "admin",
"time_appeared": "2021-03-08T19:28:40Z",
"time_solved": null,
"post": 11,
"accident_class": 1,
"description": "Test accident",
"accident_history": []
}
```

<a name="id_accident"><h4>3. Get accident with id</h4></a>

Request
`GET` `api/v1/accident/2/`

Response
```json
{
"id": 2,
"user": "admin",
"time_appeared": "2020-01-07T19:28:40Z",
"time_solved": null,
"post": 11,
"accident_class": 3,
"description": "Refactored",
"accident_history": [
{
"id": 4,
"time_changed": "2021-10-31T15:11:57.332716Z",
"accident_id": 2,
"accident_class": null,
"description": "Тестовый инцидент"
}
]
}
```

<a name="id_accident_delete"><h4>4. Delete certain accident</h4></a>

Request
`DELETE` `api/v1/accident/2/`

Returns response code `204`

### 2. Edit Accidents

<a name="list_history"><h4>1. List the history of editing accidents</h4></a>

Request
`GET` `api/v1/accident/history`
Response
```json
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"time_changed": "2021-10-28T12:49:02.895479Z",
"accident_id": 3,
"accident_class": 1,
"description": "Тестовый инцидент"
},
{
"id": 2,
"time_changed": "2021-10-28T14:20:55.233350Z",
"accident_id": 1,
"accident_class": 2,
"description": "Тип травма изменен на Тип некомплектность"
}
]
}
```

<a name="create_history"><h4>2. Create a history record (Edit existing accident)</h4></a>

Request
`POST` `api/v1/accident/`

Body
```json
{
"accident_id": 2,
"accident_class": 3,
"description": "Refactored"
}
```
Response
```json
{
"accident_id": 2,
"accident_class": 3,
"description": "Refactored"
}
```
File renamed without changes.
Binary file added accident/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/apps.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/filters.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/permissions.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/serializers.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added accident/__pycache__/views.cpython-36.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions coreAPI/admin.py → accident/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin
from .models import *
from accident.models import *


admin.site.register(Accident)
admin.site.register(AccidentClass)
admin.site.register(AccidentHistory)

admin.site.register(AccidentHistory)
4 changes: 2 additions & 2 deletions coreAPI/apps.py → accident/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class CoreApiConfig(AppConfig):
class AccidentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'coreAPI'
name = 'accident'
30 changes: 30 additions & 0 deletions accident/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import django_filters
from django_filters import FilterSet
from accident.models import Accident


"""
TODO: Разобраться как передавать класс инцидента и фильтровать, а так же ренж даты
"""

class AccidentFilter(FilterSet):

class Meta:
model = Accident
fields = {
# 'accident_class': ['number',],
'posts_block': ['exact',],
'time_appeared': ['date__range',]
}

@property
def qs(self):
"""Переопределяем геттер queryset'а.
Вернет элемент, зафиксированный последним, с учетом фильтров"""
# возвращает queryset Инцидентов
parent = super().qs
is_last = self.request.query_params.get('last')
if is_last is not None and is_last == "True":
# Необходимо положить в список/кортеж, чтобы пагинатор мог определить длинну последовательности
parent = (parent.latest('time_appeared'), )
return parent
56 changes: 56 additions & 0 deletions accident/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by Django 3.2.8 on 2021-11-15 00:25

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Accident',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time_appeared', models.DateTimeField(default=django.utils.timezone.now, unique=True, verbose_name='Время появления происшествия')),
('time_solved', models.DateTimeField(blank=True, null=True, verbose_name='Время решения происшествия')),
('post', models.IntegerField(verbose_name='Пост с происшествием')),
('description', models.TextField(blank=True, null=True, verbose_name='Описание происшествия')),
],
),
migrations.CreateModel(
name='AccidentClass',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('number', models.IntegerField(verbose_name='Класс происшествия')),
('name', models.CharField(max_length=64, verbose_name='Название класса происшествия')),
],
),
migrations.CreateModel(
name='AccidentHistory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time_changed', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Время внесения изменений')),
('description', models.TextField(blank=True, null=True, verbose_name='Описание происшествия')),
('accident', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='accident_history', to='accident.accident')),
('accident_class', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='accident.accidentclass')),
],
),
migrations.AddField(
model_name='accident',
name='accident_class',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='accident.accidentclass'),
),
migrations.AddField(
model_name='accident',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='accidents', to=settings.AUTH_USER_MODEL),
),
]
18 changes: 18 additions & 0 deletions accident/migrations/0002_rename_post_accident_posts_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.8 on 2021-11-18 07:45

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('accident', '0001_initial'),
]

operations = [
migrations.RenameField(
model_name='accident',
old_name='post',
new_name='posts_block',
),
]
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
44 changes: 19 additions & 25 deletions coreAPI/models.py → accident/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
from django.conf import settings
from django.db import models
from django.conf import settings
from django.utils import timezone

'''
Как только сообщается красная кнопка - фиксация времени.
создание происшествия с начальным временем и номером поста в соответствии с конфигурацией. Accident().save()
Больше одного НЕрешенного происшествия на одном блоке кнопок быть не может.
Значит при нажатии на клиенте на красную кнопку берем последний инцидент (GET + /?last=true)
Причем в соотетствии с конфигурацией (можно ее хранить в локалсторедж), понимаем на какой пост нажали - запрашиваем инцидент по такому посту
подгружаем время фиксации, ставим пост. Менять можно класс, описание. Время решения менять нельзя,
оно выставляется на беке в момент переключения кнопки, в дальнейшем обновится на фронте.
'''




class AccidentClass(models.Model):
"""Таблица с классами инцидентов"""
Expand All @@ -13,15 +25,14 @@ def __str__(self) -> str:


class Accident(models.Model):
objects = None
"""Основная информация происшествия"""
ACC_HIST_ARGS = ('accident_class', 'description')
'''Основная информация происшествия'''
user = models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='accidents', on_delete=models.CASCADE)
user = models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='accidents', on_delete=models.CASCADE, blank=True, null=True)
# Время появления проблемы (момент нажатия кнопки)
time_appeared = models.DateTimeField('Время появления происшествия', blank=False, default=timezone.now, unique=True)
# Время решения проблемы (мастер зарегестрировал в системе) TODO: узнать как это поле заполнять
time_solved = models.DateTimeField('Время решения происшествия', blank=True, null=True)
post = models.IntegerField('Пост с происшествием')
posts_block = models.IntegerField('Пост с происшествием')
accident_class = models.ForeignKey(to=AccidentClass, on_delete=models.SET_NULL, null=True, default=None)
description = models.TextField('Описание происшествия', blank=True, null=True)

Expand All @@ -41,34 +52,17 @@ def add_history_record(self, **kwargs):
return history_record

def __str__(self) -> str:
return f'[{self.user.username}][{self.time_appeared}]: {self.accident_class}'
return f'[{self.time_appeared}]: {self.accident_class}'


class AccidentHistory(models.Model):
"""Таблица истори изменений происшествий"""
objects = None
accident = models.ForeignKey(Accident, related_name='accident_history', on_delete=models.SET_NULL, null=True,
accident = models.ForeignKey(Accident, related_name='accident_history', on_delete=models.CASCADE, null=True,
default=None)
time_changed = models.DateTimeField('Время внесения изменений', blank=False, default=timezone.now)
accident_class = models.ForeignKey(to=AccidentClass, on_delete=models.SET_NULL, null=True)
description = models.TextField('Описание происшествия', blank=True, null=True)

def __str__(self) -> str:
return f'History record [{self.pk}]: {self.accident}'


class ConveyorState(models.Model):
"""Таблица с 28 записями состояний постов"""

objects = None

class StatusChoices(models.IntegerChoices):
ACTIVE = 1
SUCCESS = 2
ERROR = 3

post = models.IntegerField('Номер поста')
status = models.CharField('Статус поста', max_length=12, default='success')

def __str__(self) -> str:
return f'[{self.status}]: post {self.post}'
return f'History record [{self.pk}]: {self.accident}'
2 changes: 1 addition & 1 deletion coreAPI/premissions.py → accident/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def has_object_permission(self, request, view, obj):
return True

# относится только к инцидентам (Accident.user), либо другим моделям, где есть поле user с той же сущностью
return obj.user == request.user
return obj.user == request.user
Loading