def _(): # don't polute globals() tbl = db.define_table( 'desk', Field('name', 'string', length=100), Field('item_list', 'list:reference item', default=[])) tbl.name.label = T('Name') tbl.item_list.readable = False # add a callback to remove items on delete def __desk_callback_item(s): item = s.select().first() desks_with_item = db(db.desk.item_list.contains(item.id)).select() for d in desks_with_item: d.item_list.remove(item.id) d.update_record() return False db.item._before_delete.insert(0, __desk_callback_item) tbl = db.define_table( 'organization', Field('name', 'string', length=100), Field('description', 'text'), Field('users', 'list:reference auth_user', default=[]), Field('desks', 'list:reference desk', default=[])) tbl.name.label = T('Name') tbl.description.label = T('Description') tbl.users.label = T('Users')
def _(): # don't polute globals() tbl = db.define_table( 'desk', Field('name', 'string', length=100), Field('item_list', 'list:reference item', default=[]) ) tbl.name.label = T('Name') tbl.item_list.readable = False # add a callback to remove items on delete def __desk_callback_item(s): item = s.select().first() desks_with_item = db(db.desk.item_list.contains(item.id)).select() for d in desks_with_item: d.item_list.remove(item.id) d.update_record() return False db.item._before_delete.insert(0, __desk_callback_item) tbl = db.define_table( 'organization', Field('name', 'string', length=100), Field('description', 'text'), Field('users', 'list:reference auth_user', default=[]), Field('desks', 'list:reference desk', default=[]) ) tbl.name.label = T('Name') tbl.description.label = T('Description') tbl.users.label = T('Users')
def _(): plugins = PluginManager("picture", app=None) # this will register the content/type on the application if plugins.picture.app is not None: editor = CKEditor(db=db) plugins.picture.app.registerContentType("picture", ContentPicture()) if not hasattr(db, "plugin_picture_rendition"): tbl = db.define_table( "plugin_picture_rendition", Field("picture", "upload", uploadseparate=True, autodelete=True), Field("purpose", "string", length=50, default="raw"), Field("height", "integer", default=0, readable=False, writable=False), Field("width", "integer", default=0, readable=False, writable=False), Field("color", "string", length=20, readable=False, writable=False), Field("format", "string", length=10, readable=False, writable=False), ) tbl.purpose.comment = T( """ It may contain any value but it is recommended to use one of the values: raw, web, thumbnail, print """ ) tbl.purpose.label = T("Purpose") tbl.height.label = T("Height") tbl.width.label = T("Width") tbl.color.label = T("Color space") tbl.format.label = T("Format") tbl.format.comment = T("Automatic form PIL") tbl.picture.label = T("Picture") tbl.picture.requires = [IS_IMAGE(), IS_NOT_EMPTY()] if not hasattr(db, "plugin_picture_info"): # definimos la BD tbl = db.define_table( "plugin_picture_info", Field("credit_line", "string", length=250, default=""), Field("description", "text", label=T("Description"), default=""), Field("caption", "string", length=250, default=""), Field("thumbnail", "upload", uploadseparate=True, autodelete=True, default=None), Field("renditions", "list:reference plugin_picture_rendition"), Field("item_id", "string", length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T("Description") tbl.description.widget = editor.widget tbl.caption.label = T("Caption") tbl.renditions.label = T("Renditions") tbl.item_id.readable = False tbl.item_id.writable = False # enable record versioning tbl._enable_record_versioning() return
def _(): plugins = PluginManager('photoset', app=None) if plugins.photoset.app is not None: plugins.photoset.app.registerContentType('photoset', ContentPhotoset()) editor = CKEditor(db=db) if not hasattr(db, 'plugin_photoset_photo'): db.define_table( 'plugin_photoset_photo', Field( 'thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None ), Field( 'picture', 'upload', uploadseparate=True, autodelete=True ), ) if not hasattr(db, 'plugin_photoset_content'): tbl = db.define_table( 'plugin_photoset_content', Field('credit_line', 'string', length=250, default=''), Field( 'description', 'text', label=T('Description'), default='' ), Field('photoset', 'list:reference plugin_photoset_photo'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add callback for item cleanup on delete. def __plugin_photoset_item_on_delete(s): item = s.select().first() if item.item_type == 'photoset': # cleanup here cnt = db.plugin_photoset_content(item_id=item.unique_id) db( db.plugin_photoset_photo.id.belongs( cnt.photoset)).delete() db( db.plugin_photoset_content.item_id == item.unique_id ).delete() return False # remember to procced db.item._before_delete.insert(0, __plugin_photoset_item_on_delete)
def _(): plugins = PluginManager('photoset', app=None) if plugins.photoset.app is not None: plugins.photoset.app.registerContentType('photoset', ContentPhotoset()) editor = CKEditor(db=db) if not hasattr(db, 'plugin_photoset_photo'): db.define_table( 'plugin_photoset_photo', Field('thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None), Field('picture', 'upload', uploadseparate=True, autodelete=True), ) if not hasattr(db, 'plugin_photoset_content'): tbl = db.define_table( 'plugin_photoset_content', Field('credit_line', 'string', length=250, default=''), Field('description', 'text', label=T('Description'), default=''), Field('photoset', 'list:reference plugin_photoset_photo'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add callback for item cleanup on delete. def __plugin_photoset_item_on_delete(s): item = s.select().first() if item.item_type == 'photoset': # cleanup here cnt = db.plugin_photoset_content(item_id=item.unique_id) db(db.plugin_photoset_photo.id.belongs( cnt.photoset)).delete() db(db.plugin_photoset_content.item_id == item.unique_id).delete() return False # remember to procced db.item._before_delete.insert(0, __plugin_photoset_item_on_delete)
def _(): plugins = PluginManager('text', app=None) if plugins.text.app is not None: # this will register the content/type on the application plugins.text.app.registerContentType('text', ContentText()) if not hasattr(db, 'plugin_text_text'): # configure ckeditor editor = CKEditor(db=db) # definimos la BD tbl = db.define_table( 'plugin_text_text', Field('byline', 'string', length=250, default=''), Field('body', 'text', label=T('Content'), default=''), Field('item_id', 'string', length=64), auth.signature, ) tbl.byline.label = T('By line') tbl.item_id.readable = False tbl.item_id.writable = False tbl.body.requires = IS_NOT_EMPTY() tbl.body.widget = editor.widget # enable record versioning tbl._enable_record_versioning() return
def _(): plugins = PluginManager('text', app=None) if plugins.text.app is not None: # this will register the content/type on the application plugins.text.app.registerContentType('text', ContentText()) if not hasattr(db, 'plugin_text_text'): # configure ckeditor editor = CKEditor(db=db) # definimos la BD tbl = db.define_table( 'plugin_text_text', Field('byline', 'string', length=250, default=''), Field('body', 'text', label=T('Content')), Field('item_id', 'string', length=64), auth.signature, ) tbl.byline.label = T('By line') tbl.item_id.readable = False tbl.item_id.writable = False tbl.body.requires = IS_NOT_EMPTY() tbl.body.widget = editor.widget # enable record versioning tbl._enable_record_versioning() return
def _(): plugins = PluginManager("text", app=None) if plugins.text.app is not None: # this will register the content/type on the application plugins.text.app.registerContentType("text", ContentText()) if not hasattr(db, "plugin_text_text"): # configure ckeditor editor = CKEditor(db=db) # definimos la BD tbl = db.define_table( "plugin_text_text", Field("byline", "string", length=250, default=""), Field("body", "text", label=T("Content")), Field("item_id", "string", length=64), auth.signature, ) tbl.byline.label = T("By line") tbl.item_id.readable = False tbl.item_id.writable = False tbl.body.requires = IS_NOT_EMPTY() tbl.body.widget = editor.widget # enable record versioning tbl._enable_record_versioning() return
def _(): # don't polute globals() tbl = db.define_table( 'desk', Field('name', 'string', length=100), Field('item_list', 'list:reference item', default=[]) ) tbl.name.label = T('Name') tbl.item_list.readable = False tbl = db.define_table( 'organization', Field('name', 'string', length=100), Field('description', 'text'), Field('users', 'list:reference auth_user', default=[]), Field('desks', 'list:reference desk', default=[]) ) tbl.name.label = T('Name') tbl.description.label = T('Description') tbl.users.label = T('Users')
def _(): tbl = db.define_table( 'plugin_comment_comment', Field('body', 'text', label=T('Your comment')), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.readable = False tbl.item_id.writable = False tbl.body.requires = IS_NOT_EMPTY() return lambda item_id: LOAD( 'plugin_comment', 'index.load', args=[item_id], ajax=True)
def _(): plugins = PluginManager('photoset', app=None) if plugins.photoset.app is not None: plugins.photoset.app.registerContentType('photoset', ContentPhotoset()) editor = CKEditor(db=db) if not hasattr(db, 'plugin_photoset_photo'): db.define_table( 'plugin_photoset_photo', Field( 'thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None ), Field( 'picture', 'upload', uploadseparate=True, autodelete=True ), ) if not hasattr(db, 'plugin_photoset_content'): tbl = db.define_table( 'plugin_photoset_content', Field('credit_line', 'string', length=250, default=''), Field( 'description', 'text', label=T('Description'), default='' ), Field('photoset', 'list:reference plugin_photoset_photo'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning()
def _(): tbl = db.define_table('notification', Field('subject', 'string', length=500), Field('message_content', 'text'), Field('from_user', 'reference auth_user'), Field('to_user', 'reference auth_user'), Field('seen', 'boolean', default=False), Field('msg_date', 'datetime', default=request.now)) tbl.subject.label = T('Subject') tbl.message_content.label = T('Message') tbl.from_user.label = T('From') tbl.msg_date.label = T('Date and Time') tbl.seen.label = T('Seen') tbl.to_user.readable = False tbl.id.readable = False
def _(): tbl = db.define_table( 'notification', Field('subject', 'string', length=500), Field('message_content', 'text'), Field('from_user', 'reference auth_user'), Field('to_user', 'reference auth_user'), Field('seen', 'boolean', default=False), Field('msg_date', 'datetime', default=request.now) ) tbl.subject.label = T('Subject') tbl.message_content.label = T('Message') tbl.from_user.label = T('From') tbl.msg_date.label = T('Date and Time') tbl.seen.label = T('Seen') tbl.to_user.readable = False tbl.id.readable = False
def _(): plugins = PluginManager('package', app=None) if plugins.package.app is not None: # this will register the the application on content/type plugins.package.app.registerContentType('package', ContentPackage()) if not hasattr(db, 'plugin_package_content'): editor = CKEditor(db=db) tbl = db.define_table( 'plugin_package_content', Field('item_list', 'list:string'), Field('description', 'text'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.writable = False tbl.item_id.readable = False tbl.item_list.writable = False tbl.item_list.readable = False tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning()
def _(): plugins = PluginManager('package', app=None) if plugins.package.app is not None: # this will register the the application on content/type plugins.package.app.registerContentType('package', ContentPackage()) if not hasattr(db, 'plugin_package_content'): editor = CKEditor(db=db) tbl = db.define_table( 'plugin_package_content', Field('item_list', 'list:string'), Field('description', 'text'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.writable = False tbl.item_id.readable = False tbl.item_list.writable = False tbl.item_list.readable = False tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add a callback to the item table for updating the item list of # the package on item deletion. def plugin_package_callback(s): item = s.select().first() # this are the packages with contains the item to delete pkgs = db( db.plugin_package_content.item_list.contains( item.unique_id) ).select() for pkg in pkgs: # remove the item from the package pkg.item_list.remove(item.unique_id) pkg.update_record() return False db.item._before_delete.insert(0, plugin_package_callback)
def _(): plugins = PluginManager('package', app=None) if plugins.package.app is not None: # this will register the the application on content/type plugins.package.app.registerContentType('package', ContentPackage()) if not hasattr(db, 'plugin_package_content'): editor = CKEditor(db=db) tbl = db.define_table( 'plugin_package_content', Field('item_list', 'list:string'), Field('description', 'text'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.writable = False tbl.item_id.readable = False tbl.item_list.writable = False tbl.item_list.readable = False tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add a callback to the item table for updating the item list of # the package on item deletion. def plugin_package_callback(s): item = s.select().first() # this are the packages with contains the item to delete pkgs = db( db.plugin_package_content.item_list.contains( item.unique_id)).select() for pkg in pkgs: # remove the item from the package pkg.item_list.remove(item.unique_id) pkg.update_record() return False db.item._before_delete.insert(0, plugin_package_callback)
def _(): plugins = PluginManager('picture', app=None) # this will register the content/type on the application if plugins.picture.app is not None: editor = CKEditor(db=db) plugins.picture.app.registerContentType('picture', ContentPicture()) if not hasattr(db, 'plugin_picture_rendition'): tbl = db.define_table( 'plugin_picture_rendition', Field('picture', 'upload', uploadseparate=True, autodelete=True), Field('purpose', 'string', length=50, default='raw'), Field('height', 'integer', default=0, readable=False, writable=False), Field('width', 'integer', default=0, readable=False, writable=False), Field('color', 'string', length=20, readable=False, writable=False), Field('format', 'string', length=10, readable=False, writable=False)) tbl.purpose.comment = T(''' It may contain any value but it is recommended to use one of the values: raw, web, thumbnail, print ''') tbl.purpose.label = T('Purpose') tbl.height.label = T('Height') tbl.width.label = T('Width') tbl.color.label = T('Color space') tbl.format.label = T('Format') tbl.format.comment = T('Automatic form PIL') tbl.picture.label = T('Picture') tbl.picture.requires = [IS_IMAGE(), IS_NOT_EMPTY()] if not hasattr(db, 'plugin_picture_info'): # definimos la BD tbl = db.define_table( 'plugin_picture_info', Field('credit_line', 'string', length=250, default=''), Field('description', 'text', label=T('Description'), default=''), Field('caption', 'string', length=250, default=''), Field('thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None), Field('renditions', 'list:reference plugin_picture_rendition'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl.caption.label = T("Caption") tbl.renditions.label = T("Renditions") tbl.item_id.readable = False tbl.item_id.writable = False # enable record versioning tbl._enable_record_versioning() return
db.define_table( 'item', # content metadata Field('headline', 'string', length=512, default=''), Field('slugline', 'string', length=512, default=''), Field('keywords', 'list:string', default=''), Field('located', 'string', length=200, default=''), Field('genre', 'string', length=100, default=''), Field('section_page', 'string', length=100, default=''), # language of the item it self not the lenguage of the content Field( 'language_tag', 'string', default=T.accepted_language.split('-')[0], length=2), # item metadata Field('provider', 'string', length=100, default=''), Field('provider_service', 'string', default=''), Field('pubstatus', 'string', length=10, default='usable'), Field('embargoed', 'datetime', default=None), auth.signature, # copyright info. Field('copyright_holder', 'string', length=100, default=''), Field('copyright_url', 'string', length=512, default=''), Field('copyright_notice', 'text', default=''), # the item_type will be of use for searching the actions asociate with a # item in CONTENT_TYPE_REG, it should not be readed or writed by users # and should be writen only one, in the creation of the item. Field('item_type', 'string', length='100', default='text'), Field( 'unique_id', 'string', length=64, default=uuid.uuid4(), writable=False, readable=False ), )
def _(): plugins = PluginManager('picture', app=None) # this will register the content/type on the application if plugins.picture.app is not None: editor = CKEditor(db=db) plugins.picture.app.registerContentType('picture', ContentPicture()) if not hasattr(db, 'plugin_picture_rendition'): tbl = db.define_table( 'plugin_picture_rendition', Field( 'picture', 'upload', uploadseparate=True, autodelete=True ), Field('purpose', 'string', length=50, default='web'), Field( 'height', 'integer', default=0, readable=False, writable=False ), Field( 'width', 'integer', default=0, readable=False, writable=False ), Field( 'color', 'string', length=20, readable=False, writable=False ), Field( 'format', 'string', length=10, readable=False, writable=False ), Field( 'thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None ), ) tbl.purpose.comment = T(''' It may contain any value but it is recommended to use one of the values: raw, web, thumbnail, print ''') tbl.purpose.label = T('Purpose') tbl.height.label = T('Height') tbl.width.label = T('Width') tbl.color.label = T('Color space') tbl.format.label = T('Format') tbl.format.comment = T('Automatic form PIL') tbl.picture.label = T('Picture') tbl.picture.requires = [IS_IMAGE(), IS_NOT_EMPTY()] if not hasattr(db, 'plugin_picture_info'): # definimos la BD tbl = db.define_table( 'plugin_picture_info', Field('credit_line', 'string', length=250, default=''), Field( 'description', 'text', label=T('Description'), default='' ), Field( 'caption', 'string', length=250, default='' ), Field('renditions', 'list:reference plugin_picture_rendition'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl.caption.label = T("Caption") tbl.renditions.label = T("Renditions") tbl.item_id.readable = False tbl.item_id.writable = False # enable record versioning tbl._enable_record_versioning() # add callback for item cleanup on delete. def __plugin_picture_item_on_delete(s): item = s.select().first() if item.item_type == 'picture': # cleanup here cnt = db.plugin_picture_info(item_id=item.unique_id) db( db.plugin_picture_rendition.id.belongs( cnt.renditions)).delete() db( db.plugin_picture_info.item_id == item.unique_id ).delete() return False # remember to procced db.item._before_delete.insert(0, __plugin_picture_item_on_delete) return
# -*- coding: utf-8 -*- import datetime from collections import defaultdict # for ide if False: from gluon import Field, auth from gluon.validators import IS_IN_SET from db import db from fuente_datos import marcadas_tunel_latix from util import datetime_sp dias_semana = ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado'] db.define_table('marcadas', Field('id_reg'), Field('user_code'), Field('datetime'), Field('bkp_type'), Field('type_code'), Field('huella', unique=True, length=40)) db.define_table( 'empleado', Field('nombre', length=255), Field('apellido', length=255), Field('user_code', 'integer', unique=True, length=4), Field('dias'), Field('entrada', 'time'), Field('salida', 'time'), Field('descanso', 'time'), auth.signature, format='%(Nombre)s %(Apellido)', ) db.empleado.dias.requires = IS_IN_SET(dias_semana, multiple=True)