Compare commits

...

5 Commits

Author SHA1 Message Date
Ales (Shagi) Zabala Alava 7c1cd322ed Bump version: 0.7
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/tag Build is failing Details
2021-05-11 19:12:38 +02:00
Ales (Shagi) Zabala Alava 73141c549d Enhance sidebar menu 2021-05-11 19:11:07 +02:00
Ales (Shagi) Zabala Alava 02bf93efc8 Use all css files on login template 2021-05-11 18:42:34 +02:00
Ales (Shagi) Zabala Alava 3eeda3a82a Make user admin section optional 2021-05-11 16:20:01 +02:00
Ales (Shagi) Zabala Alava ab1a600c9e Show role description in user edit form 2021-05-11 16:08:25 +02:00
13 changed files with 89 additions and 26 deletions

View File

@ -1,6 +1,13 @@
Changelog
=========
0.7
---
* Enhance sidebar menu
* Use all css files on login template
* Make user admin section optional
* Show role description in user edit form
0.6
---

View File

@ -7,12 +7,3 @@ site.register_role('staff', _('Users with access to gas control panel.'))
site.register_role('admins', _('Users with access to everithing inside control panel.'))
site.register_urls('', 'gas.gas.core.urls')
site.register_urls('users', 'gas.gas.users.urls')
site.register_menu(
name='users',
label=_("Users"),
icon="",
url="gas:user_list",
roles=('admins',),
)

View File

@ -7,7 +7,7 @@ from django.views.generic import TemplateView
from gas.views import GASMixin
class GASLoginView(LoginView):
class GASLoginView(GASMixin, LoginView):
template_name = "gas/login.html"
def get_success_url(self):

13
gas/gas/users_config.py Normal file
View File

@ -0,0 +1,13 @@
from django.utils.translation import gettext_lazy as _
from gas.sites import site
site.register_urls('users', 'gas.gas.users.urls')
site.register_menu(
name='users',
label=_("Users"),
icon="",
url="gas:user_list",
roles=('admins',),
)

View File

@ -82,7 +82,7 @@ msgstr "Crear"
#: gas/users/views.py:55
msgid "Update user"
msgstr "Actulizar usuario"
msgstr "Actualizar usuario"
#: gas/users/views.py:56
msgid "User updated"

View File

@ -77,8 +77,8 @@ class GASSite(object):
@property
def role_choices(self):
return [
(role, role)
for role in self._registry['roles']
(role, f"{role}: {description}")
for role, description in self._registry['roles'].items()
]
def get_role_description(self, role):

View File

@ -7,6 +7,11 @@
--info: #99f;
}
#logo {
width: 100px;
height: auto;
}
table {
border-collapse: collapse;
border: 1px solid gray;
@ -74,11 +79,6 @@ a, a:visited {
content: '';
}
#logo {
width: 100px;
height: auto;
}
#content {
flex: 4;
}
@ -97,6 +97,18 @@ a, a:visited {
background-color: #fafafa;
}
#sidebar ul ul {
display: none;
}
#sidebar ul li.dropdown {
cursor: pointer;
}
#sidebar ul li.dropdown.open > ul {
display:block;
}
ul.actions {
list-style-type: none;
padding: 0;

View File

@ -1,4 +1,8 @@
var GAS = {
config: {
'menuItemSelector': '.dropdown',
'openedMenuItemClass': 'open',
},
init: function() {
$(document).ready(function(){
$('.select2').select2({
@ -10,6 +14,10 @@ var GAS = {
let $message = $(this).parents('.message');
$message.remove();
});
GAS.toggle(
GAS.config.menuItemSelector,
GAS.config.openedMenuItemClass,
);
});
var csrftoken = GAS.getCookie('csrftoken');
@ -67,6 +75,19 @@ var GAS = {
}
}
return cookieValue;
},
toggle: function(selector, cssclass) {
const items = document.querySelectorAll(selector);
for (const item of items) {
item.addEventListener('click', function(ev) {
if (item.classList.contains(cssclass)) {
item.classList.remove(cssclass);
} else {
item.classList.add(cssclass);
}
});
}
}
}

View File

@ -80,7 +80,11 @@
<ul class="actions">
{% for target_url, icon, label in actions %}
{% if icon %}
{% if icon|slice:":2" == "fa" %}
<li><a href="{{ target_url }}"><i class="fas {{ icon }}" title="{{ label }}"></i></a></li>
{% else %}
<li><a href="{{ target_url }}" class="{{ icon }}">{{ label }}</a></li>
{% endif %}
{% else %}
<li><a href="{{ target_url }}">{{ label }}</a></li>
{% endif %}

View File

@ -4,7 +4,9 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>{{ gas_title }} {% trans "Login" %}</title>
<link href="{% static "gas/css/gas.css" %}" rel="stylesheet" type="text/css" />
{% for cssfile in css %}
<link href="{% static cssfile %}" rel="stylesheet" type="text/css" />
{% endfor %}
</head>
<body id="login">
<form action="." method="POST">{% csrf_token %}

View File

@ -1,18 +1,23 @@
{% load i18n %}
{% load gas_tags %}
{% if not is_submenu %}
<li class="nav-item">
<a class="nav-link" href="{% url "gas:index" %}">{% trans "Home" %}</a>
</li>
{% endif %}
{% for entry in menu %}
<li>
{% with children=entry|get_children:user_roles %}
<li class="nav-item{% if children %} dropdown{% endif %}{% if entry.icon %} icon-{{ entry.icon }}{% endif %}">
{% if entry.url %}
<a href="{% url entry.url %}">{{ entry.label }}</a>
{% else %}
{{ entry.label }}
{% endif %}
{% with children=entry|get_children:user_roles %}
{% if children %}
<ul>
{% include "gas/tags/navigation.html" with menu=children %}
{% include "gas/tags/navigation.html" with menu=children is_submenu=True %}
</ul>
{% endif %}
{% endwith %}
</li>
{% endwith %}
{% endfor %}

View File

@ -56,6 +56,14 @@ Create a submodule `gas.config` in your django app.
Edit this `config.py` file to register your code into `gas`. For examples look
at `gas.gas.config` and `gas.gas.users` modules.
Gas comes with a basic user management. To enable this section, import
`gas.gas.users_config` from any `gas.config` of your installed apps.
To enable the urls but keep the section out of the menu, just add this to
your `gas.config`:
site.register_urls('users', 'gas.gas.users.urls')
Licenses
--------

View File

@ -1,6 +1,6 @@
[metadata]
name = django-gas
version = 0.6
version = 0.7
description = An alternative to django admin
long_description = file: readme.md, changelog.md
long_description_content_type = text/markdown