From 307c3090dd17a3b1d7977c71c383ed4b4b44583f Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 10 Jan 2016 12:11:05 +0100 Subject: [PATCH] remove not need tools/base_tools.anubis and also only exists on produciton_manager project which is where is based db_model_manager fix the datetime_field generation for VTM --- src/generation/files.anubis | 1 - src/generation/header.anubis | 1 - src/model.3.0.0.anubis | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/types/db_model.anubis | 22 ++++++++-------------- 4 files changed, 107 insertions(+), 20 deletions(-) diff --git a/src/generation/files.anubis b/src/generation/files.anubis index 8391e0a..eef3db7 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -83,7 +83,6 @@ define Maybe(One) * */ read tools/basis.anubis -read tools/base_tools.anubis read calexium_lib/database/vtm/view_table_manager_types.anubis\n"+ join("\n", transmit)+"\n\n"+ "public define List(VTM_view)\n"+ diff --git a/src/generation/header.anubis b/src/generation/header.anubis index 7d68ec3..18b46e6 100644 --- a/src/generation/header.anubis +++ b/src/generation/header.anubis @@ -51,7 +51,6 @@ public define Maybe(One) * */ read tools/basis.anubis -read tools/base_tools.anubis read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_common.anubis diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis index 35821a6..080e3d4 100644 --- a/src/model.3.0.0.anubis +++ b/src/model.3.0.0.anubis @@ -1,6 +1,54 @@ read types/db_model.anubis + +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("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("ipkg_list", text_field, []), + db_column("ifconfig", text_field, []), + db_column("dmesg", text_field, []), + db_column("memory", text_field, []), + db_column("vm_memory", text_field, []), + db_column("status", text_field, []), + db_column("disks", text_field, []), + 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_date", datetime_field(none), []), + db_column("alert_msg", text_field, []), + db_column("alert_mf_version", char_field(20), []), + ], + "obj.serial" + ), + db_display( + //list_view + ["id", "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", + "alert_msg", "alert_mf_version"] + ) + ). + public define DB_Table settings_table = db_table("settings", db_model( @@ -13,9 +61,53 @@ public define DB_Table settings_table = ), db_display( //list_view - ["var_name", "var_value"], + ["id", "var_name", "var_value"], //list edit - ["type"] + ["var_name", "var_value"] + ) + ). + +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("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, []), + ], + "obj.object_repr" + ), + db_display( + //list_view + ["id", "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"] + ) + ). + +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, []), + ], + "obj.mac+\" = MailFountain[\"+obj.mailfountain_id+\"]\"" + ), + db_display( + //list_view + ["id", "mac", "index", "mailfountain_id"], + //list edit + ["mac", "index", "mailfountain_id"] ) ). @@ -140,10 +232,13 @@ public define DB_Database = db_database("prod_manager", [ - settings_table, + mf_serial_table + /*settings_table, production_mass_storage_type_table, production_mass_storage_model_table, - production_memory_type_table + production_memory_type_table, + production_macaddress_table, + django_admin_log_table*/ //production_mass_storage_table, //production_purchase_table ]). diff --git a/src/types/db_model.anubis b/src/types/db_model.anubis index 5ff90a2..76ebf3c 100644 --- a/src/types/db_model.anubis +++ b/src/types/db_model.anubis @@ -123,26 +123,20 @@ public type DB_Table: public type DB_Database: db_database (String name, // name of the database - List(DB_Table) tables). // list of all tables in the database - - Note: indexes are described via the attributes and will be generated accordingly. + List(DB_Table) tables). +// list of all tables in the database + - - Dates (of type 'String' in Anubis) are stored into the database as ISO-8601 strings, - for example: 2013-05-24 09:34:23 - - We provide functions for conversion into Int (number of seconds since the 'epoch') and conversely - in 'library/tools/ISO-8601.anubis'. -public define Maybe(String) convert_to_date (MaybeNull(ByteArray) b). -public define MaybeNull(String) convert_to_date_or_null (MaybeNull(ByteArray) b). +//public define Maybe(String) convert_to_date (MaybeNull(ByteArray) b). +//public define MaybeNull(String) convert_to_date_or_null (MaybeNull(ByteArray) b). *** (8.3.6) Converting 'integer?' and 'integer?_or_null' to and fro. The next functions are used for integer16, integer32 and integer. -public define Maybe(Int) convert_to_integer (MaybeNull(ByteArray) b). -public define MaybeNull(Int) convert_to_integer_or_null (MaybeNull(ByteArray) b). +//public define Maybe(Int) convert_to_integer (MaybeNull(ByteArray) b). +//public define MaybeNull(Int) convert_to_integer_or_null (MaybeNull(ByteArray) b). *** (8.3.7) Converting 'char/text' and 'char_or_null/text_or_null' to and fro. @@ -579,7 +573,7 @@ public define Maybe(String) time_field(attrs) then success("time(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+")"), datetime_field(attrs) then if attrs is { - none then success("datetime(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+")"), + none then success("datetime(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)"), auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)"), auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)") }, -- libgit2 0.21.4