Skip to content
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

Upgrade demo to django 4.1 #50

Merged
merged 9 commits into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/Dockerfile
Expand Up @@ -14,7 +14,7 @@ ADD media /demo/media
ADD templates /demo/templates
ADD db.sqlite3 /demo/db.sqlite3

RUN pip install --no-cache-dir $POETRY_EXPORT "django<4" django-semantic-admin sentry-sdk
RUN pip install --no-cache-dir $POETRY_EXPORT django-semantic-admin sentry-sdk

# Start the server
ENTRYPOINT ["gunicorn", "--chdir", "/demo", "--bind", "0.0.0.0:8080", "demo.wsgi:application"]
477 changes: 179 additions & 298 deletions poetry.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions pyproject.toml
Expand Up @@ -16,19 +16,19 @@ python = ">=3.8,<4.0"
django = ">=3.2"

[tool.poetry.dev-dependencies]
flake8 = "^3.8.4"
black = "^20.8b1"
isort = "^5.7.0"
Pillow = "^9.0.0"
django-taggit = "^1.3.0"
django-filter = "^2.4.0"
invoke = "^1.5.0"
factory-boy = "^3.2.0"
Faker = ">=8.9.1"
gunicorn = "^20.0.4"
whitenoise = "^5.2.0"
mkdocs = "^1.1.2"
python-decouple = "^3.5"
flake8 = "*"
black = "*"
isort = "*"
Pillow = "*"
django-taggit = "*"
django-filter = "*"
invoke = "*"
factory-boy = "*"
Faker = "*"
gunicorn = "*"
whitenoise = "*"
mkdocs = "*"
python-decouple = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
164 changes: 0 additions & 164 deletions semantic_admin/static/admin_ordering/admin_ordering.js

This file was deleted.

Expand Up @@ -21,6 +21,13 @@
min-width: 0px;
}

/* Fix full-height bottom off by 2px */
#app-main .full.height > .computer-menu > .ui.inverted.menu {
border-top: 1px solid transparent !important;
border-bottom: 1px solid transparent !important;
border-radius: 0 !important;
}

/* Hide Top Bar */
@media only screen and (min-width: 1145px) {
#app-main .full.height {
Expand All @@ -41,9 +48,3 @@
margin-top: 3em;
}
}

@media print {
.page-break {
page-break-inside: avoid;
}
}
34 changes: 1 addition & 33 deletions semantic_admin/static/semantic_admin/unsemantic.css
Expand Up @@ -12,30 +12,10 @@ body,
margin-top: 0 !important;
}

.red {
color: #db2828;
}

.error-red {
color: #9f3a38;
}

.green {
color: #21ba45;
}

.help {
.help:not(.help-tooltip) {
padding-top: 0.5em;
}

.c-sf-add-button {
color: #333 !important;
}

button.c-sf-button:hover {
background-color: #808080 !important;
}

.hidden, .empty-form {
display: none !important;
}
Expand All @@ -46,18 +26,6 @@ button.c-sf-button:hover {
}
}

.no-horizontal-padding {
padding-left: 0;
padding-right: 0;
}

/* Helper class rescued from previous pure.css admin */
@media (min-width: 48em) {
.text-align-right-md {
text-align: right;
}
}

/* CHECKBOX */

div.ui.checkbox:not(.changelist) {
Expand Down
5 changes: 2 additions & 3 deletions semantic_admin/templates/admin/base.html
Expand Up @@ -8,9 +8,8 @@

<!-- Style -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.8.7/dist/semantic.min.css">
<!--
-->
<link rel="stylesheet" href="{% static "semantic_admin/custom.css" %}" />

<link rel="stylesheet" href="{% static "semantic_admin/semantic-admin.css" %}" />
<link rel="stylesheet" href="{% static "semantic_admin/unsemantic.css" %}" />
{% block extrastyle %}{% endblock %}
{% block responsive %}
Expand Down
4 changes: 2 additions & 2 deletions semantic_admin/templates/admin/menu.html
Expand Up @@ -19,8 +19,8 @@
<div class="ui inverted accordion">
{% for app in app_list %}
<div class="item">
<div class="title{% if app.is_current %} active{% endif %}" href="{{ app.app_url }}" title="{% blocktrans with name=app.name %}Models in the {{ app.name }} application{% endblocktrans %}"><i class="small dropdown icon"></i> {{ app.name|title }}</div>
<div class="content{% if app.is_current %} active{% endif %}">
<div class="title{% if app.is_active %} active{% endif %}" href="{{ app.app_url }}" title="{% blocktrans with name=app.name %}Models in the {{ app.name }} application{% endblocktrans %}"><i class="small dropdown icon"></i> {{ app.name|title }}</div>
<div class="content{% if app.is_active %} active{% endif %}">
{% for model in app.models %}
{% if model.admin_url %}
<a class="item" href="{{ model.admin_url }}">{{ model.name }}</a>
Expand Down
7 changes: 5 additions & 2 deletions semantic_admin/templatetags/semantic_sidebar.py
Expand Up @@ -13,10 +13,13 @@ def get_semantic_sidebar(app_list, current_app):
ordered = []
for app_label in semantic_sidebar:
for app in app_list:
is_current = app["app_label"] == current_app
app["is_current"] = is_current
is_active = app["app_label"] == current_app
app["is_active"] = is_active
if app_label == app["app_label"]:
ordered.append(app)
has_active = any([app["is_active"] for app in ordered])
if len(ordered) and not has_active:
ordered[0]["is_active"] = True
app_list = ordered
return app_list

Expand Down
19 changes: 14 additions & 5 deletions semantic_admin/views/autocomplete.py
Expand Up @@ -4,6 +4,8 @@


class SemanticAutocompleteJsonView(AutocompleteJsonView):
# TODO: Delete overridden get method once serialize_result is released
# in a future Django version
def get(self, request, *args, **kwargs):
"""
Return a JsonResponse with search results of the form:
Expand All @@ -28,14 +30,21 @@ def get(self, request, *args, **kwargs):
{
# BEGIN CUSTOMIZATION #
"results": [
{
"id": str(getattr(obj, to_field_name)),
"name": getattr(obj, "semantic_autocomplete", str(obj)),
"text": str(obj),
}
self.serialize_result(obj, to_field_name)
for obj in context["object_list"]
],
# END CUSTOMIZATION #
"pagination": {"more": context["page_obj"].has_next()},
}
)

def serialize_result(self, obj, to_field_name):
"""
Convert the provided model object to a dictionary that is added to the
results list.
"""
return {
"id": str(getattr(obj, to_field_name)),
"name": getattr(obj, "semantic_autocomplete", str(obj)),
"text": str(obj),
}