-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4bac55
commit 31e9c20
Showing
13 changed files
with
134 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
}, | ||
}, | ||
"DASHBOARD_CALLBACK": None, | ||
"ENVIRONMENT": None, | ||
"STYLES": [], | ||
"SCRIPTS": [], | ||
"SIDEBAR": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="max-w-7xl mx-auto{% if class %} {{ class }}{% endif %}"> | ||
{{ children }} | ||
<div class="mx-auto{% if class %} {{ class }}{% endif %}"> | ||
{{ children }} | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<label for="{{ field.id_for_label }}" class="block font-medium mb-2 text-gray-900 text-sm dark:text-gray-200"> | ||
{{ field.label }} | ||
|
||
{% if field.field.required %} | ||
<span class="text-red-600">*</span> | ||
{% endif %} | ||
</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% if not is_popup %} | ||
{% block header %} | ||
<div class="border-b border-gray-200 mb-6 px-4 lg:px-12 dark:border-gray-800"> | ||
<div class="container flex items-center h-16 mx-auto py-4"> | ||
<div id="header-inner" class="flex items-center w-full"> | ||
<div class="flex items-center w-full"> | ||
{% block usertools %} | ||
{% if has_permission %} | ||
{% block welcome-msg %} | ||
{% include 'unfold/helpers/welcomemsg.html' %} | ||
{% endblock %} | ||
|
||
{% block userlinks %} | ||
{% include 'unfold/helpers/userlinks.html' %} | ||
{% endblock %} | ||
{% endif %} | ||
{% endblock %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
<label for="{{ field.id_for_label }}" class="block font-medium mb-2 text-gray-900 text-sm dark:text-gray-200"> | ||
{{ field.label }} | ||
|
||
{% if field.field.required %} | ||
<span class="text-red-600">*</span> | ||
<span class="border font-semibold leading-none mr-2 px-2 py-1 rounded shadow-sm text-xxs uppercase whitespace-nowrap last:mr-0 | ||
{% if type == 'info' %} | ||
bg-blue-50 border-blue-200 text-blue-500 dark:bg-blue-500/20 dark:border-blue-500/10 | ||
{% elif type == 'danger' %} | ||
bg-red-50 border-red-200 text-red-500 dark:bg-red-500/20 dark:border-red-500/10 | ||
{% elif type == 'warning' %} | ||
bg-orange-50 border-orange-200 text-orange-500 dark:bg-orange-500/20 dark:border-orange-500/10 | ||
{% elif type == 'success' %} | ||
bg-green-50 border-green-200 text-green-500 dark:bg-green-500/20 dark:border-green-500/10 | ||
{% else %} | ||
bg-white border-gray-200 text-gray-400 dark:bg-white/[.04] dark:border-gray-800 dark:text-gray-400 | ||
{% endif %} | ||
</label> | ||
"> | ||
{{ text }} | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from django.contrib.auth.models import AnonymousUser | ||
from django.test import TestCase | ||
from django.test.client import RequestFactory | ||
from django.test.utils import override_settings | ||
from unfold.settings import CONFIG_DEFAULTS, get_config | ||
from unfold.sites import UnfoldAdminSite | ||
|
||
|
||
def environment_callback(request): | ||
return ["Testing Environment", "warning"] | ||
|
||
|
||
class EnvironmentTestCase(TestCase): | ||
@override_settings(UNFOLD={**CONFIG_DEFAULTS}) | ||
def test_empty_environment_callback(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertTrue("environment" not in context) | ||
get_config.cache_clear() | ||
|
||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"ENVIRONMENT": "tests.test_environment.non_existing_environment_callback", | ||
}, | ||
} | ||
) | ||
def test_incorrect_environment_callback(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
print(context) | ||
self.assertTrue("environment" not in context) | ||
get_config.cache_clear() | ||
|
||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"ENVIRONMENT": "tests.test_environment.environment_callback", | ||
}, | ||
} | ||
) | ||
def test_correct_environment_callback(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
print(context) | ||
self.assertTrue("environment" in context) | ||
self.assertEqual(context["environment"], ["Testing Environment", "warning"]) | ||
get_config.cache_clear() |