def test_checkbox_field(self): """ Test for L{modu.editable.datatypes.boolean.CheckboxField} """ test_itemdef = define.itemdef( selected = boolean.CheckboxField( label = 'Selected', attributes = dict(basic_element=False), ) ) req = self.get_request() test_storable = storable.Storable('test') test_storable.selected = 1 itemdef_form = test_itemdef.get_form(req, test_storable) reference_form = form.FormNode('test-form') reference_form['selected'](type='checkbox', label='Selected', checked=True) reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes={'onClick':"return confirm('Are you sure you want to delete this record?');"}) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_select_field(self): """ Test for L{modu.editable.datatypes.select.SelectField} """ options = {'admin':'Administrator', 'user':'******'} test_itemdef = define.itemdef( user_type = select.SelectField( label = 'Type', options = options, attributes = dict(basic_element=False), ) ) req = self.get_request() test_storable = storable.Storable('test') test_storable.user_type = 'user' itemdef_form = test_itemdef.get_form(req, test_storable) #options = {'admin':'Administrator', 'user':'******'} reference_form = form.FormNode('test-form') reference_form['user_type'](type='select', label='Type', value='user', options=options) reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes={'onClick':"return confirm('Are you sure you want to delete this record?');"}) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_foreign_labelfield(self): """ Test for L{modu.editable.datatypes.relational.ForeignLabelField} """ test_itemdef = define.itemdef( category_id = relational.ForeignLabelField( label = 'Category', ftable = 'category', fvalue = 'code', flabel = 'title', attributes = dict(basic_element=False), ) ) req = self.get_request() req.store.ensure_factory('page') test_storable = storable.Storable('page') test_storable.set_factory(req.store.get_factory('page')) test_storable.title = "My Title" test_storable.category_id = 'bio' itemdef_form = test_itemdef.get_form(req, test_storable) reference_form = form.FormNode('page-form') reference_form['category_id'](type='label', label='Category', value='Biography') reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes={'onClick':"return confirm('Are you sure you want to delete this record?');"}) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_stringfield_listing(self): """ Test for L{modu.editable.datatypes.string.StringField} as displayed in a generated form. """ test_itemdef = define.itemdef( name = string.StringField( label = 'Name', listing = True, attributes = dict(basic_element=False), ) ) req = self.get_request() test_storable = storable.Storable('test') test_storable.name = 'Test Name' itemdef_form = test_itemdef.get_listing(req, [test_storable])[0] reference_form = form.FormNode('test-row') reference_form['name'](type='label', label='Name', value='Test Name') itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_linked_labelfield(self): """ Test for L{modu.editable.datatypes.string.LabelField}. ...and any other datatype that could support a link prefix/suffix """ test_itemdef = define.itemdef( # Normally base_path is set by the admin resource __config = dict( base_path = '/admin' ), linked_name = string.LabelField( label = 'Name', link = True, listing = True, attributes = dict(basic_element=False), ) ) req = self.get_request() test_storable = storable.Storable('test') test_storable.linked_name = 'Linked Name' itemdef_form = test_itemdef.get_listing(req, [test_storable]) reference_form = form.FormNode('test-row') reference_form['linked_name'](type='label', label='Name', value='Linked Name', prefix=tags.a(href='http://____store-test-domain____:1234567/app-test/detail/test/0', __no_close=True), suffix='</a>') itemdef_form_html = itemdef_form[0].render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_password_field_noencrypt(self): """ Test for L{modu.editable.datatypes.string.PasswordField} without encryption. """ post_data = [('page-form[title][entry]', 'Text Before Encryption'), ('page-form[title][verify]','Text Before Encryption'), ('page-form[save]','save')] test_itemdef = define.itemdef( title = string.PasswordField( label = 'Encrypted Title', encrypt = False, attributes = dict(basic_element=False), ) ) req = self.get_request(post_data) req.store.ensure_factory('page') test_storable = storable.Storable('page') test_storable.title = "My Title" test_storable.category_id = 3 test_storable.content = 'Sample content' test_storable.code = 'my-title' itemdef_form = test_itemdef.get_form(req, test_storable) itemdef_form.execute(req) self.failUnless(test_storable.get_id(), 'Storable was not saved.') self.failIfEqual(test_storable.title, "My Title", "Title field wasn't overwritten by password datatype") self.failUnlessEqual(test_storable.title, "Text Before Encryption", "Title field wasn't encrypted by password datatype")
def test_checkbox_field_listing(self): """ Test for L{modu.editable.datatypes.boolean.CheckboxField} as displayed in a generated form. """ test_itemdef = define.itemdef( selected = boolean.CheckboxField( label = 'Selected', listing = True, attributes = dict(basic_element=False), ) ) req = self.get_request() test_storable = storable.Storable('test') test_storable.selected = 1 itemdef_form = test_itemdef.get_listing(req, [test_storable])[0] reference_form = form.FormNode('test-row') reference_form['selected'](type='checkbox', label='Selected', checked=True, disabled=True) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_validation(self): """ Test validation and prewrite callbacks in itemdefs. """ self.validation_test_bool = False self.prewrite_callback_bool = False def test_validator(req, form, storable): self.validation_test_bool = True return True def test_prewrite(req, form, storable): self.prewrite_callback_bool = True return True test_itemdef = define.itemdef( __config = dict( prewrite_callback = test_prewrite ), title = string.StringField( label = 'Title', validator = test_validator ) ) form_data = [('page-form[title]','Sample Title'), ('page-form[save]','save')] req = self.get_request(form_data) req.store.ensure_factory('page') test_storable = storable.Storable('page') test_storable.title = "My Title" test_storable.code = 'my-title' test_storable.category_id = 3 test_storable.content = 'My Content' test_storable.modified_date = int(time.time()) test_storable.created_date = int(time.time()) itemdef_form = test_itemdef.get_form(req, test_storable) itemdef_form.execute(req) self.failUnless(self.validation_test_bool, "Validation function didn't run") self.failUnless(self.prewrite_callback_bool, "Pre-write callback function didn't run") def test_failed_prewrite(req, form, storable): return False test_itemdef.config['prewrite_callback'] = test_failed_prewrite itemdef_form = test_itemdef.get_form(req, test_storable) try: itemdef_form.execute(req) except RuntimeError, e: self.fail("Submit callback ran despite pre-write failure")
def test_foreign_autocomplete_field(self): """ Test for L{modu.editable.datatypes.relational.ForeignAutocompleteField} """ test_itemdef = define.itemdef( name = relational.ForeignAutocompleteField( label = 'Name', fvalue = 'id', flabel = 'title', ftable = 'category', attributes = dict(basic_element=False), ) ) req = self.get_request() req.store.ensure_factory('test') test_storable = storable.Storable('test') test_storable.set_factory(req.store.get_factory('test')) test_storable.name = 'Test Name' itemdef_form = test_itemdef.get_form(req, test_storable) reference_form = form.FormNode('test-form') reference_form['name'](type='fieldset', style='brief', label='Name') reference_form['name']['name-autocomplete'](type='textfield', weight=0, attributes={'id':'test-form-name-autocomplete'}) reference_form['name']['ac-support'](type="markup", weight=1, value=tags.script(type='text/javascript') [("""$("#test-form-name-autocomplete").autocomplete("http://____store-test-domain____:1234567/app-test/autocomplete/test/name", { autoFill:1, selectFirst:1, matchSubset:0, selectOnly:1, formatItem:formatItem, extraParams:{t:%s}, minChars:3});""" + '$("#test-form-name-autocomplete").result(select_item_handler("test-form-name-ac-callback"));') % int(time.time())]) reference_form['name']['name'](type='hidden', weight=2, value=0, attributes={'id':'test-form-name-ac-callback'}) reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes={'onClick':"return confirm('Are you sure you want to delete this record?');"}) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
def test_submit(self): """ Test submission, saving, and postwrite callbacks in itemdefs. """ def postwrite_callback(req, form, storable): raise RuntimeError('postwrite') test_itemdef = define.itemdef( __config = dict( postwrite_callback = postwrite_callback ), title = string.StringField( label = 'Title' ), bogus = string.StringField( label = 'Title', implicit_save = False ) ) form_data = [('page-form[title]','Sample Title'), ('page-form[save]','save')] req = self.get_request(form_data) req.store.ensure_factory('page') test_storable = storable.Storable('page') test_storable.title = "My Title" test_storable.code = 'my-title' test_storable.category_id = 3 test_storable.content = 'My Content' test_storable.modified_date = int(time.time()) test_storable.created_date = int(time.time()) itemdef_form = test_itemdef.get_form(req, test_storable) self.failUnlessRaises(RuntimeError, itemdef_form.execute, req) self.failUnless(test_storable.get_id(), 'Storable was not saved.') self.failUnlessEqual(test_storable.title, 'Sample Title', 'Storable field `title` was not saved.')
def test_foreign_select_field(self): """ Test for L{modu.editable.datatypes.relational.ForeignSelectField} """ options = {1:'Drama', 2:'Science Fiction', 3:'Biography', 4:'Horror', 5:'Science', 6:'Historical Fiction', 7:'Self-Help', 8:'Romance', 9:'Business', 10:'Technical', 11:'Engineering', 12:'Lanugage', 13:'Finance', 14:'Young Readers', 15:'Music', 16:'Dance', 17:'Psychology', 18:'Astronomy', 19:'Physics', 20:'Politics'} test_itemdef = define.itemdef( category_id = relational.ForeignSelectField( label = 'Category', ftable = 'category', fvalue = 'id', flabel = 'title', attributes = dict(basic_element=False), ) ) req = self.get_request() req.store.ensure_factory('page') test_storable = storable.Storable('page') test_storable.set_factory(req.store.get_factory('page')) test_storable.title = "My Title" test_storable.category_id = 3 test_storable.content = 'Sample content' test_storable.code = 'my-title' itemdef_form = test_itemdef.get_form(req, test_storable) reference_form = form.FormNode('page-form') reference_form['category_id'](type='select', label='Category', value=3, options=options) reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes={'onClick':"return confirm('Are you sure you want to delete this record?');"}) itemdef_form_html = itemdef_form.render(req) reference_form_html = reference_form.render(req) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) )
# modusite # Copyright (c) 2006-2010 Phil Christensen # http://modu.bubblehouse.org # # from modu import util from modu.editable import define from modu.editable.datatypes import string, boolean, fck, select __itemdef__ = define.itemdef( __config=dict(name="page", label="pages", acl="access admin", category="site content", weight=1), id=string.LabelField(label="id:", weight=-10, listing=True), title=string.StringField(label="title:", size=60, maxlength=255, weight=1, listing=True, link=True, search=True), url_code=string.StringField( label="url code:", size=40, maxlength=255, help="the url code for this page's permalink", weight=3, listing=True ), data=string.TextAreaField(label="page body:", weight=4), # data = string.TextAreaField( # label = 'page body:', # rows = 20, # cols = 80, # weight = 4 # ), # active=boolean.CheckboxField(label="active:", weight=4), )
__itemdef__ = define.itemdef( __config = dict( name = 'page', label = 'pages', acl = 'access admin', category = 'site content', weight = 1 ), id = string.LabelField( label = 'id:', weight = -10, listing = True ), title = string.StringField( label = 'title:', size = 60, maxlength = 255, weight = 1, listing = True, link = True, search = True ), url_code = string.StringField( label = 'url code:', size = 40, maxlength = 255, help = "the url code for this page's permalink", weight = 3, listing = True ), data = fck.FCKEditorField( label = 'page body:', weight = 4 ), active = boolean.CheckboxField( label = 'active:', weight = 4 ) )
__itemdef__ = define.itemdef( __config = dict( name = 'address', label = 'addresses', acl = 'access admin', category ='relationships', weight = 2, model_class = address.Address, hidden = True, ), address_for = editable.ItemTitleField( column = 'item_id', label = 'Address for:', flabel = 'name', weight = -4, listing = True ), type = select.SelectField( label = 'type:', options = address.ADDRESS_TYPES, weight = 1, search = True, listing = True, ), name = string.StringField( label = 'name:', size = 60, maxlength = 255, weight = 2, listing = True, link = True, search = True, ), address1 = string.StringField( label = 'address 1:', size = 60, maxlength = 255, weight = 3, listing = True, link = True, ), address2 = string.StringField( label = 'address 2:', size = 60, maxlength = 255, weight = 4, ), city = string.StringField( label = 'city:', size = 60, maxlength = 255, weight = 5, listing = True, ), region = select.SelectField( label = 'state:', options = gigkeeper.states, weight = 6, listing = True, ), zip = string.StringField( label = 'zip:', size = 60, maxlength = 255, weight = 7, listing = True, ), country = select.SelectField( label = 'country:', options = gigkeeper.countries, default_value = 'US', weight = 8, ), item_id = string.HiddenField( weight = 100, ), item_table = string.HiddenField( weight = 101, ), )
__itemdef__ = define.itemdef( __config = dict( name = 'media', acl = 'access admin', weight = 100, model_class = media.Media, prewrite_callback = media_prewrite_callback, hidden = True, ), id = string.LabelField( label = 'id:', help = 'the internal id of this item.', weight = -10, listing = True, ), item_title = editable.ItemTitleField( column = 'item_id', label = 'media for:', flabel = 'name', listing = True, weight = 2, ), filename = fck.FCKFileField( label = 'filename:', fck_root = '/fck/content', listing = True, link = True, weight = 3, ), created_date = date.CurrentDateField( label = 'created date:', style = 'datetime', save_format = 'datetime', default_checked = True, weight = 5, ), item_table = string.LabelValueField( label = 'from table:', listing = True, weight = 6, ), type = string.LabelField( label = 'media type:', listing = True, weight = 6.5, help = 'This field will be updated on save', ), format = string.LabelField( label = 'media format:', weight = 7, help = 'This field will be updated on save', ), quality = string.LabelField( label = 'media quality:', weight = 8, help = 'This field will be updated on save', ), filesize = string.LabelField( label = 'file size:', weight = 9, help = 'This field will be updated on save', ), md5 = string.LabelField( label = 'checksum:', weight = 10, help = 'This field will be updated on save', ), )
__itemdef__ = define.itemdef( __config = dict( name = 'note', label = 'notes', acl = 'access admin', category ='relationships', weight = 2, model_class = note.Note, hidden = True, ), note_for = editable.ItemTitleField( column = 'item_id', label = 'Note for:', flabel = 'name', weight = -4, listing = True ), type = select.SelectField( label = 'type:', options = note.NOTE_TYPES, weight = 1, search = True, listing = True, ), summary = string.StringField( label = 'summary:', size = 60, maxlength = 255, weight = 2, listing = True, link = True, search = True, ), description = fck.FCKEditorField( label = 'description:', rows = 8, cols = 70, weight = 3, ), created_date = date.CurrentDateField( label = 'created date:', save_format = 'datetime', default_checked = True, weight = 3.5, ), item_id = string.HiddenField( weight = 100, ), item_table = string.HiddenField( weight = 101, ), )
__itemdef__ = define.itemdef( __config = dict( name = 'history', label = 'event log', acl = 'access admin', category = 'relationships', weight = 2, model_class = history.History, hidden = True, prewrite_callback = history_prewrite_callback, ), history_for = editable.ItemTitleField( column = 'item_id', label = 'History for:', flabel = 'name', weight = 1, listing = True ), user_id = relational.ForeignLabelField( label = 'created by:', ftable = 'user', flabel = 'username', fvalue = 'id', weight = 2, ), contact_id = relational.ForeignAutocompleteField( label = 'contact:', ftable = 'contact', flabel = 'name', fvalue = 'id', weight = 3, autocomplete_callback = editable.contact_autocomplete_callback, ), type = select.SelectField( label = 'type:', options = history.HISTORY_TYPES, weight = 4, search = True, listing = True, required = True, ), summary = string.StringField( label = 'summary:', size = 60, maxlength = 255, weight = 5, listing = True, link = True, search = True, ), description = string.TextAreaField( label = 'description:', rows = 8, cols = 70, weight = 6, ), created_date = date.CurrentDateField( label = 'created date:', save_format = 'datetime', default_checked = True, weight = 7, ), item_id = string.HiddenField( weight = 100, ), item_table = string.HiddenField( weight = 101, ), )
def test_date_field(self): """ Test for L{modu.editable.datatypes.date.DateField} """ from modu.editable.datatypes import date as date_datatype test_itemdef = define.itemdef( start_date = date_datatype.DateField( label = 'start date:', save_format = 'datetime', attributes = dict(basic_element=False), ) ) req = self.get_request([('test-form[start_date][date][month]',8), ('test-form[start_date][date][day]',25), ('test-form[start_date][date][year]',2007), ('test-form[start_date][date][hour]',23), ('test-form[start_date][date][minute]',40) ]) test_storable = storable.Storable('test') # +---------------------------+ # | from_unixtime(1190864400) | # +---------------------------+ # | 2007-09-26 23:40:00 | # +---------------------------+ test_storable.start_date = datetime.datetime.fromtimestamp(1190864400) self.failUnlessEqual(test_storable.start_date.year, 2007, 'Test year was calculated incorrectly as %s' % test_storable.start_date.year) months, days = date.get_date_arrays() hours, minutes = date.get_time_arrays() itemdef_form = test_itemdef.get_form(req, test_storable) reference_form = form.FormNode('test-form') reference_form['start_date'](type='fieldset', style='brief', label='start date:') reference_form['start_date']['null'](type='checkbox', text="no value", weight=-1, suffix=tags.br(), attributes=dict(onChange='enableDateField(this);')) reference_form['start_date']['date'](type='fieldset') reference_form['start_date']['date']['month'](type='select', weight=0, options=months, value=8) reference_form['start_date']['date']['day'](type='select', weight=1, options=days, value=25) reference_form['start_date']['date']['year'](type='textfield', weight=2, size=5, value=2007) reference_form['start_date']['date']['hour'](type='select', weight=3, options=hours, value=23) reference_form['start_date']['date']['minute'](type='select', weight=4, options=minutes, value=40) reference_form['start_date']( suffix = tags.script(type="text/javascript")[""" enableDateField($('#form-item-start_date input')); """], ) reference_form['save'](type='submit', value='save', weight=1000) reference_form['cancel'](type='submit', value='cancel', weight=1001) reference_form['delete'](type='submit', value='delete', weight=1002, attributes=dict(onClick="return confirm('Are you sure you want to delete this record?');")) itemdef_form_html = str(itemdef_form.render(req)) reference_form_html = str(reference_form.render(req)) for i in range(len(itemdef_form_html)): if(reference_form_html[i] != itemdef_form_html[i]): self.fail('Expecting %s (%s) but found %s (%s) at position %d' % ( reference_form_html[i], reference_form_html[i-20:i+20], itemdef_form_html[i], itemdef_form_html[i-20:i+20], i )) self.failUnlessEqual(itemdef_form_html, reference_form_html, "Didn't get expected form output, got:\n%s\n instead of:\n%s" % (itemdef_form_html, reference_form_html) ) test_storable.start_date = datetime.datetime.now() # this just loads the data, since there was # no submit button in the test post data itemdef_form.execute(req) test_itemdef['start_date'].update_storable(req, itemdef_form, test_storable) self.failUnlessEqual(test_storable.start_date, datetime.datetime.fromtimestamp(1190864400), 'Date was calculated incorrectly as %s' % test_storable.start_date)
# # $Id$ # from modu import util from modu.editable import define from modu.editable.datatypes import string, boolean, fck, select from gigkeeper import editable from gigkeeper.model import url __itemdef__ = define.itemdef( __config=dict( name="url", label="URLs", acl="access admin", category="relationships", weight=2, model_class=url.URL, title_column="url", hidden=True, ), url_for=editable.ItemTitleField(column="item_id", label="URL for:", flabel="name", weight=-4, listing=True), type=select.SelectField( label="type:", options=url.URL_TYPES, default_value=url.URL_TYPES.keys()[0], weight=1, search=True, listing=True ), url=string.StringField(label="url:", size=60, maxlength=255, weight=2, listing=True, link=True, search=True), item_id=string.HiddenField(weight=100), item_table=string.HiddenField(weight=101), )
# See LICENSE for details from modu.editable import define from modu.editable.datatypes import string, relational __itemdef__ = define.itemdef( __config = dict( name = 'permission', label = 'permissions', category = 'accounts', acl = 'access admin', weight = 2 ), id = string.LabelField( label = 'id:', size = 10, weight = -10, listing = True ), name = string.StringField( label = 'name:', size = 60, maxlength = 255, weight = 1, listing = True, link = True ) )
__itemdef__ = define.itemdef( # The configuration dict __config = dict( # [r] A unique identifier for this itemdef, usually the table name name = 'page', # [o] If the identifier is not the table name, it must be set here table = '[default:<name>]', # [o] The display name of this itemdef label = '[default:<name>]', # [o] The itemdef category category = "[default:'other']", # [o] The position of this itemdef in relation to others in its category weight = 5, # [o] The required user permission to use this itemdef acl = '[default:'']', # [o] Alternate usage specifying multiple required permissions acl = ['access pages', 'access admin'], # [o] This is called during validation. If it returns false, # validation will fail. prewrite_callback = pre_post_write_callback, # [o] Called during submit, after writing the storable. postwrite_callback = pre_post_write_callback, # [o] This is called during validation. If it returns false, # validation will fail. predelete_callback = pre_post_delete_callback, # [o] Called during submit, after writing the storable. postdelete_callback = pre_post_delete_callback, # [o] Overrides the default theme class for form generation. theme = theme.Theme, # [o] Factory to use to build Storable objects factory = storable.DefaultFactory, # [o] Model class to use with DefaultFactory model_class = storable.Storable, # [o] Overrides the default list template. list_template = "[default:'admin-listing.tmpl.html']", # [o] Overrides the default detail template. detail_template = "[default:'admin-detail.tmpl.html']", # [o] A dict of name-value pairs returned from this function # will be added to the template template_variable_callback = template_variable_callback, # [o] The name of a result column that should be used as the title # of a record title_column = 'title', # [o] Don't allow anyone to create a new item. no_create = False, # [o] The number of results to show per listing page. per_page = 25, # [o] The title to be displayed on listing pages. listing_title = "[default:'Listing <Name> Records']", # [o] When using the export feature, this function will be called to generate the query export_query_builder = export_query_builder # [o] Export type (may be 'csv' or 'tsv' export_type = 'csv',
# phylo # Copyright (C) 2010 phylo # # $Id$ # from modu.editable import define from modu.editable.datatypes import string, relational __itemdef__ = define.itemdef( __config=dict(name="permission", label="permissions", category="accounts", acl="access admin", weight=2), id=string.LabelField(label="id:", size=10, weight=-10, listing=True), name=string.StringField(label="name:", size=60, maxlength=255, weight=1, listing=True, link=True), )
__itemdef__ = define.itemdef( __config = dict( name = 'faq', label = 'FAQs', acl = 'access admin', category = 'site content', prewrite_callback = update_answered_by, weight = 1 ), id = string.LabelField( label = 'id:', weight = -10, listing = True ), question = string.TextAreaField( label = 'question:', weight = 1, listing = True, link = True, search = True ), answer = string.TextAreaField( label = 'answer:', weight = 5 ), answered_by = relational.ForeignSelectField( label = 'answered by:', fvalue = 'id', flabel = 'username', ftable = 'user', help = 'This field is filled/updated automatically when the record is saved.', weight = 6 ), answered_date = date.DateField( label = 'answered date:', style = 'date', default_now = True, save_format = 'datetime', weight = 7 ), weight = string.StringField( label = 'weight:', size = 5, weight = 8, attributes = dict(value=0) ) )
__itemdef__ = define.itemdef( __config = dict( name = 'release', label = 'releases', acl = 'access admin', category = 'site content', model_class = release.Release, prewrite_callback = release_prewrite_callback, weight = 4, ), id = string.LabelField( label = 'id:', weight = -10, listing = True, ), project_id = relational.ForeignSelectField( label = 'related project:', ftable = 'project', fvalue = 'id', flabel = 'name', weight = 1, listing = True, ), version_weight = string.StringField( label = 'version weight:', size = 5, weight = 2, listing = True, help = 'The release version will be sorted by this string.', ), version_string = string.StringField( label = 'version string:', size = 10, weight = 3, listing = True, help = 'This is the version info that is actually displayed', ), filename = fck.FCKFileField( label = 'filename:', fck_root = '/fck/releases', listing = True, link = True, weight = 4, ), release_date = date.DateField( label = 'release date:', listing = True, weight = 4.5, default_now = True, save_format = 'datetime', ), tarball_url = string.StringField( label = 'tarball url:', weight = 5, ), tarball_checksum = string.StringField( label = 'tarball checksum:', weight = 6, ), description = string.TextAreaField( label = 'page body:', weight = 7, ), nightly = boolean.CheckboxField( label = 'nightly:', weight = 7.5, default_checked = False, ), active = boolean.CheckboxField( label = 'active:', weight = 8, default_checked = True, ), license_name = string.StringField( label = 'license name:', weight = 9, listing = True, ), license_url = string.StringField( label = 'license url:', weight = 10, ), installation_url = string.StringField( label = 'installation url:', weight = 11, ), changelog_url = string.StringField( label = 'changelog url:', weight = 12, ), )
__itemdef__ = define.itemdef( __config = dict( name = 'project', label = 'projects', acl = 'access admin', category = 'site content', weight = 2 ), id = string.LabelField( label = 'id:', weight = -10, listing = True ), name = string.StringField( label = 'name:', size = 60, maxlength = 255, weight = 1, listing = True, link = True, search = True ), shortname = string.StringField( label = 'shortname:', size = 60, maxlength = 255, weight = 1.5, listing = True, ), releases = project.ReleaseListField( label = 'releases:', weight = 1.75, listing = True, ), license_name = string.StringField( label = 'license name:', weight = 2, listing = True, ), license_url = string.StringField( label = 'license url:', weight = 3, ), installation_url = string.StringField( label = 'installation url:', weight = 4, ), changelog_url = string.StringField( label = 'changelog url:', weight = 5, ), active = boolean.CheckboxField( label = 'active:', weight = 8, listing = True, ) )
__itemdef__ = define.itemdef( __config = dict( name = 'company', label = 'companies', acl = 'access admin', category ='relationships', weight = 2, model_class = company.Company, title_column = 'name', ), type = select.SelectField( label = 'type:', options = company.COMPANY_TYPES, search = True, listing = True, weight = 1, required = True, ), name = string.StringField( label = 'name:', size = 60, maxlength = 255, weight = 2, listing = True, link = True, search = True, required = True, ), phone = string.StringField( label = 'phone:', size = 60, maxlength = 255, weight = 2, listing = True, ), contacts = contact.CompanyContactListField( label = 'Contacts:', weight = 2.1, ), history = history.GenericHistoryListField( label = 'History:', weight = 2.2, ), event_history = history.EventHistoryListField( label = 'Event History:', weight = 2.3, ), addresses = address.AddressListField( label = 'Addresses:', weight = 2.5, address_name_callback = address_name_callback, ), urls = url.URLListField( label = 'URLs:', weight = 3, ), notes = note.NoteListField( label = 'notes:', weight = 4, ), )
__itemdef__ = define.itemdef( __config = dict( name = 'user', label = 'users', category = 'accounts', acl = 'access admin', weight = 0 ), id = string.LabelField( label = 'id:', size = 10, weight = -10, listing = True ), username = string.StringField( label = 'username:'******'first:', size = 60, maxlength = 255, weight = 2, listing = True ), last = string.StringField( label = 'last:', size = 60, maxlength = 255, weight = 3, listing = True ), crypt = string.PasswordField( label = 'password:'******'roles:', fvalue = 'id', flabel = 'name', ftable = 'role', ntof = 'user_role', ntof_f_id = 'role_id', ntof_n_id = 'user_id' ) )
__itemdef__ = define.itemdef( __config = dict( name = 'blog', label = 'blog entries', acl = 'access admin', category = 'site content', prewrite_callback = [update_published_by, util.get_url_code_callback('title', 'url_code')], weight = 1 ), id = string.LabelField( label = 'id:', weight = -10, listing = True ), title = string.StringField( label = 'title:', size = 60, maxlength = 255, weight = 1, listing = True, link = True, search = True ), url_code = string.StringField( label = 'url code:', size = 60, maxlength = 255, weight = 1.5, ), category_code = string.StringField( label = 'category:', size = 60, maxlength = 255, weight = 2, listing = True, link = True, search = True ), teaser = fck.FCKEditorField( label = 'teaser:', weight = 4, height = 150, toolbar_set = 'Basic' ), body = fck.FCKEditorField( label = 'page body:', weight = 5 ), published_by = relational.ForeignSelectField( label = 'author:', fvalue = 'id', flabel = 'username', ftable = 'user', help = 'This field is filled/updated automatically when the record is saved.', weight = 6 ), published_date = date.DateField( label = 'published date:', style = 'datetime', default_now = True, save_format = 'datetime', weight = 7 ), active = boolean.CheckboxField( label = 'active:', weight = 8 ) )
__itemdef__ = define.itemdef( __config = dict( name = 'role', label = 'roles', category = 'accounts', acl = 'access admin', weight = 1 ), id = string.LabelField( label = 'id:', size = 10, weight = -10, listing = True ), name = string.StringField( label = 'name:', size = 60, maxlength = 255, weight = 1, listing = True, link = True ), permissions = relational.ForeignMultipleSelectField( label = 'permissions:', fvalue = 'id', flabel = 'name', ftable = 'permission', ntof = 'role_permission', ntof_f_id = 'permission_id', ntof_n_id = 'role_id' ) )
# gigkeeper # Copyright (C) 2008 gigkeeper # # $Id$ # from modu.editable import define from modu.editable.datatypes import string, relational __itemdef__ = define.itemdef( __config=dict(name="role", label="roles", category="accounts", acl="access admin", weight=1), id=string.LabelField(label="id:", size=10, weight=-10, listing=True), name=string.StringField(label="name:", size=60, maxlength=255, weight=1, listing=True, link=True), permissions=relational.ForeignMultipleSelectField( label="permissions:", fvalue="id", flabel="name", ftable="permission", ntof="role_permission", ntof_f_id="permission_id", ntof_n_id="role_id", ), )