Added first files
This commit is contained in:
commit
d325960160
12 changed files with 510 additions and 0 deletions
0
admin/__init__.py
Normal file
0
admin/__init__.py
Normal file
77
admin/pages.py
Normal file
77
admin/pages.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import os
|
||||
from paramecio2.libraries.generate_admin_class import GenerateAdminClass
|
||||
#from paramecio2.libraries.db.adminutils import make_admin_url
|
||||
#from paramecio.citoplasma.urls import make_url
|
||||
from paramecio2.libraries.i18n import I18n
|
||||
from settings import config
|
||||
from modules.pages2.models import pages
|
||||
|
||||
from paramecio2.libraries.db.coreforms import BaseForm
|
||||
from paramecio2.modules.admin import admin_app, t as admin_t
|
||||
from flask import url_for, g
|
||||
from paramecio2.libraries.mtemplates import env_theme, PTemplate
|
||||
|
||||
env=env_theme(__file__)
|
||||
|
||||
t=PTemplate(env)
|
||||
|
||||
t.env.directories=admin_t.env.directories
|
||||
|
||||
t.env.directories.insert(1, os.path.dirname(__file__).replace('/admin', '')+'/templates/admin')
|
||||
|
||||
@admin_app.route('/admin/pages2/', methods=['GET', 'POST'])
|
||||
def admin_pages2():
|
||||
|
||||
#t=admin_t
|
||||
|
||||
conn=g.connection
|
||||
|
||||
page=pages.Page2(conn)
|
||||
|
||||
page.enctype=True
|
||||
|
||||
page.fields['slugify'].name_form=BaseForm
|
||||
|
||||
page.fields['text'].name_form=TextEditorJsForm
|
||||
|
||||
#page.fields['text'].extra_parameters[0].t=t
|
||||
|
||||
#url=make_admin_url('pages')
|
||||
url=url_for('admin_app.admin_pages2')
|
||||
|
||||
admin=GenerateAdminClass(page, url, t)
|
||||
|
||||
admin.list.fields_showed=['id', 'title', 'slugify']
|
||||
|
||||
form_admin=admin.show()
|
||||
|
||||
#return admin.show()
|
||||
if type(form_admin).__name__=='str':
|
||||
|
||||
return t.load_template('content.phtml', title=I18n.lang('pages', 'pages', 'Pages'), contents=form_admin, path_module='admin_app.admin_pages2')
|
||||
else:
|
||||
|
||||
return form_admin
|
||||
|
||||
class TextEditorJsForm(BaseForm):
|
||||
"""Form for html texts, based in tinycme javascript library"""
|
||||
|
||||
def __init__(self, name, value, t_add=None):
|
||||
"""
|
||||
Args:
|
||||
name (str): The html name for this form
|
||||
value (str): The default value of this html form.
|
||||
t_add (PTemplate): If you want change the standard html form, use other template loader
|
||||
"""
|
||||
|
||||
super().__init__(name, value)
|
||||
|
||||
self.t=t_add
|
||||
|
||||
if t_add==None:
|
||||
self.t=t
|
||||
|
||||
def form(self):
|
||||
|
||||
return self.t.load_template('editorjsform.phtml', form=self)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue