Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jul 5, 2024
1 parent 4c353f3 commit d85ed39
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
max-complexity = 12
max-line-length = 120
max-line-length = 88
exclude =
.*/
__pycache__
Expand All @@ -12,3 +12,4 @@ exclude =
per-file-ignores =
src/**/migrations/*.py:E501
src/**/upgrade.py:E731
src/**/upgrade.py:E731
2 changes: 1 addition & 1 deletion .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'App CodeQL Config'

paths-ignore:
- '**/tests/**'
- '**/tests/**'
2 changes: 1 addition & 1 deletion .pdm-python
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/Users/sax/Documents/data/PROGETTI/UNICEF/hope-country-workspace/.venv/bin/python
/Users/sax/Documents/data/PROGETTI/UNICEF/hope-country-workspace/.venv/bin/python
2 changes: 1 addition & 1 deletion docker/bin/wait-for-it.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ if [[ $WAITFORIT_CLI != "" ]]; then
exec "${WAITFORIT_CLI[@]}"
else
exit $WAITFORIT_RESULT
fi
fi
2 changes: 1 addition & 1 deletion docker/conf/mime.types
Original file line number Diff line number Diff line change
Expand Up @@ -2184,4 +2184,4 @@ video/x-sgi-movie movie

x-conference/x-cooltalk ice
x-epoc/x-sisx-app sisx
x-world/x-vrml vrm vrml wrl
x-world/x-vrml vrm vrml wrl
4 changes: 3 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
sys.path.insert(0, SRC)

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hope_country_workspace.config.settings")
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "hope_country_workspace.config.settings"
)

from django.core.management import execute_from_command_line

Expand Down
90 changes: 89 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dev = [
"responses>=0.25.3",
"pytest-factoryboy>=2.7.0",
"django-webtest>=1.9.11",
"pre-commit>=3.7.1",
]

[tool.black]
Expand Down
13 changes: 10 additions & 3 deletions src/hope_country_workspace/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def setting(anchor: str) -> str:
return f"@see {DJANGO_HELP_BASE}#{anchor}"


def celery_doc(anchor: str) -> str:
return (
f"@see https://docs.celeryq.dev/en/stable/"
f"userguide/configuration.html#{anchor}"
)


class Group(Enum):
DJANGO = 1

Expand Down Expand Up @@ -46,18 +53,18 @@ class Group(Enum):
"CELERY_TASK_ALWAYS_EAGER": (
bool,
False,
"https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_always_eager",
f"{celery_doc}#std-setting-task_always_eager",
True,
),
"CELERY_TASK_EAGER_PROPAGATES": (
bool,
True,
"https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-eager-propagates",
f"{celery_doc}#task-eager-propagates",
),
"CELERY_VISIBILITY_TIMEOUT": (
int,
1800,
"https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-transport-options",
f"{celery_doc}#broker-transport-options",
),
"CSRF_COOKIE_SECURE": (bool, True, setting("csrf-cookie-secure")),
"DATABASE_URL": (
Expand Down
1 change: 0 additions & 1 deletion src/hope_country_workspace/config/fragments/celery.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from ..settings import env # type: ignore[attr-defined]

CELERY_ACCEPT_CONTENT = ["pickle", "json", "application/text", "application/json"]
# CELERY_BROKER_TRANSPORT_OPTIONS = {"visibility_timeout": int(CELERY_BROKER_VISIBILITY_VAR)}
CELERY_BROKER_URL = env("CELERY_BROKER_URL")
CELERY_BROKER_VISIBILITY_VAR = env("CELERY_VISIBILITY_TIMEOUT")

Expand Down
3 changes: 2 additions & 1 deletion src/hope_country_workspace/config/fragments/csp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CSP_DEFAULT_SRC = ["'self'", "'unsafe-inline'", "'same-origin'", "fonts.googleapis.com", 'fonts.gstatic.com', 'data:',
# CSP_DEFAULT_SRC = ["'self'", "'unsafe-inline'", "'same-origin'",
# "fonts.googleapis.com", 'fonts.gstatic.com', 'data:',
# 'blob:', "cdn.redoc.ly"]
CSP_DEFAULT_SRC = ["'self'", "'unsafe-inline'"]
CSP_STYLE_SRC = [
Expand Down
1 change: 0 additions & 1 deletion src/hope_country_workspace/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@


DEFAULT_FROM_EMAIL = "[email protected]"
# EMAIL_BACKEND = "djcelery_email.backends.CeleryEmailBackend" # TODO: when ready, add djcelery_email
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
EMAIL_HOST = env("EMAIL_HOST", default="")
EMAIL_HOST_USER = env("EMAIL_HOST_USER", default="")
Expand Down
2 changes: 1 addition & 1 deletion src/hope_country_workspace/tenant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, prefix: str):
setting_changed.connect(self._on_setting_changed)

def _set_attr(self, prefixed_name: str, value: "Any") -> None:
name = prefixed_name[(len(self.prefix) + 1) :]
name = prefixed_name[(len(self.prefix) + 1) :] # noqa
setattr(self, name, value)

@cached_property
Expand Down
3 changes: 2 additions & 1 deletion src/hope_country_workspace/tenant/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def get_tenant_filter(self) -> "Dict[str, Any]":
tenant_filter_field = self.model.Tenant.tenant_filter_field
if not tenant_filter_field:
raise ValueError(
f"Set 'tenant_filter_field' on {self} or override `get_queryset()` to enable queryset filtering"
f"Set 'tenant_filter_field' on {self} or override "
f"`get_queryset()` to enable queryset filtering"
)
if tenant_filter_field == "__all__":
return {}
Expand Down
6 changes: 0 additions & 6 deletions src/hope_country_workspace/tenant/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,3 @@ def process_response(
if response:
state.set_cookies(response)
state.reset()

# @contextlib.contextmanager
# def context(self, request: "AuthHttpRequest", response: "HttpResponse|None" = None) -> "Iterator[None]":
# self.process_request(request)
# yield
# self.process_response(request, response)
4 changes: 2 additions & 2 deletions tests/tenant/test_tenant_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.contrib.auth.models import AnonymousUser

import pytest
from pytest_factoryboy import register
from testutils.factories import UserFactory
from testutils.perms import user_grant_permissions

from hope_country_workspace.state import state
Expand All @@ -15,8 +17,6 @@

_DATA = namedtuple("_DATA", "afg,ukr")

from pytest_factoryboy import register
from testutils.factories import UserFactory

register(UserFactory)

Expand Down

0 comments on commit d85ed39

Please sign in to comment.