Added module for login
This commit is contained in:
parent
79b1e8afb6
commit
758d7e4cef
8 changed files with 163 additions and 6 deletions
|
|
@ -3,7 +3,7 @@ body
|
|||
{
|
||||
|
||||
margin:0px;
|
||||
background-color:#f7f6f1;
|
||||
background-color:#f4f6f9;
|
||||
font-family: "Roboto", sans, sans-serif, serif;
|
||||
font-size: 16px;
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ p {
|
|||
{
|
||||
|
||||
float:left;
|
||||
width:20%;
|
||||
width:18%;
|
||||
margin-right:0px;
|
||||
position:relative;
|
||||
/* border:solid #cccccc;
|
||||
|
|
@ -240,13 +240,13 @@ p {
|
|||
|
||||
margin:auto;
|
||||
background: rgba(18,47,59,1);
|
||||
background: -moz-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
/*background: -moz-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(18,47,59,1)), color-stop(51%, rgba(18,47,59,1)), color-stop(74%, rgba(18,47,59,1)), color-stop(100%, rgba(8,59,77,1)));
|
||||
background: -webkit-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
background: -o-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);*/
|
||||
background: linear-gradient(to right, rgba(18,47,59,1) 0%, rgba(18,47,59,1) 51%, rgba(18,47,59,1) 74%, rgba(8,59,77,1) 100%);
|
||||
background-size: 20% 100%;
|
||||
background-size: 18% 100%;
|
||||
background-repeat:no-repeat;
|
||||
padding:0px;
|
||||
border:solid #bcbcbc;
|
||||
|
|
@ -268,7 +268,7 @@ p {
|
|||
.contents
|
||||
{
|
||||
float:right;
|
||||
width:80%;
|
||||
width:82%;
|
||||
padding:0px 0px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
|
@ -313,6 +313,10 @@ p {
|
|||
padding:10px;
|
||||
margin:10px 0px 10px 0px;
|
||||
border-radius:5px;
|
||||
background: #fbfbfb;
|
||||
-webkit-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
-moz-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +390,14 @@ margin-right:auto;
|
|||
|
||||
}
|
||||
|
||||
table {
|
||||
|
||||
-webkit-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
-moz-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
|
||||
}
|
||||
|
||||
.table_list {
|
||||
|
||||
width:100%;
|
||||
|
|
@ -433,6 +445,7 @@ margin-right:auto;
|
|||
/*border:solid #cccccc;
|
||||
border-width:1px;*/
|
||||
padding:4px;
|
||||
background: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
37
paramecio2/modules/login/__init__.py
Normal file
37
paramecio2/modules/login/__init__.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from flask import Blueprint, g, request, session, redirect, url_for
|
||||
from paramecio2.libraries.db.webmodel import WebModel
|
||||
from functools import wraps
|
||||
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||
try:
|
||||
import ujson as json
|
||||
except:
|
||||
import json
|
||||
|
||||
#Load json config
|
||||
|
||||
login_app=Blueprint('login_app', __name__)
|
||||
|
||||
env=env_theme(__file__)
|
||||
|
||||
t=PTemplate(env)
|
||||
|
||||
def login_site(f):
|
||||
|
||||
@wraps(f)
|
||||
|
||||
def wrapper(*args, **kwds):
|
||||
|
||||
session_name='login_site'
|
||||
|
||||
if 'sesion_name' in kwds:
|
||||
session_name=kwds['session_name']
|
||||
|
||||
if not session_name in session:
|
||||
|
||||
return redirect(url_for('.login'))
|
||||
|
||||
else:
|
||||
|
||||
return f(*args, **kwds)
|
||||
|
||||
return wrapper
|
||||
0
paramecio2/modules/login/admin/__init__.py
Normal file
0
paramecio2/modules/login/admin/__init__.py
Normal file
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
|
||||
|
||||
14
paramecio2/modules/login/admin/templates/loginform.phtml
Normal file
14
paramecio2/modules/login/admin/templates/loginform.phtml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
${content_form|n}
|
||||
<p><input type="submit" value="${lang('admin', 'send', 'Send')}"/></p>
|
||||
<script>
|
||||
|
||||
$.ajax({
|
||||
url: "${url_for('.admin_login')}",
|
||||
data: {},
|
||||
success: function(data) {
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
</script>
|
||||
2
paramecio2/modules/login/app.py
Normal file
2
paramecio2/modules/login/app.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
from paramecio2.modules.login import login_app
|
||||
|
||||
0
paramecio2/modules/login/settings/__init__.py
Normal file
0
paramecio2/modules/login/settings/__init__.py
Normal file
9
paramecio2/modules/login/settings/config_admin.py
Normal file
9
paramecio2/modules/login/settings/config_admin.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from paramecio2.libraries.config_admin import config_admin
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
|
||||
#modules_admin=[[I18n.lang('admin', 'users_admin', 'User\'s Admin'), 'paramecio.modules.admin.admin.ausers', 'ausers']]
|
||||
|
||||
config_admin.append([I18n.lang('admin', 'login_admin', 'Login admin')])
|
||||
|
||||
config_admin.append([I18n.lang('admin', 'login_config', 'Login configuration'), 'paramecio2.modules.login.admin.login', 'admin_app.admin_login'])
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue