Skip to content

Commit

Permalink
clean up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
diversen7 committed Jan 10, 2025
1 parent b0ac8b6 commit 2ddafc7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[flake8]
exclude = .git, __pycache__, .mypy_cache, .pytest_cache, venv, .github, \
stadsarkiv_client/templates,stadsarkiv_client/locales, generate_client, tests, \
example-config-aarhus, example-config-simple, example-config-teater, build
example-config-aarhus, example-config-simple, example-config-teater, build, \
bin-local
ignore = E203, W503, E402, E231
max-line-length = 140
2 changes: 1 addition & 1 deletion bin/post_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ async def verify_token(token):
print(f"An error occurred: {error}")


asyncio.run(verify_token("some-test-token"))
asyncio.run(verify_token("some-test-token"))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
line-length = 140

[tool.mypy]
exclude = [ "venv", ".venv", "generate_openaws_client", "tests", "example-config", "build",]
exclude = [ "venv", ".venv", "generate_openaws_client", "tests", "example-config", "build", "bin-local",]

[tool.bump_version]
version_file = "stadsarkiv_client/__init__.py"
Expand Down
1 change: 0 additions & 1 deletion stadsarkiv_client/endpoints/endpoints_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from stadsarkiv_client.records.meta_data_record import get_record_meta_data
from stadsarkiv_client.core.hooks import get_hooks
from stadsarkiv_client.core.logging import get_log
from stadsarkiv_client.core.flash import set_message
from stadsarkiv_client.database import crud_orders
from stadsarkiv_client.database import utils_orders
from stadsarkiv_client.core import flash
Expand Down
21 changes: 10 additions & 11 deletions stadsarkiv_client/endpoints/endpoints_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from stadsarkiv_client.database.cache import DatabaseCache
from stadsarkiv_client.database.crud_default import database_url
from stadsarkiv_client.database.utils import DatabaseConnection
from stadsarkiv_client.core import api
from stadsarkiv_client.core.dynamic_settings import settings
import random

Expand Down Expand Up @@ -83,16 +82,16 @@ async def test_mail(request: Request):

# template_str = await get_template_content("mails/verify_email.html", context)

data_dict = {
"data": {
"user_id": "01944542-2d7b-72bc-82bf-34e735b383cb",
"subject": "Test",
"sender": {"email": "[email protected]", "name": "Aarhus Stadsarkiv"},
"reply_to": {"email": "[email protected]", "name": "Aarhus Stadsarkiv"},
"html_content": "Test Test",
"text_content": "Test Test",
}
}
# data_dict = {
# "data": {
# "user_id": "01944542-2d7b-72bc-82bf-34e735b383cb",
# "subject": "Test",
# "sender": {"email": "[email protected]", "name": "Aarhus Stadsarkiv"},
# "reply_to": {"email": "[email protected]", "name": "Aarhus Stadsarkiv"},
# "html_content": "Test Test",
# "text_content": "Test Test",
# }
# }

# await api.mail_post(request, data_dict)

Expand Down
35 changes: 1 addition & 34 deletions stadsarkiv_client/endpoints/endpoints_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Webhook endpoints
"""

from starlette.responses import JSONResponse, HTMLResponse
from starlette.responses import JSONResponse
from starlette.requests import Request
from stadsarkiv_client.core.logging import get_log
from stadsarkiv_client.core.mail import get_template_content
Expand Down Expand Up @@ -116,36 +116,3 @@ async def mail_reset_token(request: Request):
log.exception("Error in sending reset email to user")

return JSONResponse({"status": "ok", "data": data})


"""
# Test data. This ID will not work if sending to the real API
data: dict = {
"nonce": "ya_X5caNnPNNV8I1DRjogmHzO3xoKBn2OffA5M1we4c",
"context": {},
"original_request_id": "09c74815a76841d98da1268fdcb3b3e6",
"error": None,
"timestamp": 1736240547.001911,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMTk0NDAwMC00NDlhLTc0M2EtYjU4My0yNDJkMjNjMmNjZjgiLCJlbWFpbCI6IjAxOTQ0MDAwNDQ5NjcxMmVhODhiZmFlZjM2ODQ5MTY5QGludGVybmFsLmxvY2FsIiwiYXVkIjoiZmFzdGFwaS11c2Vyczp2ZXJpZnkiLCJleHAiOjE3MzYyNDQxNDZ9.dFuissS8vA7ZESmwPvH-aQy_Hn5zsY0Z4SJUhom9iY0",
"to_user": {
"id": "019265e5-3fd4-7734-990c-7c7660d1ca64",
"email": "[email protected]",
"is_active": True,
"is_verified": False,
"client_id": "demo",
"display_name": "diversen",
"data": {"bookmarks": [], "custom": {"updated": 1736240547, "data": {}}},
"timestamp": 1736240546,
"updated": 1736240546,
"last_login": 1736240546,
"permissions": [
{"name": "user", "grant_id": 6, "entity_id": None},
{"name": "guest", "grant_id": 8, "entity_id": None},
{"name": "read", "grant_id": 9, "entity_id": None},
],
},
}
"""

0 comments on commit 2ddafc7

Please sign in to comment.