Compare commits
5 Commits
c549745ef6
...
7c1cd322ed
Author | SHA1 | Date |
---|---|---|
Ales (Shagi) Zabala Alava | 7c1cd322ed | |
Ales (Shagi) Zabala Alava | 73141c549d | |
Ales (Shagi) Zabala Alava | 02bf93efc8 | |
Ales (Shagi) Zabala Alava | 3eeda3a82a | |
Ales (Shagi) Zabala Alava | ab1a600c9e |
|
@ -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
|
||||
---
|
||||
|
||||
|
|
|
@ -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',),
|
||||
)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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',),
|
||||
)
|
|
@ -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"
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,11 @@
|
|||
<ul class="actions">
|
||||
{% for target_url, icon, label in actions %}
|
||||
{% if icon %}
|
||||
<li><a href="{{ target_url }}"><i class="fas {{ icon }}" title="{{ label }}"></i></a></li>
|
||||
{% 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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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
|
||||
--------
|
||||
|
|
Loading…
Reference in New Issue