Compare commits

...

5 Commits

Author SHA1 Message Date
Ales (Shagi) Zabala Alava f2c1a76a1b Bugfix release 0.7.1
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details
2021-05-12 17:08:27 +02:00
Ales (Shagi) Zabala Alava 55982b83bf Code cleaning 2021-05-12 16:14:40 +02:00
Ales (Shagi) Zabala Alava 7155342ed2 Fix autodiscover test 2021-05-12 16:11:33 +02:00
Ales (Shagi) Zabala Alava 2fa7401d58 Fix login view 2021-05-12 16:11:06 +02:00
Ales (Shagi) Zabala Alava 873e8cc043 Fix initial roles in user form 2021-05-12 16:10:27 +02:00
8 changed files with 33 additions and 21 deletions

View File

@ -1,8 +1,15 @@
Changelog
=========
0.7.1
-----
* Fix login view
* Fix initial roles in user form
0.7
---
* Enhance sidebar menu
* Use all css files on login template
* Make user admin section optional

View File

@ -1,6 +1,5 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
from django.db.models.signals import post_migrate
class GASConfig(AppConfig):

View File

@ -25,6 +25,7 @@ class UserForm(forms.ModelForm):
label=_('roles'),
required=False,
)
class Meta:
model = User
fields = (
@ -33,8 +34,8 @@ class UserForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'roles' not in self.initial and self.instance.pk is not None:
self.initial['roles'] = self.instance.user_roles.values_list('role', flat=True)
if self.instance.pk is not None:
self.initial['roles'] = list(self.instance.user_roles.values_list('role', flat=True))
def save(self, commit=True):
obj = super().save(commit=False)

View File

@ -6,14 +6,30 @@ from django.views.generic import TemplateView
from gas.views import GASMixin
from gas import gas_settings
class GASLoginView(GASMixin, LoginView):
class GASLoginView(LoginView):
template_name = "gas/login.html"
def get_success_url(self):
url = self.get_redirect_url()
return url or resolve_url('gas:index')
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
css = gas_settings.MEDIA['css']
js = gas_settings.MEDIA['js']
if gas_settings.EXTRA_MEDIA:
css = css + gas_settings.EXTRA_MEDIA.get('css', [])
js = js + gas_settings.EXTRA_MEDIA.get('js', [])
ctx.update({
'logo_static_url': gas_settings.LOGO,
'css': css,
'js': js,
})
return ctx
class GASPasswordChangeView(GASMixin, PasswordChangeView):
template_name = 'gas/base_form.html'
@ -21,6 +37,7 @@ class GASPasswordChangeView(GASMixin, PasswordChangeView):
title = _('Change your password')
success_message = _('Password changed.')
class Index(GASMixin, TemplateView):
main_menu = 'index'
template_name = "gas/index.html"

View File

@ -1,9 +1,6 @@
from collections import namedtuple
from django.urls import include, re_path
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import autodiscover_modules
from django.utils.translation import gettext_lazy as _
class Entry:

View File

@ -148,13 +148,7 @@ class SiteTestCase(TestCase):
class SampleAppIntegrationTest(TestCase):
def test_gas_autodiscover(self):
# urls registered
reverse('gas:user_list')
# menu registered
self.assertIn(
'users',
site._registry['menu'],
)
reverse('gas:index')
# role registered
self.assertIn(

View File

@ -1,11 +1,10 @@
import datetime
import json
from django.contrib import messages
from django.contrib.admin.utils import NestedObjects
from django.core.exceptions import ImproperlyConfigured
from django.db import router
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest, HttpResponseNotAllowed
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.html import escape, escapejs
@ -13,9 +12,7 @@ from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _
from django.views.generic import ListView, CreateView, UpdateView, DeleteView
from . import forms
from . import gas_settings
from .sites import site
class AjaxCommandsMixin:
@ -52,8 +49,8 @@ class GASMixin:
roles.add(self.base_role)
access_denied = (
not user.is_authenticated or (
not user.is_superuser
and user.user_roles.filter(role__in=roles).count() == 0
not user.is_superuser
and user.user_roles.filter(role__in=roles).count() == 0
)
)
if access_denied:

View File

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