Compare commits
	
		
			5 Commits
		
	
	
		
			c549745ef6
			...
			7c1cd322ed
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 7c1cd322ed | |
|  | 73141c549d | |
|  | 02bf93efc8 | |
|  | 3eeda3a82a | |
|  | ab1a600c9e | 
|  | @ -1,6 +1,13 @@ | ||||||
| Changelog | 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 | 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_role('admins', _('Users with access to everithing inside control panel.')) | ||||||
| 
 | 
 | ||||||
| site.register_urls('', 'gas.gas.core.urls') | 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 | from gas.views import GASMixin | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class GASLoginView(LoginView): | class GASLoginView(GASMixin, LoginView): | ||||||
|     template_name = "gas/login.html" |     template_name = "gas/login.html" | ||||||
| 
 | 
 | ||||||
|     def get_success_url(self): |     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 | #: gas/users/views.py:55 | ||||||
| msgid "Update user" | msgid "Update user" | ||||||
| msgstr "Actulizar usuario" | msgstr "Actualizar usuario" | ||||||
| 
 | 
 | ||||||
| #: gas/users/views.py:56 | #: gas/users/views.py:56 | ||||||
| msgid "User updated" | msgid "User updated" | ||||||
|  |  | ||||||
|  | @ -77,8 +77,8 @@ class GASSite(object): | ||||||
|     @property |     @property | ||||||
|     def role_choices(self): |     def role_choices(self): | ||||||
|         return [ |         return [ | ||||||
|             (role, role) |             (role, f"{role}: {description}") | ||||||
|             for role in self._registry['roles'] |             for role, description in self._registry['roles'].items() | ||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|     def get_role_description(self, role): |     def get_role_description(self, role): | ||||||
|  |  | ||||||
|  | @ -7,6 +7,11 @@ | ||||||
|     --info: #99f; |     --info: #99f; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #logo { | ||||||
|  |   width: 100px; | ||||||
|  |   height: auto; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| table { | table { | ||||||
|     border-collapse: collapse; |     border-collapse: collapse; | ||||||
|     border: 1px solid gray; |     border: 1px solid gray; | ||||||
|  | @ -74,11 +79,6 @@ a, a:visited { | ||||||
|     content: ''; |     content: ''; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #logo { |  | ||||||
|   width: 100px; |  | ||||||
|   height: auto; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #content { | #content { | ||||||
|     flex: 4; |     flex: 4; | ||||||
| } | } | ||||||
|  | @ -97,6 +97,18 @@ a, a:visited { | ||||||
|     background-color: #fafafa; |     background-color: #fafafa; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #sidebar ul ul { | ||||||
|  |     display: none; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #sidebar ul li.dropdown { | ||||||
|  |     cursor: pointer; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #sidebar ul li.dropdown.open > ul { | ||||||
|  |  display:block; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| ul.actions { | ul.actions { | ||||||
|     list-style-type: none; |     list-style-type: none; | ||||||
|     padding: 0; |     padding: 0; | ||||||
|  |  | ||||||
|  | @ -1,4 +1,8 @@ | ||||||
| var GAS = { | var GAS = { | ||||||
|  |     config: { | ||||||
|  |         'menuItemSelector': '.dropdown', | ||||||
|  |         'openedMenuItemClass': 'open', | ||||||
|  |     }, | ||||||
|     init: function() { |     init: function() { | ||||||
|         $(document).ready(function(){ |         $(document).ready(function(){ | ||||||
|             $('.select2').select2({ |             $('.select2').select2({ | ||||||
|  | @ -10,6 +14,10 @@ var GAS = { | ||||||
|                 let $message = $(this).parents('.message'); |                 let $message = $(this).parents('.message'); | ||||||
|                 $message.remove(); |                 $message.remove(); | ||||||
|             }); |             }); | ||||||
|  |             GAS.toggle( | ||||||
|  |                 GAS.config.menuItemSelector, | ||||||
|  |                 GAS.config.openedMenuItemClass, | ||||||
|  |             ); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         var csrftoken = GAS.getCookie('csrftoken'); |         var csrftoken = GAS.getCookie('csrftoken'); | ||||||
|  | @ -67,6 +75,19 @@ var GAS = { | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return cookieValue; |         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"> |                         <ul class="actions"> | ||||||
|                             {% for target_url, icon, label in actions %} |                             {% for target_url, icon, label in actions %} | ||||||
|                                 {% if icon %} |                                 {% if icon %} | ||||||
|  |                                     {% if icon|slice:":2" == "fa" %} | ||||||
|                                         <li><a href="{{ target_url }}"><i class="fas {{ icon }}" title="{{ label }}"></i></a></li> |                                         <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 %} |                                 {% else %} | ||||||
|                                     <li><a href="{{ target_url }}">{{ label }}</a></li> |                                     <li><a href="{{ target_url }}">{{ label }}</a></li> | ||||||
|                                 {% endif %} |                                 {% endif %} | ||||||
|  |  | ||||||
|  | @ -4,7 +4,9 @@ | ||||||
|         <meta charset="UTF-8" /> |         <meta charset="UTF-8" /> | ||||||
|         <meta name="viewport" content="width=device-width" /> |         <meta name="viewport" content="width=device-width" /> | ||||||
|         <title>{{ gas_title }} {% trans "Login" %}</title> |         <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> |     </head> | ||||||
|     <body id="login"> |     <body id="login"> | ||||||
|         <form action="." method="POST">{% csrf_token %} |         <form action="." method="POST">{% csrf_token %} | ||||||
|  |  | ||||||
|  | @ -1,18 +1,23 @@ | ||||||
|  | {% load i18n %} | ||||||
| {% load gas_tags %} | {% 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 %} | {% 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 %} |         {% if entry.url %} | ||||||
|             <a href="{% url entry.url %}">{{ entry.label }}</a> |             <a href="{% url entry.url %}">{{ entry.label }}</a> | ||||||
|         {% else %} |         {% else %} | ||||||
|             {{ entry.label }} |             {{ entry.label }} | ||||||
|         {% endif %} |         {% endif %} | ||||||
|         {% with children=entry|get_children:user_roles %} |  | ||||||
|         {% if children %} |         {% if children %} | ||||||
|             <ul> |             <ul> | ||||||
|                 {% include "gas/tags/navigation.html" with menu=children %} |                 {% include "gas/tags/navigation.html" with menu=children is_submenu=True %} | ||||||
|             </ul> |             </ul> | ||||||
|         {% endif %} |         {% endif %} | ||||||
|         {% endwith %} |  | ||||||
|     </li> |     </li> | ||||||
|  | {% endwith %} | ||||||
| {% endfor %} | {% 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 | Edit this `config.py` file to register your code into `gas`. For examples look | ||||||
| at `gas.gas.config` and `gas.gas.users` modules. | 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 | Licenses | ||||||
| -------- | -------- | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| [metadata] | [metadata] | ||||||
| name = django-gas | name = django-gas | ||||||
| version = 0.6 | version = 0.7 | ||||||
| description = An alternative to django admin | description = An alternative to django admin | ||||||
| long_description = file: readme.md, changelog.md | long_description = file: readme.md, changelog.md | ||||||
| long_description_content_type = text/markdown | long_description_content_type = text/markdown | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue