Added module for login
This commit is contained in:
parent
79b1e8afb6
commit
758d7e4cef
8 changed files with 163 additions and 6 deletions
82
paramecio2/modules/login/admin/login.py
Normal file
82
paramecio2/modules/login/admin/login.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
from settings import config
|
||||
from flask import g, url_for
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
import copy
|
||||
from paramecio2.modules.admin import admin_app, t as admin_t
|
||||
from paramecio2.libraries.db import coreforms
|
||||
from paramecio2.libraries.formsutils import show_form
|
||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||
import os
|
||||
|
||||
#env=env_theme(__file__)
|
||||
|
||||
#t=PTemplate(env)
|
||||
|
||||
t=copy.copy(admin_t)
|
||||
|
||||
t.env.directories.insert(1, os.path.dirname(__file__)+'/templates')
|
||||
|
||||
print(t.env.directories)
|
||||
|
||||
@admin_app.route('/admin/login/', methods=['GET', 'POST'])
|
||||
def admin_login():
|
||||
"""
|
||||
connection=g.connection
|
||||
|
||||
user_admin=UserAdmin(connection)
|
||||
|
||||
user_admin.fields['privileges'].name_form=SelectForm
|
||||
|
||||
user_admin.create_forms(['username', 'password', 'email', 'privileges', 'lang'])
|
||||
|
||||
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.fields['password'].protected=False
|
||||
|
||||
user_admin.check_user=False
|
||||
user_admin.check_email=False
|
||||
|
||||
url=url_for('admin_app.login')
|
||||
|
||||
admin=GenerateAdminClass(user_admin, url, t)
|
||||
|
||||
admin.list.fields_showed=['username', 'privileges']
|
||||
|
||||
admin.list.search_fields=['username']
|
||||
|
||||
admin.arr_fields_edit=['username', 'password', 'repeat_password', 'email', 'privileges', 'lang']
|
||||
|
||||
form_admin=admin.show()
|
||||
|
||||
if type(form_admin).__name__=='str':
|
||||
|
||||
return t.load_template('content.phtml', title=I18n.lang('admin', 'users_edit', 'Users edit'), contents=form_admin, path_module='/admin/login')
|
||||
else:
|
||||
|
||||
return form_admin
|
||||
|
||||
"""
|
||||
|
||||
form_admin=''
|
||||
|
||||
arr_forms={}
|
||||
|
||||
arr_forms['name']=coreforms.BaseForm('name', '')
|
||||
|
||||
arr_forms['name'].label='Name'
|
||||
|
||||
arr_forms['activate_double_check']=coreforms.SelectForm('activate_double_check', 0, {0: I18n.lang('admin', 'no', 'No'), 1: I18n.lang('admin', 'yes', 'Yes')})
|
||||
|
||||
arr_forms['activate_double_check'].label='Activate double check'
|
||||
|
||||
form_admin=show_form({}, arr_forms, t, yes_error=True, pass_values=True, modelform_tpl='forms/modelform.phtml')
|
||||
|
||||
login_form=t.load_template('loginform.phtml', content_form=form_admin)
|
||||
|
||||
if type(form_admin).__name__=='str':
|
||||
|
||||
return t.load_template('content.phtml', title=I18n.lang('admin', 'login_edit', 'Login edit'), contents=login_form, path_module='/admin/login')
|
||||
else:
|
||||
|
||||
return form_admin
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue