Skip to content

Commit

Permalink
add: allow function-based views to be specified for BREAD views, impr…
Browse files Browse the repository at this point in the history
…ove defaults for sqlite database in project template
  • Loading branch information
saemideluxe committed Nov 12, 2024
1 parent e3321de commit 2676669
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
"OPTIONS": {
"transaction_mode": "IMMEDIATE",
"timeout": 5, # seconds
"init_command": """
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
PRAGMA mmap_size = 134217728;
PRAGMA journal_size_limit = 27103364;
PRAGMA cache_size=2000;
""",
},
}
}

Expand Down
57 changes: 41 additions & 16 deletions basxbread/utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,38 +255,63 @@ def default_model_paths(
if browseview is not None:
if browseview is True:
browseview = defaultview["browse"]
ret.append(
autopath(
browseview.as_view(model=model),
model_urlname(model, "browse"),
if isinstance(browseview, type):
ret.append(
autopath(
browseview.as_view(model=model),
model_urlname(model, "browse"),
)
)
)
else:
ret.append(autopath(browseview, model_urlname(model, "browse")))
if readview is not None:
if readview is True:
readview = defaultview["read"]
ret.append(
autopath(readview.as_view(model=model), model_urlname(model, "read"))
)
if isinstance(readview, type):
ret.append(
autopath(readview.as_view(model=model), model_urlname(model, "read"))
)
else:
ret.append(autopath(readview, model_urlname(model, "read")))
if editview is not None:
if editview is True:
editview = defaultview["edit"]
ret.append(
autopath(editview.as_view(model=model), model_urlname(model, "edit"))
)
if isinstance(editview, type):
ret.append(
autopath(editview.as_view(model=model), model_urlname(model, "edit"))
)
else:
ret.append(autopath(editview, model_urlname(model, "edit")))

if addview is not None:
if addview is True:
addview = defaultview["add"]
ret.append(autopath(addview.as_view(model=model), model_urlname(model, "add")))
if isinstance(addview, type):
ret.append(
autopath(addview.as_view(model=model), model_urlname(model, "add"))
)
else:
ret.append(autopath(addview, model_urlname(model, "add")))

if deleteview is not None:
if deleteview is True:
deleteview = defaultview["delete"]
ret.append(
autopath(deleteview.as_view(model=model), model_urlname(model, "delete"))
)
if isinstance(deleteview, type):
ret.append(
autopath(
deleteview.as_view(model=model), model_urlname(model, "delete")
)
)
else:
ret.append(autopath(deleteview, model_urlname(model, "delete")))

if copyview is not None:
if copyview is True:
copyview = generate_copyview(model)
ret.append(autopath(copyview, model_urlname(model, "copy")))
if isinstance(copyview, type):
ret.append(autopath(copyview, model_urlname(model, "copy")))
else:
ret.append(autopath(copyview, model_urlname(model, "copy")))

for viewname, view in kwargs.items():
if isinstance(view, type):
Expand Down

0 comments on commit 2676669

Please sign in to comment.