Compare commits
No commits in common. "c0db8cf71c2196314ac66e3de626d6867d864926" and "a97004ddc730eab39ecead54ca75514e520ed61f" have entirely different histories.
c0db8cf71c
...
a97004ddc7
|
@ -1,11 +1,6 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
0.8.6
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Allow overriding home url
|
|
||||||
|
|
||||||
0.8.5
|
0.8.5
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
<nav id="navbar-main" role="navigation">
|
<nav id="navbar-main" role="navigation">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="{{ home_url }}"><img id="logo" src="{% static logo_static_url %}"></a>
|
<a class="navbar-brand" href="{% url "gas:index" %}"><img id="logo" src="{% static logo_static_url %}"></a>
|
||||||
</div>
|
</div>
|
||||||
<ul id="main-navigation">
|
<ul id="main-navigation">
|
||||||
<li>{{ user }}</li>
|
<li>{{ user }}</li>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
{% if not is_popup %}
|
{% if not is_popup %}
|
||||||
<nav class="breadcrumb">
|
<nav class="breadcrumb">
|
||||||
<ol>
|
<ol>
|
||||||
<li><a href="{{ home_url }}" title="{% trans "Home" %}"><i class="fas fa-home fa-fw"></i></a></li>
|
<li><a href="{% url "gas:index" %}" title="{% trans "Home" %}"><i class="fas fa-home fa-fw"></i></a></li>
|
||||||
{% for bc_url, bc_label in breadcrumbs %}
|
{% for bc_url, bc_label in breadcrumbs %}
|
||||||
{% if bc_url %}
|
{% if bc_url %}
|
||||||
<li><a href="{{ bc_url }}">{{ bc_label }}</a></li>
|
<li><a href="{{ bc_url }}">{{ bc_label }}</a></li>
|
||||||
|
|
|
@ -228,14 +228,10 @@ class GASMixinTestCase(TestCase):
|
||||||
]
|
]
|
||||||
template_name = 'gas/base.html'
|
template_name = 'gas/base.html'
|
||||||
|
|
||||||
def get_home_url(self):
|
|
||||||
return 'home_url'
|
|
||||||
|
|
||||||
view = SampleView.as_view()
|
view = SampleView.as_view()
|
||||||
request = self.request_factory.get('some_url')
|
request = self.request_factory.get('some_url')
|
||||||
request.user = self.admin_user
|
request.user = self.admin_user
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(response.context_data['home_url'], 'home_url')
|
|
||||||
self.assertEqual(response.context_data['title'], SampleView.title)
|
self.assertEqual(response.context_data['title'], SampleView.title)
|
||||||
self.assertEqual(response.context_data['header_title'], SampleView.header_title)
|
self.assertEqual(response.context_data['header_title'], SampleView.header_title)
|
||||||
self.assertEqual(response.context_data['help_text'], SampleView.help_text)
|
self.assertEqual(response.context_data['help_text'], SampleView.help_text)
|
||||||
|
|
12
gas/views.py
12
gas/views.py
|
@ -83,7 +83,7 @@ class GASMixin:
|
||||||
breadcrumbs = []
|
breadcrumbs = []
|
||||||
actions = None
|
actions = None
|
||||||
|
|
||||||
def check_user_forbidden(self):
|
def dispatch(self, *args, **kwargs):
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
roles = set(self.roles)
|
roles = set(self.roles)
|
||||||
roles.add(self.base_role)
|
roles.add(self.base_role)
|
||||||
|
@ -93,10 +93,7 @@ class GASMixin:
|
||||||
and user.user_roles.filter(role__in=roles).count() == 0
|
and user.user_roles.filter(role__in=roles).count() == 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return access_denied
|
if access_denied:
|
||||||
|
|
||||||
def dispatch(self, *args, **kwargs):
|
|
||||||
if self.check_user_forbidden():
|
|
||||||
return HttpResponseRedirect(reverse('gas:login') + '?next={}'.format(self.request.path))
|
return HttpResponseRedirect(reverse('gas:login') + '?next={}'.format(self.request.path))
|
||||||
return super().dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -110,10 +107,6 @@ class GASMixin:
|
||||||
def get_success_message(self):
|
def get_success_message(self):
|
||||||
return self.success_message
|
return self.success_message
|
||||||
|
|
||||||
def get_home_url(self):
|
|
||||||
""" Url for the home of the control panel """
|
|
||||||
return reverse('gas:index')
|
|
||||||
|
|
||||||
def get_cancel_url(self):
|
def get_cancel_url(self):
|
||||||
if self.cancel_url:
|
if self.cancel_url:
|
||||||
# Forcing possible reverse_lazy evaluation
|
# Forcing possible reverse_lazy evaluation
|
||||||
|
@ -158,7 +151,6 @@ class GASMixin:
|
||||||
js = js + gas_settings.EXTRA_MEDIA.get('js', [])
|
js = js + gas_settings.EXTRA_MEDIA.get('js', [])
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'base_template': self.base_template,
|
'base_template': self.base_template,
|
||||||
'home_url': self.get_home_url(),
|
|
||||||
'header_title': self.get_header_title(),
|
'header_title': self.get_header_title(),
|
||||||
'title': self.get_title(),
|
'title': self.get_title(),
|
||||||
'help_text': self.get_help_text(),
|
'help_text': self.get_help_text(),
|
||||||
|
|
|
@ -10,7 +10,6 @@ def runtests():
|
||||||
if not settings.configured:
|
if not settings.configured:
|
||||||
# Configure test environment
|
# Configure test environment
|
||||||
settings.configure(
|
settings.configure(
|
||||||
SECRET_KEY="test-secret",
|
|
||||||
DATABASES={
|
DATABASES={
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = django-gas
|
name = django-gas
|
||||||
version = 0.8.6
|
version = 0.8.5
|
||||||
description = An alternative to django admin
|
description = An alternative to django admin
|
||||||
long_description = file: readme.md, changelog.md, collaborators.md
|
long_description = file: readme.md, changelog.md, collaborators.md
|
||||||
long_description_content_type = text/markdown
|
long_description_content_type = text/markdown
|
||||||
|
|
Loading…
Reference in New Issue