Compare commits

..

No commits in common. "f2c1a76a1bffe9c42b63e0bb7a0900552b867f5c" and "7c1cd322ed8e8e55ca8a1e9ad9ea25d9945dc184" have entirely different histories.

8 changed files with 21 additions and 33 deletions

View File

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

View File

@ -6,30 +6,14 @@ from django.views.generic import TemplateView
from gas.views import GASMixin
from gas import gas_settings
class GASLoginView(LoginView):
class GASLoginView(GASMixin, 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'
@ -37,7 +21,6 @@ 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,6 +1,9 @@
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,7 +148,13 @@ class SiteTestCase(TestCase):
class SampleAppIntegrationTest(TestCase):
def test_gas_autodiscover(self):
# urls registered
reverse('gas:index')
reverse('gas:user_list')
# menu registered
self.assertIn(
'users',
site._registry['menu'],
)
# role registered
self.assertIn(

View File

@ -1,10 +1,11 @@
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
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest, HttpResponseNotAllowed
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.html import escape, escapejs
@ -12,7 +13,9 @@ 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:

View File

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