Beispiel #1
0
__author__ = 'Evolutiva'
from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)
ckeditor.define_tables()

##tabla caso
db.define_table('caso',
                Field('depiction', 'upload', label=T('Logotipo')),
                Field('name', 'string', label=T('Nombre')),
                Field('description',
                      'text',
                      label=T('Reseña'),
                      widget=ckeditor.widget),
                Field('country',
                      db.country,
                      label=T('País'),
                      requires=IS_IN_DB(db, 'country.id', 'country.name'),
                      default=44),
                Field('city', 'string', label=T('Ciudad')),
                Field('documentSource',
                      'list:reference document',
                      required=False,
                      requires=IS_IN_DB(requiere,
                                        'document.id',
                                        '%(name)s / (documentURL)s',
                                        multiple=True),
                      label=T('Fuentes')),
                Field('documentCloud',
                      'list:reference documentCloud',
                      required=False,
                      requires=IS_IN_DB(db,
Beispiel #2
0
from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)
ckeditor.define_tables()

UCS = ['UC Berkeley', 'UC Davis', 'UC Irvine', 'UC Los Angeles', 'UC Merced', 'UC Riverside', 'UC San Diego', 'UC Santa Barbara', 'UC Santa Cruz']


# This is a table called 'category' which defines a bunch of names for categories. We use this table to make
# categories such as Student Life, Sports, and Events. You won't be able to create a category that already
# exists. It can also not contain special characters (IS_SLUG). The URL cannot be lowercase.
db.define_table('category',
                Field('name', requires=(IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB(db, 'category.name'))))

# This table called 'post' is responsible for defining what a post is. A post will belong to a specific
# category and it will reference that category. The category field for the post can't be readable or
# writable because we want the users to be able to make a post in a given category such as Student Life,
# Sports, or Events, but we don't want them to be able to change the name of that category. A post will
# also need to have a title and a body of text. We don't want either of these to be empty. If one or more
# of those fields is empty, the form will throw an error. A post will also have a number of votes. Users
# cannot see these votes when they are viewing a post and we don't want them to be able to edit the number
# of votes. Since we are also adding in an auth.signature, we are adding in 5 more fields that hold
# references to the logged in user who posted the specific post. These fields include created_by, modified_by,
# created_on, modified_on, and is_active. We do not use is_active.
db.define_table('post',
                Field('category', 'reference category', writable=False, readable=False),
                Field('title', 'string', length=45, requires=[IS_NOT_EMPTY(), IS_LENGTH(45)]),
                Field('body', 'text', widget=ckeditor.widget, requires=IS_NOT_EMPTY()),
                Field('votes', 'integer', default=0, writable=False, readable=False),
                Field('uc', label="UC", default='[All]',
                       requires=IS_IN_SET(['[All]']+UCS)),
                Field('image', 'upload', autodelete=True,
Beispiel #3
0
# Turn on captcha for registration
if int(myconf.take('recaptcha.use')):
    auth.settings.captcha = Recaptcha2(request,
                                       myconf.take('recaptcha.site_key'),
                                       myconf.take('recaptcha.secret_key'))

# -----------------------------------------------------------------------------
# IMPORT the CKEDITOR PLUGIN TO GIVE A WYSIWYG EDITOR FOR BLOGS AND NEWS
# -- OK, so this editor is neat but one issue is that it dumps files into the
#    root of uploads, which is messy
# -- Ordinarily, this would be controlled by the upload_folder setting but
#    this is hardcoded in the module. Could edit it there but you can also use
#    a fs object to provide a folder
# -- You'd think it might be possible to have multiple upload folders but
#    it turns out to be quite hard to switch the settings
# -----------------------------------------------------------------------------

ckeditor = CKEditor(db)

app_root = request.folder
app_root_fs = OSFS(app_root)

if not app_root_fs.exists('uploads/news_and_blogs/'):
    blog_fs = app_root_fs.makeopendir('uploads/news_and_blogs/')
else:
    blog_fs = app_root_fs.opendir('uploads/news_and_blogs/')

ckeditor.settings.uploadfs = blog_fs
ckeditor.settings.table_upload_name = 'ckeditor_uploads'
ckeditor.define_tables(fake_migrate=True)