Skip to content

Commit

Permalink
Merge pull request #103 from globophobe/feature/own-static
Browse files Browse the repository at this point in the history
Version 0.6.1
  • Loading branch information
globophobe authored Aug 31, 2024
2 parents 1024518 + 6641488 commit 0a226a9
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 163 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.sqlite3
.env
.coverage
.DS_Store
dist/
static/
media/
Expand Down
285 changes: 143 additions & 142 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-semantic-admin"
version = "0.6.0"
version = "0.6.1"
description = "Django Semantic UI Admin theme"
authors = ["Alex <globophobe@gmail.com>"]
readme = "README.md"
Expand Down
4 changes: 3 additions & 1 deletion semantic_admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ class SemanticBaseModelAdmin(BaseModelAdmin):

def __init__(self, *args, **kwargs) -> None:
"""Initialize"""
original_formfield_overrides = copy.deepcopy(self.formfield_overrides)
super().__init__(*args, **kwargs)
# Simply overwrite
overrides = copy.deepcopy(SEMANTIC_FORMFIELD_FOR_DBFIELD_DEFAULTS)
for k, v in overrides.items():
self.formfield_overrides.setdefault(k, {}).update(v)
self.formfield_overrides = overrides
for k, v in original_formfield_overrides.items():
self.formfield_overrides.setdefault(k, {}).update(v)

def formfield_for_choice_field(
self, db_field: str, request: HttpRequest, **kwargs
Expand Down
12 changes: 5 additions & 7 deletions semantic_admin/templates/admin/change_form.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{# comment Extend base_site.html instead of change_form.html b/c override extrastyle without block.super #}
{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_modify semantic_utils %}
{% has_url 'javascript-catalog' as javascript_catalog %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{{ media }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{{ media }}
{% endblock %}

<div class="ui stackable grid">
Expand Down Expand Up @@ -133,21 +132,20 @@
});

const languageCode = '{{ LANGUAGE_CODE|default:"en-us" }}';
const hasJavascriptCatalog = {% if javascript_catalog %}true{% else %}false{% endif %};

// Datetime
$row.find('.ui.calendar.datetime').not('[name*=__prefix__]').each(function() {
$(this).calendar(getCalendarOptions('datetime', hasJavascriptCatalog));
$(this).calendar(getCalendarOptions('datetime', true));
});

// Date
$row.find('.ui.calendar.date').not('[name*=__prefix__]').each(function() {
$(this).calendar(getCalendarOptions('date', hasJavascriptCatalog));
$(this).calendar(getCalendarOptions('date', true));
});

// Time
$row.find('.ui.calendar.time').not('[name*=__prefix__]').each(function() {
$(this).calendar(getCalendarOptions('time', hasJavascriptCatalog));
$(this).calendar(getCalendarOptions('time', true));
});

};
Expand Down
1 change: 1 addition & 0 deletions semantic_admin/templates/admin/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{% endblock %}

{% block extrahead %}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{{ block.super }}
{{ cl.model_admin.filterset.form.media.js }}
{% endblock %}
Expand Down
13 changes: 1 addition & 12 deletions semantic_admin/templatetags/semantic_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from typing import Generator
from collections.abc import Generator

from django import template
from django.contrib.admin.templatetags.admin_list import (
Expand Down Expand Up @@ -272,14 +272,3 @@ def semantic_paginator_number(cl: ChangeList, i: int) -> str:
mark_safe(" end" if i == cl.paginator.num_pages else ""),
i,
)


@register.simple_tag
def has_url(url: str) -> bool:
"""Does the url exist?"""
try:
reverse(url)
except NoReverseMatch:
return False
else:
return True

0 comments on commit 0a226a9

Please sign in to comment.