Compare commits
5 Commits
7c1cd322ed
...
f2c1a76a1b
Author | SHA1 | Date |
---|---|---|
Ales (Shagi) Zabala Alava | f2c1a76a1b | |
Ales (Shagi) Zabala Alava | 55982b83bf | |
Ales (Shagi) Zabala Alava | 7155342ed2 | |
Ales (Shagi) Zabala Alava | 2fa7401d58 | |
Ales (Shagi) Zabala Alava | 873e8cc043 |
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue