DateTime("dob"), Boolean("active"), Address("supporter_address"), OneToMany("email","email", order_by = "email", eager = True), OneToMany("donkey_sponsorship", "donkey_sponsorship", many_side_not_null = False ), summary_fields = "name,address_line_1,postcode" ) table("email",d, Email("email") ) entity("user",d, Text("name"), Text("password"), primary_key = "name", table_type = "system" ) table("user_group",d, Text("groupname"),
def initialise(application): sysinfo = application.predefine.sysinfo sysinfo("public", True, "Allow unregistered users to use the application") sysinfo("name", 'Reformed Application', "Name of the application") database = application.database table('search_info', database, Integer('_core_id'), Integer('table'), Integer('field'), Integer('original_id'), Text('value', length = 1000), Index('main_query', "_core_id, table, field, original_id"), modified_date = False, modified_by = False, version = False, ) table('search_pending', database, Integer('_core_id'), Created('created'), modified_date = False, modified_by = False, version = False, ) info_table('summary_info', database, Text('table_name'), Text('name'), Text('display_name'), Integer('original_id'), Text('value', length = 1000)) info_table('note', database, Text('note', length = 1000), ) entity('people', database, Text('name', generator = dict(name = 'full_name')), Text('preferred_name'), Text('alterative_name'), Text('salutation'), LookupId('gender', "code", filter_field = "code_type"), LookupId('source'), Date('dob', generator = dict(name = 'dob')), Created('created'), CreatedBy('created_by'), Thumb('image'), Event('new change', CopyValue('image', 'primary_entity._core_entity.thumb')), Event('new change delete', UpdateSearch(['name']) ), Event('new change delete', UpdateSearch(['dob'], "datetime") ), title_field = 'name', default_node = 'new_person.People', valid_info_tables = "communication summary_info note" ) table("source", database, Text("code", length = 200), Text("code_desc", length = 400), Created('created'), CreatedBy('created_by'), lookup = True, ) info_table('communication', database, Text('communication_type'), DateTime('defaulted_date'), Boolean('active', default = True), Text('description', length = 1000), Index('latest_com', "_core_id, defaulted_date, active"), Created('created'), CreatedBy('created_by'), ) table('telephone', database, Integer("_core_id", mandatory = True), ForeignKey('communication_id', 'communication'), Text('number', generator = dict(name = 'phone')), Event('new', AddCommunication()), Event('new change delete', UpdateCommunicationInfo(['number'])), Event('new change delete', UpdateSearch(['number'], type = 'only_numbers')), table_class = 'communication', ) table('email', database, Integer("_core_id", mandatory = True), ForeignKey('communication_id', 'communication'), Email('email', mandatory = True), Event('new', AddCommunication()), Event('new change delete', UpdateCommunicationInfo(['email'])), Event('new change delete', UpdateSearch(['email'])), table_class = 'communication', ) table('address', database, Integer("_core_id", mandatory = True), ForeignKey('communication_id', 'communication'), Text('address_line_1', generator = dict(name = 'road')), Text('address_line_2'), Text('address_line_3'), Text('address_line_4'), Text('town', generator = dict(name = 'town')), Text('country'), Text('postcode', generator = dict(name = 'postcode')), Boolean('gone_away'), Event('new', AddCommunication()), Event('new change delete', UpdateCommunicationInfo(['address_line_1', 'town', 'postcode'])), Event('new change delete', UpdateSearch(['postcode'], type = "upper_no_space")), table_class = 'communication', ) database.persist()
def initialise(application): database = application.database table("_core", database, Text("type"), ForeignKey("primary_entity_id", "_core_entity", ), ForeignKey("secondary_entity_id", "_core_entity", ), modified_by = False, modified_date = False ) table("_core_entity", database, Text("table"), Text("title"), Text("summary"), Integer("thumb"), ModifiedByNoRelation("modified_by"), table_type = "internal", summary = u'The entity table', lookup = True, modified_by = False ) entity("user",database, Text("name"), Boolean("active", default = True, mandatory = True), Boolean("locked", default = False), Text("login_name", mandatory = True), Text("auto_login", length = 100), Password("password"), Email("email"), DateTime("last_logged_in"), Text("notes", length = 4000), Text("about_me", length = 4000), Created("created_date"), CreatedBy("created_by"), UniqueIndex("login_name_index", "login_name"), title_field = 'name', table_type = "system", default_node = 'user.User', ) entity("user_group",database, Text("groupname"), Text("name", mandatory = True), Text("description", length = 200), Text("notes", length = 4000), Boolean("active", default = True, mandatory = True), Integer("access_level", default = 0), default_node = 'user.UserGroup', table_type = "system", title_field = 'name' ) table("user_group_user",database, LookupId("user_id", "user"), LookupId("user_group_id", "user_group"), table_type = "system" ) table("user_group_permission",database, ##TODO Sort out backref problems LookupId("user_group_id", "user_group"), LookupId("permission_id", "permission"), table_type = "system" ) table("permission",database, Text("permission"), Text("name", length = 200), Text("description", length = 4000), Integer("access_level", default = 0), table_type = "system", title_field = 'name' ) table("bookmarks",database, ForeignKey("_core_id", "_core_entity", ), Integer("user_id"), Text("entity_table"), DateTime("accessed_date"), table_type = "system", ) table("code", database, Text("name", mandatory = True), Text("desctiption", length = 2000), LookupTextValidated("code_type", "code_type.code_type"), Boolean("active", default = True), Created("created_date"), CreatedBy("created_by"), lookup = True, table_type = "system", title_field = "name" ) table("code_type", database, Text("code_type", mandatory = True), Text("name", mandatory = True), Text("desctiption", length = 2000), Created("created_date"), CreatedBy("created_by"), table_type = "system", ) ## application user tables entity("page",database, Text("page", length = 50, mandatory = True), Text("title", length = 200, mandatory = True), Text("body", length = 8000), default_node = 'search.Page', title_field = "title", table_type = "system", ) entity('upload', database, Text("filename", mandatory = True), Text("category"), Text("title"), Text("path"), Text("mimetype"), Integer("size"), Boolean("thumb", default = False), Created("created_date"), CreatedBy("created_by"), title_field = "filename", summary_fields = "filename", table_type = "system", ) database.persist() # permission # add admin user # this is a special case as no other users should be auto created data = dict(name = u"admin", created_by = 1, _modified_by = 1, active = True, auto_login = authenticate.create_auto_login_id(), password = u"admin") application.predefine.add_data("user", "login_name", u"admin", data) # sys admin user_group application.predefine.permission("SysAdmin", u'System Administrators', u'Administer the system.', 2) application.predefine.user_group(u'SysAdmins', u'System Administrators', u'Full system access', permissions = ['SysAdmin'], access_level = 2) # this is a special case too # make admin a sysadmin data = dict(created_by = 1, _modified_by = 1, user_id = 1, user_group_id = 1,) application.predefine.add_data("user_group_user", "user_id", 1, data)