From f86a393921ac9d3cce71ffc2a30334e70c38aaa3 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Wed, 2 Oct 2024 01:05:54 +0200 Subject: [PATCH] Fixes in asuers --- paramecio/modules/admin/admin/ausers.py | 29 ++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/paramecio/modules/admin/admin/ausers.py b/paramecio/modules/admin/admin/ausers.py index f4dcb43..de81825 100644 --- a/paramecio/modules/admin/admin/ausers.py +++ b/paramecio/modules/admin/admin/ausers.py @@ -3,9 +3,15 @@ from paramecio.modules.admin.models.admin import UserAdmin from paramecio.citoplasma.urls import make_url from paramecio.citoplasma.generate_admin_class import GenerateAdminClass -from paramecio.citoplasma.i18n import I18n +from paramecio2.libraries.i18n import I18n, PGetText from paramecio.cromosoma.coreforms import SelectForm +from paramecio.citoplasma.sessions import get_session from settings import config +from bottle import request + +pgettext=PGetText(__file__+'/../') + +_=pgettext.gettext def admin(**args): @@ -17,10 +23,14 @@ def admin(**args): user_admin.fields['privileges'].name_form=SelectForm - user_admin.create_forms(['username', 'password', 'email', 'privileges', 'lang']) + user_admin.fields['theme'].name_form=SelectForm + + user_admin.create_forms(['username', 'password', 'email', 'privileges', 'lang', 'theme']) user_admin.forms['privileges'].arr_select={0: I18n.lang('admin', 'without_privileges', 'Without privileges'), 1: I18n.lang('admin', 'selected_privileges', 'Selected privileges'), 2: I18n.lang('admin', 'administrator', 'Administrator')} + user_admin.forms['theme'].arr_select={0: _('Light theme'), 1: _('Dark theme')} + user_admin.fields['password'].protected=False url=make_url('admin/ausers', {}) @@ -31,7 +41,20 @@ def admin(**args): admin.list.search_fields=['username'] - admin.arr_fields_edit=['username', 'password', 'repeat_password', 'email', 'privileges', 'lang'] + admin.arr_fields_edit=['username', 'password', 'repeat_password', 'email', 'privileges', 'lang', 'theme'] + + #if reqes + if request.environ.get('REQUEST_METHOD', 'POST')=='POST': + s=get_session() + theme=request.forms.get('theme', '0') + + if theme!='0' and theme!='1': + theme='0' + + s['theme']=str(theme) + + s.save() + #admin.list.limit_pages=5