-
Notifications
You must be signed in to change notification settings - Fork 0
Enhance profile and pet management features (and add comprehensive test cases) #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
dac7c23
88ffae9
7b344c3
902bb92
d417296
277a694
b9e486e
eca8204
43a3242
8a14683
ca7f089
30a6bac
324885a
9c4ab3a
e010a71
d89115f
c16c9c2
a8830c2
6c9b9e6
66ee036
51925de
b839e9d
f2c0df3
e308343
53d7b9d
125a26f
54e955f
c05c407
f06949b
c7dcf9e
eadc794
c57e755
e068062
c3628ca
f03e48d
7bdaa5c
ba729b8
67d2402
03d4329
2063e6a
c8aa1af
0563785
c298f77
0cd7d05
e8aa8fd
9c378b5
731eb3d
4dc9819
5b9fa50
204a313
04aff46
4c4915c
de6760a
8784c1c
0f9879e
8cfe19a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -167,7 +167,7 @@ | |||||
# https://docs.djangoproject.com/en/4.2/ref/csrf/#how-it-works | ||||||
# CSRF_COOKIE_DOMAIN = "" | ||||||
|
||||||
TOKEN_EXPIRED_AFTER_WEEKS = 2 | ||||||
TOKEN_EXPIRED_AFTER_WEEKS = 1 | ||||||
|
||||||
|
||||||
# Static files (CSS, JavaScript, Images) | ||||||
|
@@ -400,7 +400,15 @@ | |||||
"PASSWORD": os.getenv("DB_PASSWORD"), | ||||||
"HOST": os.getenv("DB_HOST"), | ||||||
"PORT": os.getenv("DB_PORT"), | ||||||
} | ||||||
}, | ||||||
"test": { | ||||||
"ENGINE": os.getenv("DB_ENGINE"), | ||||||
"NAME": "test_" + (os.getenv("DB_NAME") or ""), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: When defining the test database configuration, ensure that the database name is not empty to avoid potential conflicts or errors during testing. This can be achieved by providing a default name for the test database if
Suggested change
|
||||||
"USER": os.getenv("DB_USER"), | ||||||
"PASSWORD": os.getenv("DB_PASSWORD"), | ||||||
"HOST": os.getenv("DB_HOST"), | ||||||
"PORT": os.getenv("DB_PORT"), | ||||||
}, | ||||||
} | ||||||
|
||||||
# Password validation | ||||||
|
@@ -451,14 +459,40 @@ | |||||
|
||||||
|
||||||
class QueryFormatter(logging.Formatter): | ||||||
""" | ||||||
This formatter class is designed to enhance logging capabilities by | ||||||
formatting SQL queries to be more readable. It checks for the presence | ||||||
of an SQL query in the log record and formats it using `sqlparse` for | ||||||
better readability in the logs. | ||||||
""" | ||||||
|
||||||
def format(self, record): | ||||||
# Implementation remains the same... | ||||||
record.prettysql = "" | ||||||
try: | ||||||
_, rawsql, *_ = record.args | ||||||
except ValueError: | ||||||
print("record.args does not contain enough values to unpack") | ||||||
if hasattr(record, "sql"): | ||||||
# If record has 'sql' attribute, use it directly | ||||||
rawsql = record.sql | ||||||
elif ( | ||||||
hasattr(record, "args") | ||||||
and isinstance(record.args, tuple) | ||||||
and len(record.args) > 1 | ||||||
): | ||||||
# If record has 'args' and it's a tuple with at least 2 elements | ||||||
rawsql = record.args[1] | ||||||
else: | ||||||
# If we can't find SQL, just use an empty string | ||||||
rawsql = "" | ||||||
|
||||||
if isinstance(rawsql, str): | ||||||
try: | ||||||
record.prettysql = sqlparse.format(rawsql, reindent=True) | ||||||
except Exception as e: | ||||||
# If formatting fails, just use the raw SQL | ||||||
record.prettysql = rawsql | ||||||
print(f"SQL formatting failed: {e}") | ||||||
else: | ||||||
record.prettysql = sqlparse.format(rawsql, reindent=True) | ||||||
# If rawsql is not a string, convert it to a string | ||||||
record.prettysql = str(rawsql) | ||||||
|
||||||
# Call the original formatter class to do the actual formatting | ||||||
return super().format(record) | ||||||
|
@@ -488,7 +522,7 @@ def format(self, record): | |||||
"filters": ["request_id"], | ||||||
}, | ||||||
"console_db": { | ||||||
"level": "DEBUG", | ||||||
"level": "FATAL", | ||||||
"class": "logging.StreamHandler", | ||||||
"formatter": "sql", | ||||||
"filters": ["request_id"], | ||||||
|
@@ -508,3 +542,17 @@ def format(self, record): | |||||
}, | ||||||
"root": {"level": LOG_LEVEL, "handlers": ["console"]}, | ||||||
} | ||||||
|
||||||
if DEBUG: | ||||||
# RunServerPlus settings | ||||||
# https://django-extensions.readthedocs.io/en/stable/runserver_plus.html | ||||||
RUNSERVER_PLUS_PRINT_SQL_TRUNCATE = 1000 | ||||||
RUNSERVERPLUS_POLLER_RELOADER_TYPE = "stat" # or 'watchdog' or 'auto' | ||||||
RUNSERVER_PLUS_EXCLUDE_PATTERNS = [ | ||||||
"*.sqlite3", | ||||||
"*.sqlite3-journal", | ||||||
"#{BASE_DIR}/.local/*", | ||||||
"#{BASE_DIR}/.git/*", | ||||||
"**/.pytest_cache/*", | ||||||
"**/__pycache__/*", | ||||||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: For the
TOKEN_EXPIRED_AFTER_WEEKS
setting, consider documenting the reason for changing the token expiration from 2 weeks to 1 week. This helps maintainers understand the security considerations or business requirements driving this change. [enhancement, importance: 7]