diff --git a/calexium_lib b/calexium_lib index aef2e71..204b008 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit aef2e7132faffe8125687b30c6f9867ac3ea6e93 +Subproject commit 204b008703703918117e3e32e9f5b20785c99b12 diff --git a/src/generation/files.anubis b/src/generation/files.anubis index fb03b57..ec74902 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -18,11 +18,13 @@ read generation/types.anubis define Maybe(One) generate_table ( - DB_Table table + DB_Table org_table ) = - since table is db_table(name, model, display), - since model is db_model(columns, show_string), + since org_table is db_table(name, old_model, display), + since old_model is db_model(columns, show_string), + with model = db_model([db_column("id", p_key, []). columns], show_string ), + with table = db_table(name, model, display), println("Generating file for table ["+name+"]"); with file_name = name+".anubis", if file(file_name, new) is @@ -30,18 +32,19 @@ define Maybe(One) failure then println("can't create file "+file_name);failure, success(fd) then with strm = make_stream(fd), - if generate_header(strm, columns) is { failure then failure, success(_) then - if generate_type(strm, table) is { failure then failure, success(_) then - if generate_get_default(strm, table) is { failure then failure, success(_) then - if generate_extract_web_arg(strm, table) is { failure then failure, success(_) then - if generate_extract_db_cursor(strm, table) is { failure then failure, success(_) then - if generate_get_all(strm, table) is { failure then failure, success(_) then - if generate_get_one(strm, table) is { failure then failure, success(_) then - if generate_update(strm, table) is { failure then failure, success(_) then - if generate_show_string(strm, table) is { failure then failure, success(_) then - if generate_VT_view(strm, table) is { failure then failure, success(_) then - if generate_VT_edit(strm, table) is { failure then failure, success(_) then - success(unique)}}}}}}}}}}} + if generate_header(strm, columns) is { failure then failure, success(_) then + if generate_type(strm, table) is { failure then failure, success(_) then + if generate_get_default(strm, table) is { failure then failure, success(_) then + if generate_extract_web_arg(strm, table) is { failure then failure, success(_) then + if generate_extract_db_cursor(strm, table) is { failure then failure, success(_) then + if generate_get_all(strm, table) is { failure then failure, success(_) then + if generate_get_one(strm, table) is { failure then failure, success(_) then + if generate_update(strm, table) is { failure then failure, success(_) then + if generate_show_string(strm, table) is { failure then failure, success(_) then + if generate_selector(strm, table) is { failure then failure, success(_) then + if generate_VT_view(strm, table) is { failure then failure, success(_) then + if generate_VT_edit(strm, table) is { failure then failure, success(_) then + success(unique)}}}}}}}}}}}} }. define One diff --git a/src/generation/header.anubis b/src/generation/header.anubis index c679861..fef6f0b 100644 --- a/src/generation/header.anubis +++ b/src/generation/header.anubis @@ -61,6 +61,7 @@ read data_base/db_tools.anubis read calexium_lib/database/db_utils.anubis read calexium_lib/database/db_types.anubis read calexium_lib/database/vtm/view_table_types.anubis +read calexium_lib/database/model/db_model.anubis read system/logger.anubis read system/datetime.anubis diff --git a/src/generation/types.anubis b/src/generation/types.anubis index 2747f36..9bcc711 100644 --- a/src/generation/types.anubis +++ b/src/generation/types.anubis @@ -144,7 +144,7 @@ public define Maybe(One) //generate the type of the table that contain all components if write_string(stream, "\n\n"+ - "define Maybe("+type_name+")\n"+ + "public define Maybe("+type_name+")\n"+ " extract_"+name+"\n"+ " (\n"+ " One -> SQLite3Row table_cursor\n"+ @@ -175,7 +175,7 @@ public define Maybe(One) //generate the type of the table that contain all components if write_string(stream, "\n\n"+ - "define List("+type_name+")\n"+ + "public define List("+type_name+")\n"+ " _get_all_"+name+"\n"+ " (\n"+ " One -> SQLite3Row table_cursor,\n"+ @@ -193,7 +193,7 @@ public define Maybe(One) " (\n"+ " SQLite3DataBase db,\n"+ " )=\n"+ - " if sql_query_timeout(db, \"SELECT "+join(", ", components(columns, []))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ + " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",components(columns, [])) )+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ " {\n"+ " error(_) then [],\n"+ " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ @@ -225,7 +225,7 @@ public define Maybe(One) " SQLite3DataBase db,\n"+ " String idx\n"+ " )=\n"+ - " if sql_query_timeout(db, \"SELECT "+join(", ", components(columns, []))+" FROM "+name+" WHERE id=\"+idx+\";\", [], \"get_"+name+"\") is\n"+ + " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",components(columns, [])))+" FROM "+name+" WHERE id=\"+idx+\";\", [], \"get_"+name+"\") is\n"+ " {\n"+ " error(_) then failure,\n"+ " ok(_, cursor, _) then extract_"+name+"(cursor)\n"+ @@ -331,6 +331,48 @@ public define Maybe(One) failure then println("can't write generate_update "+type_name); failure, success(_) then success(unique) }. + +public define Maybe(One) + generate_selector + ( + Stream stream, + DB_Table table + )= + since table is db_table(name, model, _), + since model is db_model( columns, show_string), + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. + + //generate the type of the table that contain all components + if write_string(stream, + "\n\n"+ + "define List((List(CoreAttrs), WebArgValue, String))\n"+ + " _get_selector_"+name+"\n"+ + " (\n"+ + " SQLite3DataBase db,\n"+ + " List("+type_name+") list,\n"+ + " List((List(CoreAttrs), WebArgValue, String)) so_far\n"+ + " )=\n"+ + " if list is\n"+ + " {\n"+ + " [] then reverse(so_far),\n"+ + " [ h . t ] then \n"+ + " if h.id is \n"+ + " {\n"+ + " none then [],\n"+ + " db_id(id) then _get_selector_"+name+"(db, t, [([], wav(to_String(id)), get_"+name+"_show_string(db, id)) . so_far])\n"+ + " }\n"+ + " }.\n\n"+ + "public define List((List(CoreAttrs), WebArgValue, String))\n"+ + " get_selector_"+name+"\n"+ + " (\n"+ + " SQLite3DataBase db,\n"+ + " )=\n"+ + " _get_selector_"+name+"(db, get_all_"+name+"(db), [])." + ) is //end of the function + { + failure then println("can't write generate_show_string "+type_name); failure, + success(_) then success(unique) + }. public define Maybe(One) generate_VT_view @@ -338,8 +380,8 @@ public define Maybe(One) Stream stream, DB_Table table )= - since table is db_table(name, model, display), - since model is db_model( columns, _), + since table is db_table(name, model, display), + since model is db_model( columns, _), since display is db_display(list_view, list_edit), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. @@ -366,7 +408,7 @@ public define Maybe(One) " [ h . t ] then\n"+ " with entry = vt_view_row([\n"+ // view row - make_list_view_row(model, list_view, "h", " ")+"\n"+ + make_list_view_row(table, "h", " ")+"\n"+ " ]),\n"+ " _get_viewable_"+name+"(db, t, [entry . so_far])\n"+ " }.\n\n"+ diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis index e82b462..097e2eb 100644 --- a/src/model.3.0.0.anubis +++ b/src/model.3.0.0.anubis @@ -6,22 +6,22 @@ public define DB_Table mf_serial_table = db_table("mf_serial", db_model( [ - db_column("id", p_key, []), + db_column("serial", char_field(30), []), db_column("mac", char_field(30), []), db_column("app_id", char_field(50), []), - db_column("enabled",boolean_field, []), - db_column("free_domain",boolean_field, []), - db_column("max_domains",integer_field, []), - db_column("is_demo",boolean_field, []), - db_column("is_test",boolean_field, []), + db_column("enabled",boolean_field, [], help_text("Is enabled?")), + db_column("free_domain",boolean_field, [], help_text("Free domain available?")), + db_column("max_domains",integer_field, [], help_text("Maximum number of domains")), + db_column("is_demo",boolean_field, [], help_text("Is demo?")), + db_column("is_test", boolean_field, [], help_text("Is test?")), db_column("date_created", datetime_field(auto_now_add), []), db_column("last_updated", datetime_field(none), []), - db_column("last_ping", datetime_field(none), []), - db_column("current_ip", char_field(20), []), - db_column("mf_version", char_field(20), []), - db_column("vm_version", char_field(20), []), - db_column("os_version", char_field(20), []), + db_column("last_ping", datetime_field(none), []), + db_column("current_ip", char_field(20), []), + db_column("mf_version", char_field(20), [], help_text("MF version")), + db_column("vm_version", char_field(20), [], help_text_TAG("ANUBIS_VM_VER")), + db_column("os_version", char_field(20), [], help_text("OS version")), db_column("ipkg_list", text_field, []), db_column("ifconfig", text_field, []), db_column("dmesg", text_field, []), @@ -32,7 +32,7 @@ public define DB_Table mf_serial_table = db_column("isp_smtp", text_field, []), db_column("description", text_field, []), db_column("comments", text_field, []), - db_column("alert_received",boolean_field, []), + db_column("alert_received",boolean_field, [], help_text("Alert received?")), db_column("alert_date", datetime_field(none), []), db_column("alert_msg", text_field, []), db_column("alert_mf_version", char_field(20), []), @@ -41,7 +41,7 @@ public define DB_Table mf_serial_table = ), db_display( //list_view - ["id", "serial", "mf_version", "mac", "app_id", "is_demo", "is_test", "last_updated", "last_ping", "mf_version", ], + [ "serial", "mf_version", "mac", "app_id", "is_demo", "is_test", "last_updated", "last_ping", "mf_version", ], //list edit ["serial", "mac", "app_id", "enabled", "free_domain", "max_domains", "is_demo", "is_test", "date_created", "last_updated", "last_ping", "current_ip", "mf_version", "os_version", "ipkg_list", "ifconfig", "dmesg", "memory", "vm_memory", "status", "disks", "isp_smtp", "description", "comments", "alert_received", "alert_date", @@ -53,7 +53,7 @@ public define DB_Table settings_table = db_table("settings", db_model( [ - db_column("id", p_key, []), + db_column("var_name", char_field(20), []), db_column("var_value", char_field(20), []), ], @@ -61,7 +61,7 @@ public define DB_Table settings_table = ), db_display( //list_view - ["id", "var_name", "var_value"], + [ "var_name", "var_value"], //list edit ["var_name", "var_value"] ) @@ -71,22 +71,22 @@ public define DB_Table django_admin_log_table = db_table("django_admin_log", db_model( [ - db_column("id", p_key, []), - db_column("action_time", datetime_field(auto_now_add), []), + + db_column("action_time", datetime_field(auto_now_add), []), // db_column("user_id", foreign_key("auth_user"), [indexed]), // db_column("content_type_id", foreign_key("django_content_type"), [indexed]), - db_column("user_id", integer_field, []), - db_column("content_type_id", integer_field, []), - db_column("object_id", text_field, []), - db_column("object_repr", char_field(200), []), - db_column("action_flag", integer_field, []), - db_column("change_message", text_field, []), + db_column("user_id", integer_field, []), + db_column("content_type_id", integer_field, []), + db_column("object_id", text_field, []), + db_column("object_repr", char_field(200), []), + db_column("action_flag", integer_field, []), + db_column("change_message", text_field, []), ], "obj.object_repr" ), db_display( //list_view - ["id", "action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message" ], + [ "action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message" ], //list edit ["action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message"] ) @@ -96,7 +96,7 @@ public define DB_Table production_macaddress_table = db_table("production_macaddress", db_model( [ - db_column("id", p_key, []), + db_column("mac", char_field(20), []), db_column("index", integer_field, []), db_column("mailfountain_id", integer_field, []), @@ -105,51 +105,73 @@ public define DB_Table production_macaddress_table = ), db_display( //list_view - ["id", "mac", "index", "mailfountain_id"], + [ "mac", "index", "mailfountain_id"], //list edit ["mac", "index", "mailfountain_id"] ) ). - -public define DB_Table production_memory_type_table = - db_table("production_memory_type", + +public define DB_Table production_mass_storage_type_table = + db_table("production_mass_storage_type", db_model( [ - db_column("id", p_key, []), + db_column("type", char_field(20), []), ], "to_String(obj.id)+\":\"+obj.type" ), db_display( //list_view - ["id", "type"], + [ "type"], //list edit ["type"] ) ). + -public define DB_Table production_mass_storage_type_table = - db_table("production_mass_storage_type", + +public define DB_Table production_mass_storage_table = + db_table("production_mass_storage", db_model( [ - db_column("id", p_key, []), - db_column("type", char_field(20), []), + + db_column("purchase_id", foreign_key("production_purchase"), [indexed]), + db_column("model_id", foreign_key("production_mass_storage_model"), [indexed]), + db_column("serial", char_field(40), []), // + db_column("status", char_field(10), []), // + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep ], - "to_String(obj.id)+\":\"+obj.type" + "obj.serial" ), db_display( //list_view - ["id", "type"], - //list edit - ["type"] + ["model_id", "serial", "status", "date_created"], + //list_edit + ["purchase_id", "model_id", "serial", "status", "comments"] ) ). - + + "CREATE TABLE production_purchase ( + id integer NOT NULL PRIMARY KEY, + date date NOT NULL, + buyer_id integer NOT NULL REFERENCES staff_staff (id), + supplier_id integer NOT NULL REFERENCES production_supplier (id), + order_ref varchar(50) NOT NULL, + description varchar(200) NOT NULL, + date_created datetime NOT NULL, + last_modified datetime NOT NULL, + comments text NOT NULL + )" + + + public define DB_Table production_mass_storage_model_table = db_table("production_mass_storage_model", db_model( [ - db_column("id", p_key, []), + db_column("manufacturer", char_field(20), []), db_column("type_id", foreign_key("production_mass_storage_type"), [indexed]), db_column("capacity", integer_field, []), // @@ -162,52 +184,284 @@ public define DB_Table production_mass_storage_model_table = ), db_display( //list_view - ["id", "manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"], + [ "manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"], //list_edit [] ) ). + +public define DB_Table production_memory_table = + db_table("production_memory", + db_model( + [ + + db_column("purchase_id", foreign_key("production_purchase"), [indexed]), + db_column("model_id", foreign_key("production_memory_model"), [indexed]), + db_column("serial", char_field(40), []), // + db_column("status", char_field(10), []), // + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.serial" + ), + db_display( + //list_view + [ "serial", "status", "last_modified", "date_created"], + //list_edit + ["purchase_id", "model_id", "serial", "status", "last_modified", "date_created", "comments"] + ) + ). + +public define DB_Table production_memory_model_table = + db_table("production_memory_model", + db_model( + [ + + db_column("type_id", foreign_key("production_memory_type"), [indexed]), + db_column("manufacturer", char_field(20), []), // + db_column("capacity", integer_field, []) // + ], + "obj.manufacturer" + ), + db_display( + //list_view + [ "type_id", "manufacturer", "capacity"], + //list_edit + ["type_id", "manufacturer", "capacity"] + ) + ). -public define DB_Table production_mass_storage_table = - db_table("production_mass_storage", +public define DB_Table production_memory_type_table = + db_table("production_memory_type", db_model( [ - db_column("id", p_key, []), - db_column("purchase_id", foreign_key("production_purchase"), [indexed]), - db_column("model_id", foreign_key("production_mass_storage_model"), [indexed]), + + db_column("type", char_field(20), []), + ], + "to_String(obj.id)+\":\"+obj.type" + ), + db_display( + //list_view + [ "type"], + //list edit + ["type"] + ) + ). + +public define DB_Table production_motherboard_table = + db_table("production_motherboard", + db_model( + [ + + db_column("purchase_id", foreign_key("production_purchase"), [indexed]), + db_column("model_id", foreign_key("production_motherboard_model"), [indexed]), db_column("serial", char_field(40), []), // - db_column("status", char_field(10), []), // + db_column("week_fab", char_field(10), []), // + db_column("status", char_field(10), []), // db_column("date_created", datetime_field(auto_now_add), []), db_column("last_modified", datetime_field(auto_now), []), db_column("comments", text_field, []) // whatever the user wants to keep ], - "obj.purchase_id.string" + "obj.serial" ), db_display( //list_view - ["model_id", "serial", "status", "date_created"], + [ "serial", "week_fab", "status", "last_modified", "date_created"], //list_edit - ["purchase_id", "model_id", "serial", "status", "comments"] + ["purchase_id", "model_id", "serial", "week_fab", "status", "last_modified", "date_created", "comments"] ) ). - - "CREATE TABLE production_purchase ( - id integer NOT NULL PRIMARY KEY, - date date NOT NULL, - buyer_id integer NOT NULL REFERENCES staff_staff (id), - supplier_id integer NOT NULL REFERENCES production_supplier (id), - order_ref varchar(50) NOT NULL, - description varchar(200) NOT NULL, - date_created datetime NOT NULL, - last_modified datetime NOT NULL, - comments text NOT NULL - )" + +public define DB_Table production_motherboard_model_table = + db_table("production_motherboard_model", + db_model( + [ + + db_column("name", char_field(30), []), + db_column("manufacturer", char_field(20), []), + db_column("has_nand", boolean_field, []), + db_column("nand_capacity", integer_field, []), // + db_column("memory", integer_field, []), // + db_column("cpu_freq", integer_field, []), // + db_column("cpu_model", char_field(30), []), + db_column("endian", char_field(1), []) // whatever the user wants to keep + ], + "obj.name" + ), + db_display( + //list_view + ["name", "manufacturer", "cpu_model", "cpu_freq"], + //list_edit + ["name", "manufacturer", "has_nand", "nand_capacity", "memory", "cpu_freq", "cpu_model", "endian"] + ) + ). + +public define DB_Table production_power_supply_table = + db_table("production_power_supply", + db_model( + [ + + db_column("purchase_id", foreign_key("production_purchase"), [indexed]), + db_column("model_id", foreign_key("production_power_supply_model"), [indexed]), + db_column("serial", char_field(40), []), // + db_column("status", char_field(10), []), // + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.serial" + ), + db_display( + //list_view + [ "serial", "status", "date_created", "last_modified"], + //list_edit + ["purchase_id", "model_id", "serial", "status", "date_created", "last_modified", "comments"] + ) + ). + +public define DB_Table production_power_supply_model_table = + db_table("production_power_supply_model", + db_model( + [ + + db_column("name", char_field(30), []), + db_column("manufacturer", char_field(20), []), + db_column("power", integer_field, []) + ], + "obj.name" + ), + db_display( + //list_view + [ "name", "manufacturer"], + //list_edit + ["name", "manufacturer", "power"] + ) + ). + +public define DB_Table production_product_reference_table = + db_table("production_product_reference", + db_model( + [ + db_column("type_ref_id", foreign_key("production_type_number"), [indexed]), + db_column("product_ref", char_field(4), []), + db_column("product_name", char_field(30), []), // + db_column("description", char_field(200), []), // + db_column("need_memory", boolean_field, []), // + db_column("need_power_supply", boolean_field, []), // + db_column("need_additional_storage", boolean_field, []), // + db_column("min_additional_storage", integer_field, []), // + db_column("max_additional_storage", integer_field, []), // + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.product_ref+\":\"+obj.product_name" + ), + db_display( + //list_view + [ "type_ref_id", "product_ref", "product_name", "description"], + //list_edit + [ "type_ref_id", "product_ref", "product_name", "description", "need_memory", "need_power_supply", "need_additional_storage", "min_additional_storage", "max_additional_storage", + "date_created", "last_modified", "comments"] + ) + ). + +public define DB_Table production_products_table = + db_table("production_products", + db_model( + [ + db_column("production_id", foreign_key("production_production"), []), + db_column("produced", boolean_field, []), // + db_column("date", date_field(none), []), + db_column("serial", char_field(50), []), // + db_column("security_code", char_field(50), []), // + db_column("motherboard_id", foreign_key("production_motherboard"), []), + db_column("storage_id", foreign_key("production_mass_storage"), []), + db_column("memory_id", foreign_key("production_memory"), []), + db_column("power_supply_id", foreign_key("production_power_supply"), []), + db_column("wifi", boolean_field, []), // + db_column("mac", char_field(20), []), + db_column("app_id", char_field(100), []), + db_column("os_version", char_field(20), []), + db_column("published", boolean_field, []), + db_column("publish_date", datetime_field(none), []), // + db_column("status", char_field(10), []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.serial" + ), + db_display( + //list_view + [ "production_id", "date", "serial", "motherboard_id", "app_id", "status"], + //list_edit + [ "production_id", "produced", "date", "serial", "security_code", "motherboard_id", "storage_id", "memory_id", "power_supply_id", "wifi", "mac", + "app_id", "os_version", "published", "publish_date", "status", "date_created", "last_modified", "comments"] + ) + ). + +public define DB_Table production_production_table = + db_table("production_production", + db_model( + [ + + db_column("date", date_field(none), []), + db_column("assembler_id", foreign_key("staff_staff"), []), + db_column("type_ref_id", foreign_key("production_type_number"), []), + db_column("product_ref_id", foreign_key("production_product_reference"), []), + db_column("site_id", foreign_key("production_production_site"), []), + db_column("serial_prefix_id", foreign_key("production_serial_prefix"), []), + db_column("sticker_tpl_id", foreign_key("production_type_number"), []), + db_column("starting_index", integer_field, []), // + db_column("product_count", integer_field, []), // + db_column("produced_count", integer_field, []), // + db_column("completed", boolean_field, []), // + db_column("active", boolean_field, []), // + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "date(obj.date)" + ), + db_display( + //list_view + [ "date", "type_ref_id", "sticker_tpl_id", "product_ref_id", "site_id", "product_count", "produced_count"], + //list_edit + [ "date", "assembler_id", "type_ref_id", "product_ref_id", "site_id", "serial_prefix_id", "sticker_tpl_id", "starting_index", "product_count", "produced_count", "completed", + "active", "date_created", "last_modified", "comments"] + ) + ). + +public define DB_Table production_production_site_table = + db_table("production_production_site", + db_model( + [ + db_column("ref", char_field(3), []), + db_column("name", char_field(50), []), + db_column("city", char_field(30), []), + db_column("country", char_field(30), []), + db_column("next_serial", integer_field, []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.ref+\":\"+obj.name" + ), + db_display( + //list_view + [ "ref", "name", "city", "country"], + //list_edit + [ "ref", "name", "city", "country", "next_serial", "date_created", "last_modified", "comments"] + ) + ). + public define DB_Table production_purchase_table = db_table("production_purchase", db_model( [ - db_column("id", p_key, []), db_column("date", date_field(none), []), db_column("buyer_id", foreign_key("staff_staff"), [indexed]), db_column("supplier_id", foreign_key("production_supplier"), [indexed]), @@ -217,7 +471,7 @@ public define DB_Table production_purchase_table = db_column("last_modified", datetime_field(auto_now), []), db_column("comments", text_field, []), // whatever the user wants to keep ], - "" + "date(obj.date)" ), db_display( //list_view @@ -226,19 +480,212 @@ public define DB_Table production_purchase_table = ["date", "buyer_id", "supplier_id", "order_ref", "description", "comments"] ) ). + +public define DB_Table production_serial_prefix_table = + db_table("production_serial_prefix", + db_model( + [ + + db_column("prefix", char_field(3), []), + db_column("next_start", integer_field, []) + ], + "obj.prefix" + ), + db_display( + //list_view + ["prefix", "next_start"], + //list_edit + ["prefix", "next_start"] + ) + ). + +public define DB_Table production_type_number_table = + db_table("production_type_number", + db_model( + [ + + db_column("type_ref", char_field(3), []), + db_column("description", text_field, []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.type_ref+\":\"+obj.description" + ), + db_display( + //list_view + [ "type_ref", "description"], + //list_edit + ["type_ref", "description", "comments"] + ) + ). + +public define DB_Table production_supplier_table = + db_table("production_supplier", + db_model( + [ + db_column("company", char_field(100), []), + db_column("contact_id", foreign_key("address_book_contact"), []), + db_column("address1", char_field(100), []), + db_column("address2", char_field(100), []), + db_column("zipcode", char_field(10), []), + db_column("city", char_field(50), []), + db_column("country", char_field(50), []), + db_column("email", char_field(75), []), + db_column("url", char_field(200), []), + db_column("phone", char_field(20), []), + db_column("fax", char_field(20), []), + db_column("mobile", char_field(20), []), + db_column("siret", char_field(50), []), + db_column("tva_number", char_field(50), []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.company" + ), + db_display( + //list_view + [ "company", "phone", "mobile", "email"], + //list_edit + ["company", "supplier_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", + "siret", "tva_number", "date_created", "last_modified", "comments"] + ) + ). + + +public define DB_Table staff_department_table = + db_table("staff_department", + db_model( + [ + + db_column("name", char_field(50), []), + db_column("description", text_field, []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.name" + ), + db_display( + //list_view + [ "name"], + //list_edit + ["name", "description", "comments"] + ) + ). + + +public define DB_Table staff_role_table = + db_table("staff_role", + db_model( + [ + db_column("role_name", char_field(50), []), + db_column("description", text_field, []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.role_name" + ), + db_display( + //list_view + [ "role_name"], + //list_edit + ["role_name", "description", "comments"] + ) + ). + +public define DB_Table staff_staff_table = + db_table("staff_staff", + db_model( + [ + + db_column("contact_id", foreign_key("address_book_contact"), [indexed]), + db_column("department_id", foreign_key("staff_department"), [indexed]), + db_column("role_id", foreign_key("staff_role"), [indexed]), + db_column("email", char_field(75), []), + db_column("incoming_date", date_field(none), []), // + db_column("outgoing_date", date_field(none), [], help_text("if not still present in company. The date of official outgoing")), // + db_column("still_present", boolean_field, [], help_text("Still working for the company")), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.email" + ), + db_display( + //list_view + [ "contact_id", "department_id", "role_id", "email"], + //list_edit + ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "date_modified", "comments"] + ) + ). + +public define DB_Table address_book_contact_table = + db_table("address_book_contact", + db_model( + [ + + db_column("first_name", char_field(50), []), + db_column("last_name", char_field(50), []), + db_column("company", char_field(100), []), + db_column("role", char_field(50), []), + db_column("address1", char_field(100), []), + db_column("address2", char_field(100), []), + db_column("zipcode", char_field(10), []), + db_column("city", char_field(50), []), + db_column("country", char_field(50), []), + db_column("email", char_field(75), []), + db_column("url", char_field(200), []), + db_column("phone", char_field(20), []), + db_column("fax", char_field(20), []), + db_column("mobile", char_field(20), []), + db_column("date_created", datetime_field(auto_now_add), []), + db_column("last_modified", datetime_field(auto_now), []), + db_column("comments", text_field, []) // whatever the user wants to keep + ], + "obj.first_name +\" \"+obj.last_name " + ), + db_display( + //list_view + [ "first_name", "last_name", "company", "phone", "mobile", "email"], + //list_edit + ["first_name", "last_name", "company", "role", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "comments"] + ) + ). + public define DB_Database the_database_description = db_database("prod_manager", [ - mf_serial_table - /*settings_table, + //domain manager + //mf_serial_table + settings_table, + production_mass_storage_table, production_mass_storage_type_table, production_mass_storage_model_table, + production_memory_table, + production_memory_model_table, production_memory_type_table, production_macaddress_table, - django_admin_log_table*/ - //production_mass_storage_table, - //production_purchase_table + production_motherboard_table, + production_motherboard_model_table, + production_power_supply_table, + production_power_supply_model_table, + production_product_reference_table, + production_production_table, + production_production_site_table, + production_products_table, + production_purchase_table, + production_serial_prefix_table, + production_type_number_table, + production_supplier_table, + staff_department_table, + staff_staff_table, + staff_role_table, + django_admin_log_table, + address_book_contact_table ]). -- libgit2 0.21.4