This commit is contained in:
Antonio de la Rosa 2015-12-07 21:47:23 +01:00
parent 20becdbd27
commit b2fba8870f
33 changed files with 3958 additions and 38 deletions

View file

@ -1,10 +1,10 @@
from citoplasma.lists import SimpleList from paramecio.citoplasma.lists import SimpleList
from bottle import request, redirect from bottle import request, redirect
from citoplasma.urls import add_get_parameters from paramecio.citoplasma.urls import add_get_parameters
from citoplasma.templates import set_flash_message from paramecio.citoplasma.mtemplates import set_flash_message
from cromosoma.formsutils import show_form from paramecio.cromosoma.formsutils import show_form
from citoplasma.i18n import I18n from paramecio.citoplasma.i18n import I18n
from citoplasma.httputils import GetPostFiles from paramecio.citoplasma.httputils import GetPostFiles
class GenerateAdminClass: class GenerateAdminClass:

View file

@ -1,9 +1,9 @@
#By default id is not showed #By default id is not showed
from citoplasma.pages import Pages from paramecio.citoplasma.pages import Pages
from citoplasma.urls import add_get_parameters from paramecio.citoplasma.urls import add_get_parameters
from citoplasma.sessions import get_session from paramecio.citoplasma.sessions import get_session
from citoplasma.i18n import I18n from paramecio.citoplasma.i18n import I18n
from bottle import request from bottle import request
import sys import sys

View file

@ -46,6 +46,10 @@ class ptemplate:
self.add_filter(add_js_home) self.add_filter(add_js_home)
self.add_filter(add_css_home_local)
self.add_filter(add_js_home_local)
self.add_filter(add_header_home) self.add_filter(add_header_home)
#self.auto_reload=True #self.auto_reload=True
@ -56,11 +60,15 @@ class ptemplate:
HeaderHTML.js=[] HeaderHTML.js=[]
HeaderHTML.header=[] HeaderHTML.header=[]
HeaderHTML.cache_header=[] HeaderHTML.cache_header=[]
HeaderHTML.css_local={}
HeaderHTML.js_local={}
def clean_header_cache(self): def clean_header_cache(self):
HeaderHTML.css=[] HeaderHTML.css=[]
HeaderHTML.js=[] HeaderHTML.js=[]
HeaderHTML.css_local={}
HeaderHTML.js_local={}
HeaderHTML.header=[] HeaderHTML.header=[]
HeaderHTML.cache_header=[] HeaderHTML.cache_header=[]
@ -80,8 +88,8 @@ class ptemplate:
#Standard templates #Standard templates
standard_templates=path.dirname(__name__)+'/templates' standard_templates=path.dirname(__file__)+'/templates'
#print(standard_templates)
return TemplateLookup(directories=[theme_templates, module_templates, standard_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace') return TemplateLookup(directories=[theme_templates, module_templates, standard_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace')
#return Environment(autoescape=self.guess_autoescape, auto_reload=True, loader=FileSystemLoader([theme_templates, module_templates])) #return Environment(autoescape=self.guess_autoescape, auto_reload=True, loader=FileSystemLoader([theme_templates, module_templates]))
@ -128,6 +136,10 @@ class HeaderHTML:
for js in HeaderHTML.js: for js in HeaderHTML.js:
final_js.append('<script language="Javascript" src="'+make_media_url('js/'+js)+'"></script>') final_js.append('<script language="Javascript" src="'+make_media_url('js/'+js)+'"></script>')
for module, arr_js in HeaderHTML.js_local.items():
for js in arr_js:
final_js.append('<script language="Javascript" src="'+make_media_url_module('js/'+js, module)+'"></script>')
return "\n".join(final_js) return "\n".join(final_js)
def css_home(): def css_home():
@ -137,6 +149,12 @@ class HeaderHTML:
for css in HeaderHTML.css: for css in HeaderHTML.css:
final_css.append('<link href="'+make_media_url('css/'+css)+'" rel="stylesheet" type="text/css"/>') final_css.append('<link href="'+make_media_url('css/'+css)+'" rel="stylesheet" type="text/css"/>')
for module, arr_css in HeaderHTML.css_local.items():
for css in arr_css:
final_css.append('<link href="'+make_media_url_module('css/'+css, module)+'" rel="stylesheet" type="text/css"/>')
return "\n".join(final_css) return "\n".join(final_css)
@ -159,14 +177,34 @@ def add_css_home(css):
if not css in HeaderHTML.css: if not css in HeaderHTML.css:
HeaderHTML.css.append(css) HeaderHTML.css.append(css)
return "" return ''
def add_js_home(js): def add_js_home(js):
if not js in HeaderHTML.js: if not js in HeaderHTML.js:
HeaderHTML.js.append(js) HeaderHTML.js.append(js)
return "" return ''
def add_css_home_local(css, module):
if not css in HeaderHTML.css_local:
HeaderHTML.css_local[module]=HeaderHTML.css_local.get(module, [])
HeaderHTML.css_local[module].append(css)
return ''
def add_js_home_local(js, module):
if not js in HeaderHTML.js_local:
HeaderHTML.js_local[module]=HeaderHTML.js_local.get(module, [])
HeaderHTML.js_local[module].append(js)
return ''
def set_flash_message(message): def set_flash_message(message):

View file

@ -1,8 +1,8 @@
#!/usr/bin/python3 #!/usr/bin/python3
from math import ceil, floor from math import ceil, floor
from citoplasma.urls import add_get_parameters from paramecio.citoplasma.urls import add_get_parameters
from citoplasma.i18n import I18n from paramecio.citoplasma.i18n import I18n
class Pages: class Pages:

View file

@ -5,10 +5,10 @@
<title>${title}</title> <title>${title}</title>
<!--<link href="{{'css/admin/admin.css'|make_media_url}}" rel="stylesheet" type="text/css"/> <!--<link href="{{'css/admin/admin.css'|make_media_url}}" rel="stylesheet" type="text/css"/>
<link href="{{'css/font-awesome.min.css'|make_media_url}}" rel="stylesheet" type="text/css"/>--> <link href="{{'css/font-awesome.min.css'|make_media_url}}" rel="stylesheet" type="text/css"/>-->
${add_css_home('admin/admin.css')} ${add_css_home_local('admin.css', 'admin')}
${add_css_home('font-awesome.min.css')} ${add_css_home_local('font-awesome.min.css', 'admin')}
${HeaderHTML.css_home()|n} ${HeaderHTML.css_home()|n}
${add_js_home('jquery.min.js')} ${add_js_home_local('jquery.min.js', 'admin')}
${HeaderHTML.js_home()|n} ${HeaderHTML.js_home()|n}
${HeaderHTML.header_home()|n} ${HeaderHTML.header_home()|n}
</head> </head>

View file

@ -4,9 +4,9 @@
<title><%block name="title">${lang('admin', 'login', 'Paramecio Login')}</%block></title> <title><%block name="title">${lang('admin', 'login', 'Paramecio Login')}</%block></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
${add_js_home('jquery.min.js')} ${add_js_home_local('jquery.min.js', 'admin')}
${add_css_home('admin/login.css')} ${add_css_home_local('login.css', 'admin')}
${add_css_home('font-awesome.min.css')} ${add_css_home_local('font-awesome.min.css', 'admin')}
${HeaderHTML.css_home()|n} ${HeaderHTML.css_home()|n}
${HeaderHTML.js_home()|n} ${HeaderHTML.js_home()|n}
<%block name="ajax"> <%block name="ajax">

4
cromosoma/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*~
*.pyc
__pycache__

340
cromosoma/LICENSE Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

1
cromosoma/README.md Normal file
View file

@ -0,0 +1 @@
# A very simple ORM for Python 3

0
cromosoma/__init__.py Normal file
View file

100
cromosoma/corefields.py Normal file
View file

@ -0,0 +1,100 @@
from paramecio.cromosoma.webmodel import PhangoField
from paramecio.cromosoma import coreforms
from paramecio.citoplasma.i18n import I18n
class IntegerField(PhangoField):
def __init__(self, name, size=11, required=False):
super(IntegerField, self).__init__(name, size, required)
def check(self, value):
self.error=None
self.txt_error=''
try:
value=str(int(value))
if value==0 and self.required==True:
self.txt_error="The value is zero"
self.error=True
except:
self.error=True
return value
def get_type_sql(self):
return 'INT('+str(self.size)+') NOT NULL DEFAULT "0"'
class CharField(PhangoField):
pass
class ForeignKeyField(IntegerField):
def __init__(self, name, related_table, size=11, required=False, identifier_field='id', named_field="id", select_fields=[]):
self.table_id=related_table.name_field_id
self.table_name=related_table.name
self.identifier_field=identifier_field
self.named_field=named_field
self.select_fields=select_fields
super(ForeignKeyField, self).__init__(name, size, required)
self.foreignkey=True
class BooleanField(IntegerField):
def __init__(self, name, size=1):
required=False
self.yes=I18n.lang('common', 'yes', 'Yes')
self.no=I18n.lang('common', 'no', 'No')
super(IntegerField, self).__init__(name, size, required)
def check(self, value):
self.error=False
self.txt_error=''
try:
value=int(value)
if value<0 or value>1:
self.txt_error="Need 0 or 1 value"
self.error=True
except:
self.error=True
value=0
value=str(value)
return value
def get_type_sql(self):
return 'BOOLEAN NOT NULL DEFAULT "0"'
def show_formatted(self, value):
value=int(value)
if value==0:
value=self.yes_text
else:
value=self.no_text
return value

76
cromosoma/coreforms.py Normal file
View file

@ -0,0 +1,76 @@
#!/usr/bin/python3
from collections import OrderedDict
#Forms para python3
class BaseForm:
def __init__(self, name, value):
self.label=name
self.name=name
self.default_value=value
self.css=''
self.type='text'
self.field=None
self.required=False
self.txt_error=''
def form(self):
return '<input type="'+self.type+'" class="'+self.css+'" name="'+self.name+'" id="'+self.name+'_form" value="'+self.setform(self.default_value)+'">'
def show_formatted(self, value):
return value
#Method for escape value for html input. DON'T CHANGE IF YOU DON'T KNOWN WHAT ARE YOU DOING
def setform(self, value):
value=str(value)
return value.replace('"', '&quot;')
class TextForm(BaseForm):
def __init__(self, name, value):
super(TextForm, self).__init__(name, value)
class PasswordForm(BaseForm):
def __init__(self, name, value):
super(PasswordForm, self).__init__(name, value)
self.type='password'
def setform(self, value):
return ""
class HiddenForm(BaseForm):
def __init__(self, name, value):
super(HiddenForm, self).__init__(name, value)
self.type='hidden'
class SelectForm(BaseForm):
def __init__(self, name, value):
super(SelectForm, self).__init__(name, value)
self.arr_select=OrderedDict()
def form(self):
the_form='<select name="'+self.name+'">\n'
arr_selected={self.default_value: 'selected'}
for k,v in self.arr_select.items():
arr_selected[k]=arr_selected.get(k, '')
the_form+="<option value=\""+str(k)+"\" "+arr_selected[k]+">"+v+"</option>"
the_form+='</select>\n'
return the_form

View file

@ -0,0 +1,75 @@
#!/usr/bin/python3
import sys
import pymysql.cursors
class SqlClass:
error_connection=""
connection={}
def dummy_connect(self, connection, name_connection="default"):
pass
def connect_to_db(self, connection, name_connection="default"):
try:
self.connection[name_connection] = pymysql.connect(connection['host'],
user=connection['user'],
password=connection['password'],
db=connection['db'],
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
except:
e = sys.exc_info()[0]
v = sys.exc_info()[1]
self.error_connection="Error in connection: %s %s" % (e, v)
#return False
raise NameError(self.error_connection)
#Make def query more simple if not debugging.
def query(self, sql_query, arguments=[], name_connection="default"):
#if fetch_type=="ASSOC":
#fetch_type=pymysql.cursors.DictCursor
with self.connection[name_connection].cursor(pymysql.cursors.DictCursor) as cursor:
try:
cursor.execute(sql_query, arguments)
self.connection[name_connection].commit()
return cursor
except:
e = sys.exc_info()[0]
v = sys.exc_info()[1]
if hasattr(cursor, '_last_executed'):
sql_query=cursor._last_executed
self.error_connection="Error in query ||"+sql_query+"||: %s %s" % (e, v)
#return False
raise NameError(self.error_connection)
#Fetcho row return dictionary if is defined in query.
#def fetch(self, cursor):
#return cursor.fetchone()
def close(self, name_connection="default"):
self.connection[name_connection].close()
pass

338
cromosoma/dbadmin.py Normal file
View file

@ -0,0 +1,338 @@
#!/usr/bin/python3
import argparse
import os,traceback
import sys, inspect
import shutil
from datetime import date
from pathlib import Path
from colorama import init, Fore, Back, Style
from importlib import import_module, reload
from paramecio.cromosoma.webmodel import WebModel
#from models import books
def start():
parser = argparse.ArgumentParser(description='A tool for create tables in databases using models from Cromosoma')
parser.add_argument('--model', help='Model python path', required=True)
parser.add_argument('--config', help='The config file', required=False)
args = parser.parse_args()
init()
#Import config
config_file='config'
if args.config!=None:
config_file=args.config
try:
config=import_module('settings.'+config_file)
except:
e = sys.exc_info()[0]
v = sys.exc_info()[1]
print(Fore.WHITE+Back.RED+Style.BRIGHT+"Config file not found: %s %s" % (e, v))
exit(1)
#print(WebModel.connections)
try:
model=import_module(args.model)
for name, obj in inspect.getmembers(sys.modules[model.__name__]):
if inspect.isclass(obj):
if obj.__module__==args.model and hasattr(obj, 'webmodel'):
WebModel.model[name.lower()]=obj()
#WebModel.modelobj
except:
"""
e = sys.exc_info()[0]
v = sys.exc_info()[1]
print(Fore.WHITE+Back.RED+Style.BRIGHT +"Error, file with model not found: %s %s" % (e, v))
"""
print("Exception in user code:")
print("-"*60)
traceback.print_exc(file=sys.stdout)
print("-"*60)
exit(1)
#load the table of databases
cursor=WebModel.query(WebModel, "show tables")
table_exists=[]
for row in cursor:
table=list(row.values())[0]
if table in WebModel.model:
table_exists.append(table)
#If don't want order
#set([1,2,3,4]) - set([2,5])
tables=list(WebModel.model.keys())
#Array diff ordered
new_tables=[x for x in tables if x not in table_exists]
#If don't want order
#new_tables=set(tables)-set(table_exists)
#Need order new_tables
changes=0
#Create new tables
if len(new_tables)>0:
print(Style.BRIGHT+"Creating new tables...")
changes+=1
for table in new_tables:
print(Style.NORMAL+"--Creating table "+table+"...")
WebModel.query(WebModel, WebModel.model[table].create_table())
print("--Adding indexes and constraints for the new table")
for k_field, index in WebModel.arr_sql_index[table].items():
print("---Added index to "+k_field)
WebModel.query(WebModel, index)
for k_set, index_set in WebModel.arr_sql_set_index[table].items():
if index_set!="":
WebModel.query(WebModel, index_set)
print("---Added constraint to "+k_set)
print("--Adding uniques elements for the new table")
#See if changes exists
#Check if created tables are modified.
try:
model_old=import_module('backups.'+args.model)
for name, obj in inspect.getmembers(sys.modules[model_old.__name__]):
if inspect.isclass(obj):
if obj.__module__=='backups.'+args.model and hasattr(obj, 'webmodel'):
WebModel.model['old_'+name.lower()]=obj()
print(Style.BRIGHT+"Checking old versions of model for find changes...")
for table in tables:
#WebModel.query(WebModel, "")
#Check if new table
#fields_to_add, fields_to_modify, fields_to_add_index, fields_to_add_constraint, fields_to_add_unique, fields_to_delete_index, fields_to_delete_unique, fields_to_delete_constraint, fields_to_delete
fields_to_add=[]
fields_to_modify=[]
fields_to_add_index=[]
fields_to_add_constraint=[]
fields_to_add_unique=[]
fields_to_delete_index=[]
fields_to_delete_unique=[]
fields_to_delete_constraint=[]
fields_to_delete=[]
old_table='old_'+table
for f, v in WebModel.model[table].fields.items():
if not f in WebModel.model[old_table].fields:
fields_to_add.append(f)
#Add index
if v.indexed==True:
fields_to_add_index.append(f)
changes+=1
#Add unique
if v.unique==True:
fields_to_add_unique.append(f)
changes+=1
#Add constraint
if v.foreignkey==True:
fields_to_add_constraint.append(f)
changes+=1
changes+=1
#If exists field in old webmodel and new
else:
v_old=WebModel.model[old_table].fields[f]
if v.get_type_sql()!=v_old.get_type_sql():
fields_to_modify.append(f)
changes+=1
#Add index
if v.indexed==True and v_old.indexed==False:
fields_to_add_index.append(f)
changes+=1
if v.indexed==False and v_old.indexed==True:
fields_to_delete_index.append(f)
changes+=1
#Add unique
if v.unique==True and v_old.unique==False:
fields_to_add_unique.append(f)
changes+=1
if v.unique==False and v_old.unique==True:
fields_to_delete_unique.append(f)
changes+=1
#Add constraint
if v.foreignkey==True and v_old.foreignkey==False:
fields_to_add_constraint.append(f)
changes+=1
if v.foreignkey==False and v_old.foreignkey==True:
fields_to_delete_constraint.append(f)
changes+=1
for f, v in WebModel.model[old_table].fields.items():
if not f in WebModel.model[table].fields:
#Add constraint
if v.foreignkey==True:
fields_to_delete_constraint.append(f)
changes+=1
fields_to_delete.append(f)
changes+=1
WebModel.model[table].update_table(fields_to_add, fields_to_modify, fields_to_add_index, fields_to_add_constraint, fields_to_add_unique, fields_to_delete_index, fields_to_delete_unique, fields_to_delete_constraint, fields_to_delete)
#for field_update in arr_update:
#Make a for in fields, if the field not exist in old model, create, if is not same type, recreate. If no have index now, delete index, if is a new index, create, same thing with uniques
#for field in WebModel.model
except ImportError:
pass
except:
print("Exception in user code:")
print("-"*60)
traceback.print_exc(file=sys.stdout)
print("-"*60)
exit(1)
original_file_path=args.model.replace('.', '/')+'.py'
backup_path='backups/'+original_file_path
if changes>0:
print(Style.BRIGHT+"Creating backup of the model. WARNING: DON'T DELETE BACKUPS DIRECTORY IF YOU WANT MAKE CHANGES IN THE FUTURE WITHOUT MODIFY DIRECTLY THE DATABASE")
create_backup(original_file_path, backup_path)
else:
if not os.path.isfile(backup_path):
create_backup(original_file_path, backup_path)
print(Style.BRIGHT+"All tasks finished")
def create_backup(original_file_path, file_path):
#Create copy
path=os.path.dirname(file_path)
p=Path(path)
if not p.is_dir():
p.mkdir(0o755, True)
#Create path
if os.path.isfile(file_path):
today = date.today()
shutil.copy(file_path, file_path+'.'+today.strftime("%Y%M%d%H%M%S"))
new_file=""
f=open(original_file_path)
for line in f:
"""
new_line=line.replace("model[\"", "model[\"old_")
new_line=new_line.replace("model['", "model['old_")
new_line=new_line.replace("WebModel(\"", "WebModel(\"old_")
new_line=new_line.replace("WebModel('", "WebModel('old_")
"""
new_file+=line
f.close()
f=open(file_path, 'w')
f.write(new_file)
f.close()

View file

View file

@ -0,0 +1,18 @@
from paramecio.cromosoma.corefields import CharField
import re
mail_pattern=re.compile("\w[\w\.-]*@\w[\w\.-]+\.\w+")
class EmailField(CharField):
def check(self, value):
self.error=False
self.txt_error=''
if not mail_pattern.match(value):
self.error=True
self.txt_error='No valid format'
return value

View file

@ -0,0 +1,49 @@
from paramecio.cromosoma.corefields import PhangoField
from paramecio.cromosoma.coreforms import PasswordForm
from passlib.hash import bcrypt
class PasswordField(PhangoField):
def __init__(self, name, size=255, required=False):
super(PasswordField, self).__init__(name, size, required)
self.protected=True
self.name_form=PasswordForm
self.default_value=''
def check(self, value):
self.txt_error=''
self.error=False
value.strip()
if value=='':
if self.model!=None:
if self.model.updated==True:
self.required=False
self.check_blank=True
return ""
else:
self.txt_error="The value is empty"
self.error=True
else:
self.txt_error="The value is empty"
self.error=True
else:
value = bcrypt.encrypt(value)
return value
@staticmethod
def verify( password, h):
return bcrypt.verify(password, h)

42
cromosoma/formsutils.py Normal file
View file

@ -0,0 +1,42 @@
#!/usr/bin/python3
from paramecio.cromosoma import corefields
from bottle import request
def pass_values_to_form(post, arr_form, yes_error=True):
for key, value in arr_form.items():
post[key]=post.get(key, '')
arr_form[key].default_value=post[key]
if arr_form[key].field==None:
arr_form[key].field=corefields.CharField(key, 255, required=False)
# Recheck value if no set error field
if arr_form[key].field.error == None:
arr_form[key].field.check(post[key])
arr_form[key].txt_error=""
if arr_form[key].required==True and arr_form[key].field.error==True and yes_error==True:
arr_form[key].txt_error=arr_form[key].field.txt_error
# Reset error on field.
arr_form[key].field.error=None
return arr_form
def show_form(post, arr_form, t, yes_error=True, modelform_tpl='forms/modelform.phtml'):
pass_values_to_form(post, arr_form, yes_error)
return t.load_template(modelform_tpl, forms=arr_form)
#Function for initial values for necessary fields.
def ini_fields(fields):
pass

134
cromosoma/usermodel.py Normal file
View file

@ -0,0 +1,134 @@
#!/usr/bin/python3
from paramecio.cromosoma.webmodel import WebModel
from paramecio.cromosoma.coreforms import PasswordForm
from paramecio.citoplasma.i18n import I18n
from paramecio.citoplasma.httputils import GetPostFiles
class UserModel(WebModel):
def __init__(self, name_field_id="id"):
super().__init__(name_field_id)
self.password_field='password'
self.email_field='email'
self.username_field='username'
self.yes_repeat_password=True
def create_forms(self, arr_fields={}):
# Add password_repeat to forms from the model
super().create_forms(arr_fields)
if self.password_field in arr_fields and self.yes_repeat_password:
repeat_password=PasswordForm('repeat_password', '')
repeat_password.required=1
repeat_password.label=I18n.lang('common', 'repeat_password', 'Repeat Password')
self.create_form_after(self.password_field, repeat_password)
"""
def insert(self, dict_values, external_agent=True):
if 'password' in dict_values:
dict_values['repeat_password']=dict_values.get('repeat_password', '')
if dict_values['repeat_password']!=dict_values[self.password_field]:
self.fields[self.password_field].error=True
self.fields['password'].txt_error=I18n.lang('common', 'error_passwords_no_match', 'Error: passwords doesn\'t match')
return super().insert(dict_values, external_agent)
"""
def check_all_fields(self, dict_values, external_agent, yes_update=False, errors_set="insert"):
try:
fields, values, update_values=super().check_all_fields(dict_values, external_agent, yes_update, errors_set)
except:
return False
# Check if passwords matches
if self.password_field in dict_values:
dict_values['repeat_password']=dict_values.get('repeat_password', '')
if dict_values['repeat_password']!=dict_values[self.password_field]:
if dict_values[self.password_field].strip()!="":
self.fields[self.password_field].error=True
self.fields[self.password_field].txt_error=I18n.lang('common', 'error_passwords_no_match', 'Error: passwords doesn\'t match')
return False
# Check if exists user with same email or password
get_id=0
if self.updated:
# Need the id
GetPostFiles.obtain_get()
GetPostFiles.obtain_post()
get_id=GetPostFiles.get.get(self.name_field_id, '0')
post_id=GetPostFiles.post.get(self.name_field_id, '0')
if get_id!='0':
get_id=int(get_id)
if post_id!='0':
get_id=int(post_id)
pass
sql_id=''
original_conditions=self.conditions
self.reset_conditions()
if self.username_field in dict_values:
self.conditions=['WHERE username=%s', [dict_values[self.username_field]]]
if self.email_field in dict_values:
if len(self.conditions[1])>0:
self.conditions[0]+=' OR email=%s'
else:
self.conditions[0]='WHERE email=%s'
self.conditions[1]=[]
self.conditions[1].append([dict_values[self.email_field]])
if get_id>0:
self.conditions[0]=' AND '+self.username_field+'=%s'
self.conditions[1].append(get_id)
if self.select_count()>0:
self.fields[self.username_field].error=True
self.fields[self.username_field].txt_error=I18n.lang('common', 'error_username_or_password_exists', 'Error: username or email exists in database')
return False
self.conditions=original_conditions
return fields, values, update_values

879
cromosoma/webmodel.py Normal file
View file

@ -0,0 +1,879 @@
#!/usr/bin/python3
import sys
import re
import uuid
from importlib import import_module, reload
from collections import OrderedDict
from paramecio.cromosoma.databases.mysql import SqlClass
from paramecio.cromosoma.coreforms import BaseForm, HiddenForm
# The most important class for the framework
#
# Webmodel is a class for create objects that represent models. This models are a mirage of SQL tables. You can create fields, add indexes, foreign keys, and more.
#
#
class WebModel:
#Globals class variables for internal tasks
arr_sql_index={}
arr_sql_set_index={}
arr_sql_unique={}
arr_sql_set_unique={}
last_query=""
make_connection=SqlClass.connect_to_db
#A dictionary for add models here
model=OrderedDict()
connections={'default': {'host': 'localhost', 'user': 'user', 'password': '', 'db': 'default', 'charset': 'utf8', 'set_connection': False} }
connection_id="default"
webmodel=True
# Init the class
def __init__(self, name_field_id="id"):
#The name of the table
self.name=type(self).__name__.lower()
self.label=self.name
self.label_general=self.name
self.name_field_id=name_field_id
#Fields of the table, inserte with register method
self.fields=OrderedDict()
#The tables related with foreignkeyfield to this table
self.related=[]
#A dictionary where forms of this model are saved
self.forms=OrderedDict()
self.cache_method=''
# A dictionary with the errors in fields.
self.fields_errors={}
self.errors={}
self.num_errors=0
self.query_error=""
self.conditions=["WHERE 1=1", []]
self.order_by="ORDER BY `"+self.name+"`.`id` ASC"
self.limit=""
self.related_models_deleted=[]
self.required_save={}
#Create id field
self.register(PrimaryKeyField(self.name_field_id))
#self.model[name]=self
self.yes_reset_conditions=True
self.create_fields()
self.updated=False
self.valid_fields=[]
# A method where create the new fields of this model
def create_fields(self):
pass
# A method for register the fields
def register(self, field_model):
#self.fields_required[field_model]=field_model.required
self.fields[field_model.name]=field_model
self.fields[field_model.name].model=self
# A method for create the id field.
def create_id_field(self, field_name="id"):
pass
# A method for select rows from a database.
def connect_to_db(self):
if WebModel.make_connection(SqlClass, self.connections[self.connection_id])==False:
raise NameError(SqlClass.error_connection)
WebModel.make_connection=SqlClass.dummy_connect
def dummy_connect(self, connection):
return True
# Static method for make queries
@staticmethod
def query(WebModel, str_query, args=[], connection_id='default'):
WebModel.connect_to_db(WebModel)
return SqlClass.query(SqlClass, str_query, args, connection_id)
# Insert method, for insert a row in database.using a dictionary
# External agent define if the update is in code or from external source, how a form.
def insert(self, dict_values, external_agent=True):
# Connect to db
self.connect_to_db()
self.query_error=''
self.fields[self.name_field_id].required=False
try:
fields, values, update_values=self.check_all_fields(dict_values, external_agent)
except:
self.query_error='Cannot insert the new row'
return False
sql="insert into `"+self.name+"` (`"+"`, `".join(fields)+"`) VALUES ("+", ".join(values)+")"
cursor=SqlClass.query(SqlClass, sql, self.conditions[1], self.connection_id)
if cursor.rowcount>0:
return True
else:
self.query_error='Cannot insert the new row'
return False
# Update method. For update one or many rows.
def update(self, dict_values, external_agent=True):
# Connect to db
self.fields[self.name_field_id].required=False
if self.name_field_id in dict_values:
del dict_values[self.name_field_id]
self.connect_to_db()
self.query_error=''
#try:
self.updated=True
try:
fields, values, update_values=self.check_all_fields(dict_values, external_agent, True, 'update')
except:
return False
sql="update `"+self.name+"` SET "+", ".join(update_values)+" "+self.conditions[0]
cursor=SqlClass.query(SqlClass, sql, self.conditions[1], self.connection_id)
if self.yes_reset_conditions:
self.reset_conditions()
return True
"""
if cursor.rowcount>0:
if self.yes_reset_conditions:
self.reset_conditions()
return True
else:
self.query_error='Cannot update the row'
return False
"""
"""
except:
#self.query_error=SqlClass.error_connection
e = sys.exc_info()[0]
v = sys.exc_info()[1]
self.error_connection="Error in query: %s %s" % (e, v)
return False
"""
def reset_conditions(self):
self.conditions=["WHERE 1=1", []]
# A method for select fields from a table in db. Support for foreignkeys.
#Type assoc can be assoc for return dictionaries
def select(self, arr_select=[], raw_query=0):
# Connect to db
self.connect_to_db()
conditions=self.conditions
final_fields=[]
extra_fields=[]
self.query_error=''
#First table selecction
tables_to_select=['`'+self.name+'`']
keys=list(self.fields.keys())
if len(arr_select)==0:
arr_select=keys
# Array intersect for obtain the valid fields
fields = list(set(keys) & set(arr_select))
#Creating the fields
for field in fields:
#Check if foreignkeyfield
if type(self.fields[field]).__name__=="ForeignKeyField" and raw_query==0:
table_name=self.fields[field].table_name
tables_to_select.append('`'+table_name+'`')
# Add field from related table
# as "+table_name+"_"+self.fields[field].named_field
extra_fields.append("`"+table_name+"`.`"+self.fields[field].named_field+"` as "+field)
# Add a condition to sql query for join the two tables.
conditions[0]+=" AND `"+table_name+"`.`"+self.fields[field].identifier_field+"`=`"+self.name+"`.`"+field+"`"
# Add extra fields from related table from select_fields ForeignKeyField class member
for extra_field in self.fields[field].select_fields:
extra_fields.append("`"+table_name+"`.`"+extra_field+"` as `"+table_name+"_"+extra_field+"`")
else:
# Add normal field to sql query
final_fields.append("`"+self.name+"`.`"+field+"`")
extra_sql_field=""
if len(extra_fields)>0:
extra_sql_field=", "+", ".join(extra_fields)
if len(final_fields)==0:
self.query_error="Error: without fields to search"
return False
sql= ("select "+", ".join(final_fields)+extra_sql_field+" from "+", ".join(tables_to_select)+' '+conditions[0]+' '+self.order_by+' '+self.limit).strip()
self.last_query=sql
if self.yes_reset_conditions:
self.reset_conditions()
cursor=SqlClass.query(SqlClass, sql, conditions[1], self.connection_id)
if cursor==False:
self.query_error=SqlClass.error_connection
return False
else:
return cursor
# Show results in a dictionary
def fetch(self, cursor):
return cursor.fetchone()
def insert_id(self, cursor):
return cursor.lastrowid
def element_exists(self, id):
self.conditions=['WHERE `'+self.name_field_id+'`=%s', [id]]
count=self.select_count(self.name_field_id)
if self.yes_reset_conditions:
self.reset_conditions()
if count>0:
return True
return False
def select_a_field(self, field):
pass
def select_a_row(self, id, fields_selected=[], raw_query=0):
self.conditions=['WHERE `'+self.name+'`.`'+self.name_field_id+'`=%s', [id]]
self.limit="limit 1"
cursor=self.select(fields_selected, raw_query)
self.reset_conditions()
row=cursor.fetchone()
if row==None:
row=False
return row
def select_a_row_where(self, fields_selected=[], raw_query=0):
self.limit="limit 1"
cursor=self.select(fields_selected, raw_query)
row=cursor.fetchone()
if row==None:
row=False
return row
def select_to_array(self, fields_selected=[], raw_query=0):
if len(fields_selected) > 0 and (self.name_field_id not in fields_selected):
fields_selected.append(self.name_field_id)
cursor=self.select(fields_selected, raw_query)
results={}
for row in cursor:
results[row[self.name_field_id]]=row
return results
# A method por count num rows affected for sql conditions
def select_count(self, field_to_count='id', raw_query=1):
# Connect to db
self.connect_to_db()
conditions=self.conditions
#First table selecction
tables_to_select=['`'+self.name+'`']
fields=list(self.fields.keys())
#Creating the fields
for field in fields:
#Check if foreignkeyfield
if type(self.fields[field]).__name__=="ForeignKeyField" and raw_query==0:
table_name=self.fields[field].table_name
tables_to_select.append('`'+table_name+'`')
# Add a condition to sql query for join the two tables.
conditions[0]+=" AND `"+table_name+"`.`"+self.fields[field].identifier_field+"`=`"+self.name+"`.`"+field+"`"
sql= "select count(`"+field_to_count+"`) from "+", ".join(tables_to_select)+conditions[0]
cursor=SqlClass.query(SqlClass, sql, conditions[1], self.connection_id)
count=list(cursor.fetchone().values())[0]
if self.yes_reset_conditions:
self.reset_conditions()
return count
#+' ORDER BY '+self.order_by+' '+self.limit).strip()
# A method for delete rows using sql conditions
def delete(self):
self.connect_to_db()
#Need delete rows from other related tables save in self.related_models_deleted
sql="delete from `"+self.name+"` "+self.conditions[0]
result=SqlClass.query(SqlClass, sql, self.conditions[1], self.connection_id)
if self.yes_reset_conditions:
self.reset_conditions()
return result
# Method for create sql tables
def create_table(self):
#self.connect_to_db()
self.arr_sql_index[self.name]={}
self.arr_sql_set_index[self.name]={}
self.arr_sql_unique[self.name]={}
self.arr_sql_set_unique[self.name]={}
#foreach($this->components as $field => $data)
table_fields=[]
#Create id field
#Not neccesary
#table_fields.append('`'+self.name_field_id+"` INT NOT NULL PRIMARY KEY AUTO_INCREMENT")
for field, data in self.fields.items():
table_fields.append('`'+field+'` '+data.get_type_sql())
#Check if indexed
if self.fields[field].indexed==True:
self.arr_sql_index[self.name][field]='CREATE INDEX `index_'+self.name+'_'+field+'` ON '+self.name+'(`'+field+'`);'
self.arr_sql_set_index[self.name][field]=""
#Check if unique
if self.fields[field].unique==True:
self.arr_sql_unique[self.name][field]='ALTER TABLE `'+self.name+'` ADD UNIQUE (`'+field+'`)'
self.arr_sql_set_unique[self.name][field]=""
if type(self.fields[field]).__name__=="ForeignKeyField":
self.arr_sql_index[self.name][field]='CREATE INDEX `index_'+self.name+'_'+field+'` ON '+self.name+'(`'+field+'`);'
table_related=self.fields[field].table_name
id_table_related=self.fields[field].table_id
self.arr_sql_set_index[self.name][field]='ALTER TABLE `'+self.name+'` ADD CONSTRAINT `'+field+'_'+self.name+'IDX` FOREIGN KEY ( `'+field+'` ) REFERENCES `'+table_related+'` (`'+id_table_related+'`) ON DELETE RESTRICT ON UPDATE RESTRICT;'
return "create table `"+self.name+"` (\n"+",\n".join(table_fields)+"\n) DEFAULT CHARSET=utf8;";
def update_table(self, fields_to_add, fields_to_modify, fields_to_add_index, fields_to_add_constraint, fields_to_add_unique, fields_to_delete_index, fields_to_delete_unique, fields_to_delete_constraint, fields_to_delete):
#Obtain new fields
for field in fields_to_modify:
print("---Updating "+field+" in "+self.name)
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` MODIFY `'+field+'` '+self.fields[field].get_type_sql(), [], self.connection_id)
for field in fields_to_add:
print("---Adding "+field+" in "+self.name)
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` ADD `'+field+'` '+self.fields[field].get_type_sql(), [], self.connection_id)
for field in fields_to_add_index:
print("---Adding index to "+field+" in "+self.name)
WebModel.query(WebModel, 'CREATE INDEX `index_'+self.name+'_'+field+'` ON '+self.name+' (`'+field+'`);', [], self.connection_id)
for field in fields_to_add_constraint:
print("---Adding foreign key to "+field+" in "+self.name)
table_related=self.fields[field].table_name
id_table_related=self.fields[field].table_id
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` ADD CONSTRAINT `'+field+'_'+self.name+'IDX` FOREIGN KEY ( `'+field+'` ) REFERENCES `'+table_related+'` (`'+id_table_related+'`) ON DELETE RESTRICT ON UPDATE RESTRICT;', [], self.connection_id)
for field in fields_to_add_unique:
print("---Adding unique to "+field+" in "+self.name)
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` ADD UNIQUE (`'+field+'`)', [], self.connection_id)
for field in fields_to_delete_index:
print("---Deleting index from "+field+" in "+self.name)
WebModel.query(WebModel, 'DROP INDEX `index_'+self.name+'_'+field+'` ON '+self.name, [], self.connection_id)
for field in fields_to_delete_unique:
print("---Deleting unique from "+field+" in "+self.name)
WebModel.query(WebModel, 'DROP INDEX `'+field+'` ON '+self.name, [], self.connection_id)
for field in fields_to_delete_constraint:
print("---Deleting foreignkey from "+field+" in "+self.name)
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` DROP FOREIGN KEY '+field+'_'+self.name+'IDX', [], self.connection_id)
for field in fields_to_delete:
print("---Deleting "+field+" from "+self.name)
WebModel.query(WebModel, 'ALTER TABLE `'+self.name+'` DROP `'+field+'`', [], self.connection_id)
#Deleting indexes and constraints.
# Method for drop sql tables and related
def drop_table(name):
pass
#Return an array with all fields
def all_fields():
pass
#Check of all fields in table.
def check_all_fields(self, dict_values, external_agent, yes_update=False, errors_set="insert"):
fields=[]
values=[]
update_values=[]
self.errors[errors_set]=[]
self.num_errors=0
#A dictionary that define if update property is added
updated_field={}
updated_field['insert']=0
updated_field['update']=1
error=False
if yes_update==True:
f_update=lambda field, value: "`"+field+"`="+value+""
else:
f_update=lambda field, value: ""
# I can optimize this later
for k, v in self.fields.items():
#List where the errors are saved
self.fields_errors[k]=[]
if k in dict_values:
# If fields is protected, but external_agent =0, then insert
# If fields is not protected always insert if not error checking
value=dict_values[k]
# Need rewrite the error because shitty python don't clean nothing
self.fields[k].error=False
if (self.fields[k].protected==None or self.fields[k].protected==False or external_agent==False) and k in self.valid_fields:
self.fields[k].update=updated_field[errors_set]
value=self.fields[k].check(value)
if self.fields[k].check_blank==False or self.updated==False:
# If error checking, value=False
if self.fields[k].error==True and self.fields[k].required==True:
#Error, need this fields.
self.num_errors+=1
self.fields_errors[k].append("Error: "+v.label+" field required")
error=True
else:
fields.append(k)
final_value=self.fields[k].quot_open+value+self.fields[k].quot_close
values.append(final_value)
update_values.append(f_update(k, final_value))
else:
self.num_errors+=1
self.fields_errors[k].append("Error: "+self.fields[k].label+" is protected field")
self.fields[k].error=True
self.fields[k].txt_error="Error: "+self.fields[k].label+" is protected field"
error=True
elif v.required==True:
self.num_errors+=1
self.fields_errors[k].append("Error: "+v.label+" field required")
error=True
if len(fields)==0:
self.num_errors+=1
self.errors[errors_set].append("Error: no elements to insert in table")
error=True
if error==True:
self.num_errors+=1
self.errors[errors_set].append("Error: error checking the values of the table")
return False
return (fields, values, update_values)
#Reset the require field in fields
def reset_require(self):
for k, v in self.fields.items():
self.required_save[k]=self.fields[k].required
self.fields[k].required=0
#Reload the require field in fields
def reload_require(self):
for k,r in self.fields.items():
self.fields[k].required=r
#Create a form based in table.
def create_forms(self, arr_fields={}):
if len(arr_fields)==0:
arr_fields=self.fields.keys()
#for name_field, field in self.fields.items():
for name_field in arr_fields:
self.valid_fields.append(name_field)
self.forms[name_field]=self.fields[name_field].create_form()
def create_form_after(self, form_after, new_form):
new_dict=OrderedDict()
for name_form, form in self.forms.items():
new_dict[name_form]=form
if name_form==form_after:
new_dict[new_form.name]=new_form
self.forms=new_dict
@staticmethod
def close():
WebModel.make_connection=SqlClass.connect_to_db
SqlClass.close(SqlClass)
@staticmethod
def escape_sql(value):
value=str(value)
return value.replace("'","\\'").strip()
class PhangoField:
def __init__(self, name, size=255, required=False):
# The name of the field in database table
self.name=name
# The label for the Field
self.label=name.replace('_', ' ').title()
# If field is required, self.required is True
self.required=required
# The size of field in database
self.size=size
# Protected, if this value != None, cannot use it in insert or update.
self.protected=None
# $quote_open is used if you need a more flexible sql sentence,
# @warning USE THIS FUNCTION IF YOU KNOW WHAT YOU ARE DOING
self.quot_open='\''
# $quote_close is used if you need a more flexible sql sentence,
# @warning USE THIS PROPERTY IF YOU KNOW WHAT YOU ARE DOING
self.quot_close='\''
# Variable where the basic text error is saved
self.error=None
self.txt_error=""
# Array for create initial parameters for form..
self.parameters=[]
# Themodel where this component or field live
self.model=None
# Property used for set this field how indexed in the database table.
self.indexed=False
# Property used for set this field how unique value in the database table.
self.unique=False
# Simple property for make more easy identify foreignkeyfields.
self.foreignkey=False
# Property that define the default value for this field
self.default_value=""
# Property that define if this field is in an update operation or insert operation
self.update=False
# Property used for check if this value cannot change if is in blank and is filled
self.check_blank=False
# Define the form, when is created forms with create_forms you can change the properties of this class
self.name_form=BaseForm
# This method is used for describe the new field in a sql language format.
def get_type_sql(self):
return 'VARCHAR('+str(self.size)+') NOT NULL DEFAULT "'+self.default_value+'"'
def show_formatted(self, value):
return value
# This method for check the value
def check(self, value):
self.error=False
self.txt_error=''
value=str(value)
value=WebModel.escape_sql(value)
if value=="":
self.txt_error="The field is in blank"
self.error=True
return value
def set_relationships(self):
pass
def create_form(self):
form=self.name_form(self.name, self.default_value)
form.default_value=self.default_value
form.required=self.required
form.label=self.label
form.field=self
return form
class PrimaryKeyField(PhangoField):
def __init__(self, name, size=11, required=False):
super(PrimaryKeyField, self).__init__(name, size, required)
self.protected=True
self.name_form=HiddenForm
self.required=True
def check(self, value):
self.error=None
self.txt_error=''
if value=='':
value='0'
value=str(int(value))
if value==0:
self.txt_error="The value is zero"
self.error=True
return value
def get_type_sql(self):
return 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT'

View file

@ -9,6 +9,8 @@ from beaker.middleware import SessionMiddleware
def create_app(): def create_app():
arr_module_path={}
if config.yes_static==True: if config.yes_static==True:
@route('/media/<filename:path>') @route('/media/<filename:path>')
@ -20,11 +22,11 @@ def create_app():
@route('/mediafrom/<module>/<filename:path>') @route('/mediafrom/<module>/<filename:path>')
def send_static_module(module, filename): def send_static_module(module, filename):
path_module=module+'/media/' path_module=arr_module_path[module]+'/media/'
file_path_module=path_module+filename file_path_module=path_module+filename
path=module+'/media/' path='themes/'+config.theme+'/media/'+module
file_path=path+filename file_path=path+filename
@ -52,6 +54,10 @@ def create_app():
controller_base=os.path.dirname(controller_path.__file__) controller_base=os.path.dirname(controller_path.__file__)
base_module=module.split('.')[-1]
arr_module_path[base_module]=controller_base
dir_controllers=os.listdir(controller_base) dir_controllers=os.listdir(controller_base)
for controller in dir_controllers: for controller in dir_controllers:
@ -96,9 +102,15 @@ def create_app():
app = SessionMiddleware(app, config.session_opts, environ_key=config.cookie_name) app = SessionMiddleware(app, config.session_opts, environ_key=config.cookie_name)
if __name__ == "__main__": return app
run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
else:
return run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
def run_app(app):
run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
"""
if __name__ == "__main__":
run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
#else:
#return run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
"""

View file

@ -1,10 +1,10 @@
#!/usr/bin/python3 #!/usr/bin/python3
from modules.admin.models.admin import UserAdmin from paramecio.modules.admin.models.admin import UserAdmin
from citoplasma.urls import make_url from paramecio.citoplasma.urls import make_url
from citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.generate_admin_class import GenerateAdminClass
from citoplasma.i18n import I18n from paramecio.citoplasma.i18n import I18n
from cromosoma.coreforms import SelectForm from paramecio.cromosoma.coreforms import SelectForm
def admin(t): def admin(t):

View file

@ -11,8 +11,8 @@ from settings import config_admin
from paramecio.citoplasma.lists import SimpleList from paramecio.citoplasma.lists import SimpleList
from paramecio.citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.generate_admin_class import GenerateAdminClass
from paramecio.citoplasma.httputils import GetPostFiles from paramecio.citoplasma.httputils import GetPostFiles
from cromosoma.formsutils import show_form, pass_values_to_form from paramecio.cromosoma.formsutils import show_form, pass_values_to_form
from cromosoma.coreforms import PasswordForm from paramecio.cromosoma.coreforms import PasswordForm
from importlib import import_module, reload from importlib import import_module, reload
from bottle import redirect from bottle import redirect
from collections import OrderedDict from collections import OrderedDict

View file

@ -0,0 +1,637 @@
body
{
margin:0px;
background-color:#f7f6f1;
font-family: sans, sans-serif, serif;
}
a
{
color: #1c6280;
}
a:hover
{
color: #d54e21;
}
#header
{
width:100%;
height:47px;
color:#000;
font-size:22px;
font-family:sans, serif;
background-image:url('../images/background.png');
background-position:top;
background-repeat:repeat-x;
background-color:#959595;
line-height: 47px;
}
#title_phango
{
font-size:28px;
padding-left:15px;
color: #ffffff;
font-style:italic;
text-shadow:#000000 1px 1px 1px;
filter: progid:DXImageTransform.Microsoft.Shadow(color='#000000', Direction=130, Strength=4);
}
#title_framework
{
font-size:28px;
padding-right:15px;
color:#ff9b2f;
font-style:italic;
text-shadow:#000000 1px 1px 1px;
filter: progid:DXImageTransform.Microsoft.Shadow(color='#000000', Direction=130, Strength=4);
}
h1
{
font-family:sans, serif;
font-size:26px;
font-weight:normal;
font-style:italic;
color:#04004e;
background-image:url('../images/button_head.png');
background-repeat: no-repeat;
/*padding-left:65px;*/
/*height:60px;
line-height:60px;*/
}
#logo_header
{
}
#center_body {
background-position:left;
background-repeat:repeat-y;
height: auto !important;
width:100%;
margin-left:auto;
margin-right:auto;
overflow:auto;
height: auto !important;
min-height:300px;
position:relative;
}
#menu
{
float:left;
width:18%;
margin-right:25px;
position:relative;
}
#menu a
{
font-size:12px;
/*font-family:arial, sans;*/
font-weight:bold;
text-decoration:none;
color:#6183b0;
display:block;
border:solid #cccccc;
border-width:0px 1px 1px 1px;
padding:5px;
background: #ececec;
}
#menu a:hover
{
text-decoration:underline;
color:#5072a0;
background: #e7e7e7;
}
#menu a.sub_module
{
color:#6183b1;
background-color: #fbfbfb;
text-decoration:none;
}
.menu_title
{
padding:5px;
font-size:14px;
/*font-family:arial, sans;*/
font-weight:bold;
padding:5px;
background-image:url('../images/background_title.png');
background-position:top;
background-repeat: repeat-x;
background-color: #fcf7fd;
border-radius: 8px 8px 0px 0px;
border:solid #cccccc;
border-width:1px 1px 1px 1px;
color: #333333;
}
.father_admin {
padding:5px;
font-size:14px;
display: block;
color: #fbfbfb;
font-weight:bold;
background: rgba(76,76,76,1);
background: -moz-linear-gradient(top, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 39%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 51%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(76,76,76,1)), color-stop(12%, rgba(89,89,89,1)), color-stop(25%, rgba(102,102,102,1)), color-stop(39%, rgba(71,71,71,1)), color-stop(50%, rgba(44,44,44,1)), color-stop(51%, rgba(0,0,0,1)), color-stop(60%, rgba(17,17,17,1)), color-stop(76%, rgba(43,43,43,1)), color-stop(91%, rgba(28,28,28,1)), color-stop(100%, rgba(19,19,19,1)));
background: -webkit-linear-gradient(top, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 39%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 51%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
background: -o-linear-gradient(top, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 39%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 51%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
background: -ms-linear-gradient(top, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 39%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 51%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
background: linear-gradient(to bottom, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 39%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 51%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313', GradientType=0 );
}
.content_admin
{
margin:auto;
background-color:#ffffff;
padding:10px 10px 10px 10px;
border:solid #dfdfdf;
border-width: 1px;
font-size:12px;
position:relative;
overflow:auto;
margin-bottom:40px;
}
.contents
{
float:right;
width:79%;
padding:0px 0px 15px 0px;
}
.content
{
/*border: solid #000 0px;
float:right;
width:80%;*/
}
.title
{
font-size:18px;
font-weight:bold;
font-family:arial, sans;
text-decoration:none;
color:#000000;
padding:5px;
background-image:url('../images/background_title.png');
background-position:top;
background-repeat: repeat-x;
background-color: #fcf7fd;
border-radius: 8px 8px 0px 0px;
border:solid #cccccc;
border-width:1px 1px 1px 1px;
}
#inform {
margin:auto;
}
/*Styles for common templates...*/
.form {
border: solid #cbcbcb 1px;
padding:10px;
margin:10px 0px 10px 0px;
border-radius:5px;
}
.form textarea {
width:100%;
height:200px;
}
.form label {
display: block;
/*width: 150px;*/
float: left;
margin-bottom: 10px;
text-align: left;
width: 350px;
padding-right: 20px;
/*border: #000000 solid;
border-width:1px;*/
}
.form p {
clear: left;
}
img {
display:block;
}
.panel {
display:block;
float:left;
/*clear:left;*/
text-align:center;
border: #000000 solid;
border-width:0px;
min-width:200px;
width:200px !important;
padding:0px;
margin:0px;
min-height:100px;
height:100px !important;
position:relative;
}
.panel p {
position:absolute;
bottom:0px;
/*padding-bottom:0px;*/
text-align:center;
margin-left:auto;
margin-right:auto;
}
.panel img {
margin-left:auto;
margin-right:auto;
}
.table_list {
width:100%;
}
.title_list td {
border:solid #cccccc;
border-width:1px;
padding:8px;
background-image:url('../images/background_title.png');
background-position:top;
background-repeat: repeat-x;
font-size:14px;
font-weight:bold;
}
.row_list td {
border:solid #cccccc;
border-width:1px;
padding:4px;
}
.cont_text, .cont
{
margin:auto;
background-color:#ffffff;
padding:10px 10px 10px 10px;
border:solid #dfdfdf;
border-width: 0px 1px 1px 1px;
font-size:12px;
position:relative;
overflow:auto;
margin-bottom:10px;
border-radius: 0px 0px 5px 5px;
}
.cont_top {
border-width: 1px 1px 1px 1px;
border-radius: 5px 5px 5px 5px;
}
.search {
border-width: 1px;
border-radius:5px;
margin-top:5px;
}
.right_cont
{
width:78%;
}
.none_cont
{
/*width:100%;*/
}
.contview
{
border:solid #cccccc;
border-width:1px 1px 1px 1px;
padding:15px;
margin: 0px 0px 5px 0px;
}
.error
{
color: #ff0000;
font-weight:bold;
}
.hidden_form
{
display: none;
/*clear:left;*/
}
.no_hidden_form
{
display: inline;
/*float:left;
clear:left right;*/
}
a.no_choose_flag
{
filter: Alpha(opacity=50);
-moz-opacity: .5;
opacity: .5;
float:left;
margin: 2px;
}
a.choose_flag
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
float:left;
margin: 2px;
}
a:hover.no_choose_flag
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
float:left;
margin: 2px;
}
#languages
{
width:100%;
clear:left;
}
/** input **/
#center_body input {
border: solid #bcbcbc;
border-width:1px;
height:20px;
border-radius:5px;
background: #eeeeee;
}
#center_body input:hover {
background: #fafafa;
}
#center_body input[type="submit"]
{
font-family: arial,sans;
font-size:12px;
height:25px;
border-radius:25px;
background: #eee;
}
#center_body input:hover[type="submit"]
{
background: #fff;
}
#center_body input[type="button"]
{
font-family: arial,sans;
font-size:12px;
height:25px;
border-radius:25px;
background: #eee;
}
#center_body input:hover[type="button"]
{
background: #fff;
}
#center_body textarea {
border: solid #bcbcbc;
border-width:1px;
border-radius:5px;
}
#center_body select {
border: solid #bcbcbc;
border-width:1px;
border-radius:5px;
}
#languages_general, #logout
{
position:absolute;
margin: 0px 0px 0px 0px;
top:54px;
z-index:3;
right:0px;
width:50px;
}
#logout
{
top:16px;
right:5px;
font-weight:bold;
font-size:12px;
}
a.no_choose_flag_general
{
filter: Alpha(opacity=50);
-moz-opacity: .5;
opacity: .5;
float:left;
margin: 2px;
}
a.choose_flag_general
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
float:left;
margin: 2px;
}
a:hover.no_choose_flag_general
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
float:left;
margin: 2px;
}
a.form_button_tab, a.form_button_tab_selected
{
border: solid #121212 1px;
border-radius:10px;
padding:10px;
display:inline-block;
text-decoration:none;
color:#fbfbfb;
background: #000;
}
a.form_button_tab_selected
{
background:#fbfbfb;
color: #000;
}
a.form_button_tab:hover
{
color:#000;
background:#fbfbfb;
}
.flash
{
border-radius:15px;
margin-top:15px;
padding:25px;
color:#fbfbfb;
text-shadow:#000000 1px 1px 1px;
filter: progid:DXImageTransform.Microsoft.Shadow(color='#000000', Direction=130, Strength=4);
background: #ff3019; /* Old browsers */
background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff3019), color-stop(100%,#cf0404)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* IE10+ */
background: linear-gradient(to bottom, #ff3019 0%,#cf0404 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff3019', endColorstr='#cf0404',GradientType=0 ); /* IE6-9 */
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,266 @@
body {
margin:0px;
background: #fbfbfb;
font-family: 'Open Sans', sans-serif;
}
#title {
padding:10px;
color: #fbfbfb;
background: #ff7153 url("../images/admin/background_title_login.png") right no-repeat;
font-size:1.5em;
/*text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);*/
}
.form {
margin:10px 15px 10px 10px;
position:relative;
}
input {
width:100%;
border: solid #bcbcbc 1px;
font-size:2em;
border-radius:5px;
padding:2px;
}
input:focus {
border-color: #FF7052;
outline:1px;
}
.submit {
width:250px;
display: block;
margin: 0 auto 18px auto;
background: #fff;
border-radius: 10px;
border: 1px solid #FF7052;
color: #FF7052;
font-size: 24px;
cursor: pointer;
box-shadow: 0px 0px 0px 7px #fff;
transition: 0.2s ease-out;
position:relative;
}
.submit:hover,
.submit:focus {
background: #FF7052;
color: #fff;
outline: 0;
}
.error {
font-weight:bold;
color: #ff0000;
}
#submit_block {
position:relative;
}
#loading {
top:10px;
right:40px;
position:absolute;
display:block;
width:16px;
height:16px;
border: solid #000 0px;
background: url('../images/ajax-loader.gif') center no-repeat;
display:none;
}
/* Phones */
@media (max-width: 767px) {
#login {
width:100%;
border: solid #cbcbcb;
border-width:0px 0px 1px 0px;
margin-top:5px;
margin:0px;
overflow:hidden;
background: #eaeaea;
}
}
/* Tablets */
@media (min-width: 780px) and (max-width: 979px) {
#login {
position:relative;
width:400px;
border: solid #cbcbcb 1px;
margin-top:5px;
margin-left:auto;
margin-right:auto;
overflow:hidden;
background: #eaeaea;
}
}
/* Desktops */
@media (min-width: 980px) {
#login {
position:relative;
width:400px;
border: solid #cbcbcb 1px;
margin-top:5px;
margin-left:auto;
margin-right:auto;
overflow:hidden;
background: #eaeaea;
}
}
/*
* {
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0;
}
html,
body {
width: 100%;
height: 100%;
background: #cedeff;
font-family: 'Open Sans', sans-serif;
font-weight: 200;
}
.login {
position: relative;
top: 50%;
width: 250px;
display: table;
margin: -150px auto 0 auto;
background: #fff;
border-radius: 4px;
}
.legend {
position: relative;
width: 100%;
display: block;
background: #FF7052;
padding: 15px;
color: #fff;
font-size: 20px;
}
.legend:after {
content: "";
background-image: url(../images/admin/multy-user.png);
background-size: 100px 100px;
background-repeat: no-repeat;
background-position: 152px -16px;
opacity: 0.06;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
}
.input {
position: relative;
width: 90%;
margin: 15px auto;
}
.input span {
position: absolute;
display: block;
color: #d4d4d4;
left: 10px;
top: 8px;
font-size: 20px;
}
.input input {
width: 100%;
padding: 10px 5px 10px 40px;
display: block;
border: 1px solid #EDEDED;
border-radius: 4px;
transition: 0.2s ease-out;
color: #a1a1a1;
}
.input input:focus {
padding: 10px 5px 10px 10px;
outline: 0;
border-color: #FF7052;
}
.submit {
width: 45px;
height: 45px;
display: block;
margin: 0 auto -15px auto;
background: #fff;
border-radius: 100%;
border: 1px solid #FF7052;
color: #FF7052;
font-size: 24px;
cursor: pointer;
box-shadow: 0px 0px 0px 7px #fff;
transition: 0.2s ease-out;
}
.submit:hover,
.submit:focus {
background: #FF7052;
color: #fff;
outline: 0;
}
.feedback {
position: absolute;
bottom: -70px;
width: 100%;
text-align: center;
color: #fff;
background: #2ecc71;
padding: 10px 0;
font-size: 12px;
display: none;
opacity: 0;
}
.feedback:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(46, 204, 113, 0);
border-bottom-color: #2ecc71;
border-width: 10px;
margin-left: -10px;
}
*/

View file

@ -0,0 +1,902 @@
/* General styles */
body
{
margin:0px;
background:url('../images/background.png') repeat-y center #e0e5e6;
}
iframe
{
width:100%;
border:solid #5b5b5b;
border-width:1px;
border: solid #bcbcbc;
border-width:1px;
border-radius:5px;
}
a
{
font-size:12px;
font-family:verdana, verdana;
text-decoration:none;
color: #3434cc;
font-weight:bold;
}
a:hover
{
font-size:12px;
font-family:verdana, verdana;
text-decoration:underline;
color: #4545dd;
font-weight:bold;
}
strong
{
font-weight: bold;
}
img {
/*display:block;*/
}
/** center_body is the principal class **/
#center_body {
position:relative;
height: auto !important;
width:958px;
margin-left:auto;
margin-right:auto;
overflow:auto;
height: auto !important;
min-height:600px;
}
/** input **/
#center_body input {
border: solid #bcbcbc;
border-width:1px;
height:20px;
border-radius:5px;
background: #eeeeee;
}
#center_body input:hover {
background: #fafafa;
}
#center_body input[type="submit"]
{
font-family: verdana,arial,sans;
font-size:12px;
height:25px;
border-radius:25px;
background: #eee;
}
#center_body input:hover[type="submit"]
{
background: #fff;
}
#center_body textarea {
border: solid #bcbcbc;
border-width:1px;
border-radius:5px;
}
#center_body select {
border: solid #bcbcbc;
border-width:1px;
border-radius:5px;
}
/* header elements classes */
#header
{
width:952px;
border:solid #000000;
border-width:0px;
border-right-width:0px;
padding-left:5px;
color: #676767;
text-align:middle;
height:120px;
margin-bottom:4px;
line-height: 35px;
}
#header a
{
color: #555555;
}
#logo_img
{
position:absolute;
top:20px;
left:0px;
}
#your_account
{
position:absolute;
top:25px;
right:5px;
background-image: url('../images/my-account.png');
background-repeat: no-repeat;
background-position:left;
padding-left:25px;
}
#cart
{
position:absolute;
top:50px;
right:5px;
background-image: url('../images/cart.gif');
background-repeat: no-repeat;
background-position:left;
padding-left:25px;
font-size:12px;
}
#change_currency
{
position:absolute;
top:70px;
right:5px;
background-image: url('../images/currency.gif');
background-repeat: no-repeat;
background-position:left;
padding-left:25px;
font-size:12px;
}
/* Languages styles in header. */
#languages
{
position:absolute;
margin: 0px 0px 0px 0px;
top:10px;
right:5px;
/*right:50px;*/
}
a.no_choose_flag
{
filter: Alpha(opacity=50);
-moz-opacity: .5;
opacity: .5;
}
a.choose_flag
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
}
a:hover.no_choose_flag
{
filter: Alpha(opacity=100);
-moz-opacity: 100;
opacity: 100;
}
#menu_barr
{
height:40px;
background-image:url('../images/background_barr.png');
background-repeat: repeat-x;
border:solid #cbcbcb;
border-width:1px;
border-radius:8px;
text-align:center;
font-size:16px;
line-height:40px;
margin-bottom:18px;
}
#menu_barr a
{
font-size:16px;
}
/* Menus in left and right sides... */
#menu
{
width:175px;
/*border:solid #ffffff;
border-width:5px;*/
margin:0px 0px 5px 0px;
padding:0px;
}
#menu a
{
font-size:14px;
font-family:verdana, verdana;
text-decoration:none;
color: #3434cc;
font-weight:bold;
padding:5px;
}
#menu a:hover
{
font-size:14px;
font-family:verdana, verdana;
text-decoration:underline;
color: #4545dd;
padding:5px;
}
.title_block
{
font-size:20px;
font-weight:normal;
font-family:verdana;
text-decoration:none;
color: #fff;
background-image:url('../images/block_bg.png');
background-repeat:repeat-x;
background-position:bottom;
background-color:#4e8df6;
border:solid #256753;
border-width:1px;
padding:8px 4px 0px 8px;
margin:0px;
position:relative;
height:40px;
border-radius: 8px 8px 0px 0px;
}
.url_block
{
font-size:12px;
font-family:verdana;
text-decoration:none;
color: #676767;
border:solid #cbcbcb;
border-width:0px 1px 0px 1px;
padding:8px 4px 8px 4px;
margin:0px;
position:relative;
}
.static_block
{
font-size:12px;
font-family:verdana;
text-decoration:none;
color: #676767;
/*background-image:url('../images/block_bg_link.png');*/
border:solid #cbcbcb;
border-width:0px 1px 0px 1px;
padding:4px;
margin:0px;
position:relative;
}
.block_end
{
background-image:url('../images/block_end.png');
height:15px;
border:solid #cbcbcb;
border-width:0px 1px 1px 1px;
border-radius:0px 0px 5px 5px;
margin-bottom:5px;
}
.link_menu a
{
color:#ff0000;
}
.menu_left
{
float:left;
}
.menu_right
{
float:right;
}
/* styles in content */
#content
{
display:block;
padding:0px 5px 0px 5px;
font-size:12px;
font-family:verdana, verdana;
text-decoration:none;
color: #676767;
margin-top:0px;
overflow:auto;
position:relative;
font-weight:lighter;
}
.content
{
overflow:auto;
position:relative;
}
.content_all
{
width:598px;
float:left;
}
.content_right
{
width:772px;
float:left;
}
.title
{
font-size:18px;
font-weight:bold;
font-family:verdana, verdana;
text-decoration:none;
color: #232323;
border:solid #cbcbcb;
border-width:1px;
padding:10px;
margin-bottom:5px;
background-color:#1ca34f;
background-image:url('../images/background_barr.png');
background-repeat:repeat-x;
border-radius:8px;
text-shadow: 1px 1px 2px rgba(150, 150, 150, 1);
}
.cont {
border:solid #dbdbdb;
border-width:1px 1px 1px 1px;
padding:10px 20px 10px 20px;
margin-bottom:5px;
position:relative;
/*text-align:justify;*/
overflow:hidden;
height:100%;
}
#inform {
margin:auto;
}
#options {
position:absolute;
top:50px;
left:600px;
}
/*Styles for common templates...*/
.form label {
display: block;
width: 150px;
float: left;
margin-bottom: 10px;
text-align: left;
width: 300px;
padding-right: 20px;
}
.form textarea {
width:100%;
height:150px;
clear:both;
}
.form p {
clear: left;
}
.panel {
}
.panel p {
text-align:center;
}
.panel img {
display:block;
margin-left:auto;
margin-right:auto;
}
/* Table list config */
.table_list {
border:solid #cbcbcb;
border-width:1px;
width:100%;
clear:left;
border-radius:8px;
}
.head_list
{
/*width:100%;*/
margin:4px;
display:block;
position:relative;
float:left;
/*border:solid #ffffff;
border-width:1px;*/
width:60%;
}
.head_list_right
{
/*width:100%;*/
margin:4px;
display:block;
position:relative;
/*clear:left;*/
float:right;
/*border:solid #ffffff;
border-width:1px;*/
width:35%;
bottom:0px;
text-align:right;
}
.title_list
{
width:100%;
position:relative;
/*border:solid #ffffff;
border-width:1px 1px 1px 1px;*/
}
.title_list td
{
font-size:14px;
font-weight:bold;
font-family:verdana, verdana;
text-decoration:none;
color: #fff;
border:solid #cbcbcb;
border-width:1px 1px 1px 1px;
padding:5px 5px 5px 5px;
margin:4px;
margin-bottom:5px;
background-color:#d75a09;
background-repeat:repeat-x;
text-align:center;
border-radius:8px;
}
.row_list
{
width:100%;
position:relative;
/*border:solid #ffffff;
border-width:1px 1px 1px 1px;*/
}
.row_list td
{
font-size:12px;
font-weight:bold;
font-family:verdana, verdana;
text-decoration:none;
color: #676767;
border:solid #ffffff;
border-width:1px 1px 1px 1px;
padding:5px 5px 5px 5px;
margin:4px;
margin-bottom:5px;
text-align:center;
/*background-color:#d75a09;
background-image:url('../images/fondo_titulo.png');
background-repeat:repeat-x;*/
/*float:left;*/
}
/* styles in private messages */
.new_message
{
display:block;
width:60px;
height:30px;
float:left;
padding:0px;
/*border:solid #ffffff;
border-width:1px;*/
background-image:url('../images/new_message.png');
background-repeat:no-repeat;
background-position:center;
}
.message
{
display:block;
width:60px;
height:30px;
float:left;
padding:0px;
/*border:solid #ffffff;
border-width:1px;*/
background-image:url('../images/message.png');
background-repeat:no-repeat;
background-position:center;
}
.error
{
color: #ff0000;
font-weight:bold;
}
#footer
{
height:100px;
border: solid #bcbcbc;
border-width:1px;
border-radius:8px;
margin-bottom:15px;
text-align:center;
line-height:100px;
position:relative;
font-size:12px;
font-family:verdana;
color:#555555;
background-image:url('../images/background_foot.png');
background-repeat:repeat-x;
background-position:bottom;
background-color: #fff;
}
/*Products style*/
.product
{
display:block;
position:relative;
height:100%;
margin-bottom:10px;
}
.title_product
{
border:solid #ffffff;
border-width:1px 0px 0px 0px;
font-size:15px;
font-weight:bold;
display:block;
/*clear:right;*/
margin-bottom:4px;
/*border:solid #ffffff;
border-width:1px;*/
}
.image_list_prod
{
border:solid #ffffff;
border-width:1px;
float:left;
position:relative;
padding:0px;
}
.description_product
{
float:left;
padding:20px;
}
.img_desc
{
border:solid #ffffff;
border-width:1px;
margin-left:30px;
margin-right:30px;
}
.desc_product
{
border:solid #ffffff;
border-width:0px 0px 1px 0px;
overflow:auto;
height:100%;
padding-bottom:5px;
}
a.ship {
display: block;
border: solid #cbcbcb;
border-width:1px;
border-radius:5px;
background-image:url('../images/background_barr.png');
background-position:bottom center;
background-repeat:repeat-x;
text-align:center;
min-width:100px;
min-height: 28px;
float:left;
line-height:28px;
padding:5px;
color: #868686;
}
a.ship:hover {
/*background-position: -87px 0px;*/
}
a.see {
display: block;
min-width: 126px;
min-height: 28px;
border: solid #cbcbcb;
border-width:1px;
border-radius:5px;
background-image:url('../images/background_barr.png');
background-position:bottom center;
background-repeat:repeat-x;
line-height:28px;
text-align:center;
float:left;
margin-right:2px;
padding:5px;
color: #868686;
}
.see_products {
display: block;
min-width: 126px;
min-height: 28px;
border: solid #cbcbcb;
border-width:1px;
border-radius:5px;
background-image:url('../images/background_barr.png');
background-position:bottom center;
background-repeat:repeat-x;
line-height:28px;
text-align:center;
/*border:solid #ffffff;
border-width:1px 1px 1px 1px;*/
float:left;
margin-right:2px;
padding:5px;
color: #868686;
}
#show_process_buying
{
position:absolute;
}
/*view big image css*/
#show_big_images
{
display:none;
position:fixed;
width:100%;
height:100%;
z-index:150;
background-color: #000;
}
#center_frame_image
{
position:absolute;
width:100%;
height:100%;
z-index:151;
}
#frame_image
{
display:none;
width:300px;
height:300px;
border: solid #ffffff;
border-width:4px;
border-radius:10px;
margin-left:auto;
margin-right:auto;
margin-top:20px;
position:relative;
z-index:151;
background-image:url('../images/loading_image_black.gif');
background-position:center;
background-repeat: no-repeat;
background-color: #000;
overflow:visible;
}
#icon_close_frame_image
{
position:absolute;
background-image:url('../images/close_black.png');
background-position:center;
background-repeat: no-repeat;
width:30px;
height:30px;
display:block;
z-index:152;
color:#fff;
right:0px;
}
.units
{
width:40px;
text-align:center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

5
modules/admin/media/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long