Skip to content

Commit 54c7e5f

Browse files
authored
Merge branch 'INRIM:2.1' into 2.1
2 parents 54ba662 + 795da71 commit 54c7e5f

File tree

163 files changed

+2378
-36942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+2378
-36942
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Service App is a project and framework designed to
1010
- available plugin class system to build your own backend and/or frontend custom service
1111
- documentation for plugin development is in WIP
1212

13+
Read the complete [Documentations ](docs/index.md)
14+
1315
### TODO
1416

1517
- i18n

backend/ozon/core/ModelData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ async def clean_expired_to_delete_record(self):
662662
if data_model:
663663
if name == "session":
664664
res = await clean_session(datetime.now().isoformat())
665-
logger.info(f" clean to delete {name} {res}")
665+
logger.info(f" clean to delete {res} useless session")
666666
else:
667667
res = await erese_all_to_delete_record(data_model)
668668
logger.info(f" clean to delete {name} {res}")

backend/ozon/core/OzonRawMiddleware.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
# Copyright INRIM (https://www.inrim.eu)
22
# See LICENSE file for full licensing details.
33

4-
from typing import Optional, Sequence, Union, Any
5-
from fastapi.responses import RedirectResponse, JSONResponse
4+
from typing import Optional, Union, Any
65

76
from starlette.requests import HTTPConnection, Request
87
from starlette.types import Message, Receive, Scope, Send
98
from fastapi import FastAPI
109
from .Ozon import Ozon
11-
from .SessionMain import SessionMain, SessionBase
1210
import logging
1311
import bson
1412

1513
logger = logging.getLogger(__name__)
1614

1715

16+
1817
class OzonRawMiddleware:
1918
def __init__(
20-
self, app: FastAPI, settings, pwd_context: Optional[Any] = None
19+
self, app: FastAPI, settings, pwd_context: Optional[Any] = None
2120
) -> None:
2221
self.app = app
2322
self.pwd_context = pwd_context
@@ -26,7 +25,7 @@ def __init__(
2625

2726
@staticmethod
2827
def get_request_object(
29-
scope, receive, send
28+
scope, receive, send
3029
) -> Union[Request, HTTPConnection]:
3130
# here we instantiate HTTPConnection instead of a Request object
3231
# because only headers are needed so that's sufficient.
@@ -35,7 +34,7 @@ def get_request_object(
3534
return Request(scope, receive, send)
3635

3736
async def __call__(
38-
self, scope: Scope, receive: Receive, send: Send
37+
self, scope: Scope, receive: Receive, send: Send
3938
) -> None:
4039
if scope["type"] not in ("http", "websocket"): # pragma: no cover
4140
await self.app(scope, receive, send)
@@ -62,8 +61,8 @@ async def send_wrapper(message: Message) -> None:
6261
f"object: {request.scope['ozon']} , params: {request.query_params}, headers{request.headers}"
6362
)
6463
# self.session = await self.init_request(request)
65-
66-
if not session or session is None:
64+
logger.info(f'Is public {request.scope["ozon"].auth_service.is_public_endpoint()}')
65+
if not session or session is None and not request.scope["ozon"].auth_service.is_public_endpoint():
6766
response = request.scope["ozon"].auth_service.login_page()
6867
await response(scope, receive, send)
6968
else:

backend/ozon/core/ServiceAuth.py

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
# Copyright INRIM (https://www.inrim.eu)
22
# See LICENSE file for full licensing details.
3-
import sys
43
import os
5-
from os import listdir
6-
from os.path import isfile, join
7-
from fastapi.responses import RedirectResponse, JSONResponse
8-
import ujson
4+
import uuid
95

10-
# from ozon.settings import get_settings
11-
from .database.mongo_core import *
12-
from collections import OrderedDict
13-
from pathlib import Path
146
from fastapi import Request
15-
from .SessionMain import SessionMain
7+
from fastapi.responses import JSONResponse
8+
9+
from .BaseClass import PluginBase
1610
from .ModelData import ModelData
17-
from .BaseClass import BaseClass, PluginBase
18-
from pydantic import ValidationError
11+
from .SessionMain import SessionMain
12+
# from ozon.settings import get_settings
13+
from .database.mongo_core import *
1914

20-
import logging
21-
import pymongo
22-
import requests
23-
import httpx
24-
import uuid
25-
from cryptography.fernet import Fernet
2615

2716
logger = logging.getLogger(__name__)
2817

@@ -37,13 +26,13 @@ def __init_subclass__(cls, **kwargs):
3726
class ServiceAuthBase(ServiceAuth):
3827
@classmethod
3928
def create(
40-
cls,
41-
settings=None,
42-
public_endpoint="",
43-
parent=None,
44-
request=None,
45-
pwd_context=None,
46-
req_id="",
29+
cls,
30+
settings=None,
31+
public_endpoint="",
32+
parent=None,
33+
request=None,
34+
pwd_context=None,
35+
req_id="",
4736
):
4837
self = ServiceAuthBase()
4938
self.init(
@@ -52,13 +41,13 @@ def create(
5241
return self
5342

5443
def init(
55-
self,
56-
settings=None,
57-
public_endpoint="",
58-
parent=None,
59-
request=None,
60-
pwd_context=None,
61-
req_id="",
44+
self,
45+
settings=None,
46+
public_endpoint="",
47+
parent=None,
48+
request=None,
49+
pwd_context=None,
50+
req_id="",
6251
):
6352
self.session = None
6453
self.app_code = parent.app_code
@@ -155,7 +144,7 @@ async def check_default_token_header(self):
155144
logger.debug(f"ws_request {apitoken}")
156145
self.ws_request = True
157146
self.token = apitoken
158-
logger.info(f" Is WS {self.ws_request} with token {self.token}")
147+
logger.debug(f" Is WS {self.ws_request} with token {self.token}")
159148

160149
async def check_session(self):
161150
logger.info("check_session")
@@ -190,7 +179,7 @@ async def init_session(self):
190179
self.session = await self.session_service.find_session_by_token()
191180
if not self.session and self.is_public_endpoint:
192181
self.session = await self.create_session_public_user()
193-
if self.session.expire_datetime < datetime.now():
182+
if self.session and self.session.expire_datetime < datetime.now():
194183
self.session.active = False
195184
await self.mdata.save_record(self.session)
196185
self.session = None

backend/ozon/core/database/mongodb/mongo_base.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ async def set_to_delete_records(model: Type[ModelType], query={}):
481481
days=settings.delete_record_after_days
482482
)
483483
rec.deleted = delete_at_datetime.timestamp()
484+
rec.active = False
484485
await engine.save(rec)
485486
return True
486487

@@ -498,6 +499,7 @@ async def set_to_delete_record(schema: Type[ModelType], rec):
498499
days=settings.delete_record_after_days
499500
)
500501
rec.deleted = delete_at_datetime.timestamp()
502+
rec.active = False
501503
return await save_record(rec, remove_meta=False)
502504

503505

@@ -506,35 +508,24 @@ async def retrieve_all_to_delete(model: Type[ModelType]):
506508
q = {
507509
"$and": [{"deleted": {"$gt": 0}}, {"deleted": {"$lt": curr_timestamp}}]
508510
}
509-
res = await search_by_filter(model, q)
510-
return res
511+
# res = await search_by_filter(model, q)
512+
return q
511513

512514

513515
async def erese_all_to_delete_record(model: Type[ModelType]):
514-
res = await retrieve_all_to_delete(model)
516+
query = await retrieve_all_to_delete(model)
515517
coll = db.engine.get_collection(model.str_name())
516-
for rec in res:
517-
if isinstance(rec, dict):
518-
name = rec["rec_name"]
519-
else:
520-
name = rec.rec_name
521-
await coll.delete_one({"rec_name": name})
522-
return f"removed {len(res)} records"
518+
res = await coll.delete_many(query)
519+
return f"removed {res.deleted_count} records"
523520

524521

525522
async def clean_session(date_expire):
526-
res_to_expire = await search_by_filter(
527-
Session, {"expire_datetime": {"$lt": date_expire}}
528-
)
529523
coll = db.engine.get_collection("session")
530-
for item in res_to_expire:
531-
await coll.delete_one({"_id": item["_id"]})
532-
res = await search_by_filter(
533-
Session, {"$or": [{"active": False}, {"is_public": True}]}
534-
)
535-
for rec in res:
536-
await coll.delete_one({"_id": rec["_id"]})
537-
return f"removed {len(res) + len(res_to_expire)} records"
524+
res = await coll.delete_many({"expire_datetime": {"$lt": date_expire}})
525+
res2 = await coll.delete_many(
526+
{"$or": [{"active": False}, {"is_public": True}]})
527+
528+
return f"removed {res.deleted_count + res2.deleted_count} records"
538529

539530

540531
## TODO handle archiviations

build_and_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ source ${PWD}/.env
33
CURRPATH=${PWD}
44
#./init.sh
55
echo "Update"
6-
docker-compose -f docker-compose.yml -p ${APP_CODE} --profile core-only stop
7-
docker-compose -f docker-compose.yml --env-file .env -p ${APP_CODE} --profile core-only --compatibility up -d
6+
docker compose -f docker-compose.yml -p ${APP_CODE} --profile core-only stop
7+
docker compose -f docker-compose.yml --env-file .env -p ${APP_CODE} --profile core-only --compatibility up -d

deploy.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ echo "setup coplete"
1111
cd $CURRPATH
1212
if [ -e "$PWD/docker-compose-custom.yml" ]; then
1313
echo "setup compose custom"
14-
docker-compose -f docker-compose-custom.yml -p ${STACK} --profile all stop
15-
docker-compose -f docker-compose-custom.yml -p ${STACK} --env-file .env build --no-cache --rm=false .
16-
docker-compose -f docker-compose-custom.yml -p ${STACK} --profile all --compatibility up --force-recreate --always-recreate-deps --detach --build
14+
docker compose -f docker-compose-custom.yml -p ${STACK} --profile all stop
15+
docker compose -f docker-compose-custom.yml -p ${STACK} --env-file .env build --no-cache --rm=false .
16+
docker compose -f docker-compose-custom.yml -p ${STACK} --profile all --compatibility up --force-recreate --always-recreate-deps --detach --build
1717
else
1818
echo "setup compose ${APP_NAME}"
19-
docker-compose -f docker-compose.yml --env-file .env -p ${STACK} --profile all stop
20-
docker-compose -f docker-compose.yml --env-file .env -p ${STACK} --profile all --compatibility up --force-recreate --always-recreate-deps --detach --build
19+
docker compose -f docker-compose.yml --env-file .env -p ${STACK} --profile all stop
20+
docker compose -f docker-compose.yml --env-file .env -p ${STACK} --profile all --compatibility up --force-recreate --always-recreate-deps --detach --build
2121
fi
2222

2323
sh update.sh automation

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ services:
9393
restart: always
9494

9595
automation:
96-
profiles: [ "all" ]
96+
profiles: [ "all", "automation" ]
9797
stdin_open: true # -i
9898
tty: true
9999
build:

docs/en/.base.md.swp

12 KB
Binary file not shown.

docs/en/base.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Form Builder Components
2+
3+
All components in the builder are or are derived from the default components of [Formio.js](https://formio.github.io/formio.js/app/builder)
4+
The system integrates this tool for creating Drag&Drop forms and makes them available to the user in the form of an App with [graphics adhering to AGID guidelines](https://italia.github.io/bootstrap-italia/docs/come-iniziare/introduzione/)
5+
Not all the features of Formio.js have been managed but only those useful for the purpose of the project.
6+
As regards the basic functionality of the project, see [general documentation of the application](index.md#L60)
7+
8+
## **Metadata**
9+
Metadata is data present in each model (form) and is automatically enhanced when creating/modifying a form record.
10+
The list of metadata is as follows:
11+
**id, rec_name, owner_uid, owner_name, owner_sector, owner_sector_id, owner_function, update_datetime,create_datetime,owner_function_type, sys, demo, deleted, list_order, owner_personal_type, owner_job_title**
12+
13+
# Basic functionality of all components:
14+
### The following properties are managed in the components:
15+
**Display:**
16+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Custom CSS Class →** classes can be used [Bootstrap 4](https://italia.github.io/bootstrap-italia/1.x/docs/utilities/colori/)
17+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Hidden →** set the field hidden or not
18+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Disabled →** disables the field and makes it read-only and does not save the data.
19+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Table View →** displays the field in the list view or not
20+
**Validation:**
21+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Required →** makes the field mandatory in the form
22+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Unique →** checks that the field value is unique in the db, renders the field mandatory in the form
23+
**Api:**
24+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Property Name → is the name of the field in the database
25+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**Custom Properties →** this configuration depends on the type of functionality adds the field; Yessee the specific documentation of the components
26+
**Conditional:**
27+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Advanced Conditions [Json-logic](logic.md#Guide)
28+
**Logic:**
29+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Json-logic](logic.md#Guide)
30+
### <font color="#FA8072">In the components the following properties are **<font color = "#ff6063">not</font>** managed:</font>
31+
32+
**Display:**
33+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label Position
34+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initial Focus
35+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hide Label
36+
37+
**Validation:**
38+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Validate On
39+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error Label
40+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Custom Error Message
41+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Custom Validation
42+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JSONLogic-Validation
43+
44+
**API:**
45+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Field Tags
46+
**Conditional:**
47+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Simple
48+
49+
### Icons
50+
Regarding the icons and images available in the interfaces, refer to [official AGID guide](https://italia.github.io/bootstrap-italia/docs/utilities/icone/).
51+
52+
[Return home](index.md)

0 commit comments

Comments
 (0)