Compare commits
56
Commits
bbe550b8a9
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1be7152a7 | ||
|
|
aa14131757 | ||
|
|
21a76418fe | ||
|
|
4223ec2e72 | ||
|
|
8981fe6fda | ||
|
|
f434e39c32 | ||
|
|
1417057160 | ||
|
|
742b4bfc32 | ||
|
|
bc0775eafe | ||
|
|
c778d3422c | ||
|
|
14f9040456 | ||
|
|
8dfa89c6b6 | ||
|
|
a32111fbf4 | ||
|
|
6772c5e408 | ||
|
|
156012ad64 | ||
|
|
d3429cefb4 | ||
|
|
397a1844b5 | ||
|
|
412e9f03bb | ||
|
|
76342d3d55 | ||
|
|
eced2dc1e9 | ||
|
|
e692a50efc | ||
|
|
f097fd8c43 | ||
|
|
e211b7f680 | ||
|
|
72ade7f92c | ||
|
|
72f8196acf | ||
|
|
b087d9822e | ||
|
|
785f6ac8b9 | ||
|
|
20d80d76f0 | ||
|
|
6a75825a88 | ||
|
|
5599476730 | ||
|
|
d13738069e | ||
|
|
5aec5ae176 | ||
|
|
186cf4411e | ||
|
|
435e0260e5 | ||
|
|
eaf6b09349 | ||
|
|
405639329c | ||
|
|
719b9d7000 | ||
|
|
e3270d64bf | ||
|
|
f97d8e53b1 | ||
|
|
1d8b138b62 | ||
|
|
75cc0b46f9 | ||
|
|
3cddbe4922 | ||
|
|
58645f87ea | ||
|
|
b58b56249a | ||
|
|
5ec51451ee | ||
|
|
8d4bcfdf0c | ||
|
|
8f474a1081 | ||
|
|
be28592dfa | ||
|
|
11087ead17 | ||
|
|
2bfc56ea81 | ||
|
|
dcc02ab60d | ||
|
|
4017708282 | ||
|
|
4df2a1dede | ||
|
|
b6cfe62724 | ||
|
|
96dd142899 | ||
|
|
7ae97c27a0 |
@@ -52,24 +52,6 @@ paths:
|
||||
$ref: '#/components/schemas/patch_notes'
|
||||
"400":
|
||||
description: bad payload
|
||||
|
||||
/patchnotes/all:
|
||||
get:
|
||||
tags: [Patchnotes]
|
||||
summary: Returns **all** patch notes (admin area)
|
||||
operationId: listAllPatchnotes
|
||||
responses:
|
||||
"200":
|
||||
description: list of all patch notes
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/patch_notes'
|
||||
"404":
|
||||
description: no Patch notes found
|
||||
|
||||
/patchnotes/{patchID}:
|
||||
parameters:
|
||||
- in: path
|
||||
|
||||
@@ -24,7 +24,7 @@ app = connexion.FlaskApp(__name__, specification_dir='./openapi/')
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
position=MiddlewarePosition.BEFORE_EXCEPTION,
|
||||
allow_origin_regex=r"^(https?://)(.*kanzleiapp\.io|.*masasana\.ai|localhost:4200)$",
|
||||
allow_origin_regex=r"^https?://(.*\.kanzleiapp\.io|.*\.masasana\.ai|localhost:4200)$",
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
@@ -19,6 +19,7 @@ from openapi_server.__main__ import collection, last_login_collection
|
||||
from openapi_server.models.patch_notes import PatchNotes
|
||||
from openapi_server.utils.auth import current_user_id
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
def create_patchnote(body): # noqa: E501
|
||||
"""Creates new patch notes
|
||||
@@ -123,15 +124,19 @@ def get_patchnote(patch_id): # noqa: E501
|
||||
def list_patchnotes(since: str | None = None):
|
||||
"""GET /patchnotes – liefert neue Patchnotes und setzt last_login."""
|
||||
|
||||
user_id = current_user_id() # 1) aktueller Benutzer
|
||||
user_id = current_user_id() # 1) aktueller Benutzer
|
||||
last_login_doc = last_login_collection.find_one(
|
||||
{"user_id": user_id},
|
||||
{"_id": 0, "last_login": 1}
|
||||
)
|
||||
last_login = last_login_doc.get("last_login") if last_login_doc else None
|
||||
|
||||
# 2) Wenn ?since fehlt, gespeichertes last_login holen
|
||||
if since is None:
|
||||
rec = last_login_collection.find_one({"user_id": user_id})
|
||||
since = rec["last_login"] if rec else None
|
||||
|
||||
# 3) Datum validieren (nur wenn vorhanden)
|
||||
query = {}
|
||||
logging.info("since" + str(since))
|
||||
logging.info("last_login" + str(last_login))
|
||||
if since:
|
||||
logging.info("Went into if since")
|
||||
|
||||
try:
|
||||
datetime.strptime(since, "%Y-%m-%d")
|
||||
except ValueError:
|
||||
@@ -140,12 +145,31 @@ def list_patchnotes(since: str | None = None):
|
||||
detail="since must be YYYY-MM-DD",
|
||||
status=400,
|
||||
)
|
||||
mongo_filter = {"patch_date": {"$gte": since}}
|
||||
else:
|
||||
mongo_filter = {} # erster Login → alle Notes
|
||||
query = {
|
||||
"patch_date": {
|
||||
"$gte": since,
|
||||
"$lte": last_login
|
||||
}
|
||||
}
|
||||
|
||||
# 3) Datum validieren (nur wenn vorhanden)
|
||||
elif since is None:
|
||||
logging.info("Went into if since is None")
|
||||
try:
|
||||
docs = collection.find({})
|
||||
for d in docs:
|
||||
d.pop("_id", None)
|
||||
if isinstance(d["patch_date"], (datetime, date)):
|
||||
d["patch_date"] = d["patch_date"].isoformat()
|
||||
except ValueError as e:
|
||||
raise ProblemException(
|
||||
title="Internal Server Error",
|
||||
detail=str(e),
|
||||
status=500,
|
||||
)
|
||||
# 4) Patchnotes abholen
|
||||
docs = list(collection.find(mongo_filter).sort("patch_date", 1))
|
||||
|
||||
docs = list(collection.find(query).sort("patch_date", 1))
|
||||
for d in docs:
|
||||
d.pop("_id", None)
|
||||
if isinstance(d["patch_date"], (datetime, date)):
|
||||
@@ -158,7 +182,6 @@ def list_patchnotes(since: str | None = None):
|
||||
{"$set": {"last_login": today}},
|
||||
upsert=True,
|
||||
)
|
||||
|
||||
return Response(json_util.dumps(docs), mimetype="application/json", status=200)
|
||||
|
||||
|
||||
@@ -219,5 +242,3 @@ def update_patchnote(patch_id, body): # noqa: E501
|
||||
mimetype="application/json",
|
||||
status=200,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class PatchNotes(Model):
|
||||
'title': str,
|
||||
'changes': str,
|
||||
'version': str,
|
||||
'patch_date': date,
|
||||
'patch_date': str,
|
||||
'project': str
|
||||
}
|
||||
|
||||
|
||||
@@ -65,24 +65,6 @@ paths:
|
||||
tags:
|
||||
- Patchnotes
|
||||
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
|
||||
/patchnotes/all:
|
||||
get:
|
||||
operationId: list_all_patchnotes
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/patch_notes'
|
||||
type: array
|
||||
description: list of all patch notes
|
||||
"404":
|
||||
description: no Patch notes found
|
||||
summary: Returns **all** patch notes (admin area)
|
||||
tags:
|
||||
- Patchnotes
|
||||
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
|
||||
/patchnotes/{patchID}:
|
||||
delete:
|
||||
operationId: delete_patchnote
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
eeee
|
||||
123
|
||||
Reference in New Issue
Block a user