Commit 307c3090dd17a3b1d7977c71c383ed4b4b44583f
1 parent
03fd5d94
remove not need tools/base_tools.anubis and also only exists on produciton_manag…
…er project which is where is based db_model_manager fix the datetime_field generation for VTM
Showing
4 changed files
with
107 additions
and
20 deletions
Show diff stats
src/generation/files.anubis
src/generation/header.anubis
src/model.3.0.0.anubis
| 1 | 1 | |
| 2 | 2 | read types/db_model.anubis |
| 3 | 3 | |
| 4 | + | |
| 5 | +public define DB_Table mf_serial_table = | |
| 6 | + db_table("mf_serial", | |
| 7 | + db_model( | |
| 8 | + [ | |
| 9 | + db_column("id", p_key, []), | |
| 10 | + db_column("serial", char_field(30), []), | |
| 11 | + db_column("mac", char_field(30), []), | |
| 12 | + db_column("app_id", char_field(50), []), | |
| 13 | + db_column("enabled",boolean_field, []), | |
| 14 | + db_column("free_domain",boolean_field, []), | |
| 15 | + db_column("max_domains",integer_field, []), | |
| 16 | + db_column("is_demo",boolean_field, []), | |
| 17 | + db_column("is_test",boolean_field, []), | |
| 18 | + db_column("date_created", datetime_field(auto_now_add), []), | |
| 19 | + db_column("last_updated", datetime_field(none), []), | |
| 20 | + db_column("last_ping", datetime_field(none), []), | |
| 21 | + db_column("current_ip", char_field(20), []), | |
| 22 | + db_column("mf_version", char_field(20), []), | |
| 23 | + db_column("vm_version", char_field(20), []), | |
| 24 | + db_column("os_version", char_field(20), []), | |
| 25 | + db_column("ipkg_list", text_field, []), | |
| 26 | + db_column("ifconfig", text_field, []), | |
| 27 | + db_column("dmesg", text_field, []), | |
| 28 | + db_column("memory", text_field, []), | |
| 29 | + db_column("vm_memory", text_field, []), | |
| 30 | + db_column("status", text_field, []), | |
| 31 | + db_column("disks", text_field, []), | |
| 32 | + db_column("isp_smtp", text_field, []), | |
| 33 | + db_column("description", text_field, []), | |
| 34 | + db_column("comments", text_field, []), | |
| 35 | + db_column("alert_received",boolean_field, []), | |
| 36 | + db_column("alert_date", datetime_field(none), []), | |
| 37 | + db_column("alert_msg", text_field, []), | |
| 38 | + db_column("alert_mf_version", char_field(20), []), | |
| 39 | + ], | |
| 40 | + "obj.serial" | |
| 41 | + ), | |
| 42 | + db_display( | |
| 43 | + //list_view | |
| 44 | + ["id", "serial", "mf_version", "mac", "app_id", "is_demo", "is_test", "last_updated", "last_ping", "mf_version", ], | |
| 45 | + //list edit | |
| 46 | + ["serial", "mac", "app_id", "enabled", "free_domain", "max_domains", "is_demo", "is_test", "date_created", "last_updated", "last_ping", "current_ip", "mf_version", | |
| 47 | + "os_version", "ipkg_list", "ifconfig", "dmesg", "memory", "vm_memory", "status", "disks", "isp_smtp", "description", "comments", "alert_received", "alert_date", | |
| 48 | + "alert_msg", "alert_mf_version"] | |
| 49 | + ) | |
| 50 | + ). | |
| 51 | + | |
| 4 | 52 | public define DB_Table settings_table = |
| 5 | 53 | db_table("settings", |
| 6 | 54 | db_model( |
| ... | ... | @@ -13,9 +61,53 @@ public define DB_Table settings_table = |
| 13 | 61 | ), |
| 14 | 62 | db_display( |
| 15 | 63 | //list_view |
| 16 | - ["var_name", "var_value"], | |
| 64 | + ["id", "var_name", "var_value"], | |
| 17 | 65 | //list edit |
| 18 | - ["type"] | |
| 66 | + ["var_name", "var_value"] | |
| 67 | + ) | |
| 68 | + ). | |
| 69 | + | |
| 70 | +public define DB_Table django_admin_log_table = | |
| 71 | + db_table("django_admin_log", | |
| 72 | + db_model( | |
| 73 | + [ | |
| 74 | + db_column("id", p_key, []), | |
| 75 | + db_column("action_time", datetime_field(auto_now_add), []), | |
| 76 | +// db_column("user_id", foreign_key("auth_user"), [indexed]), | |
| 77 | +// db_column("content_type_id", foreign_key("django_content_type"), [indexed]), | |
| 78 | + db_column("user_id", integer_field, []), | |
| 79 | + db_column("content_type_id", integer_field, []), | |
| 80 | + db_column("object_id", text_field, []), | |
| 81 | + db_column("object_repr", char_field(200), []), | |
| 82 | + db_column("action_flag", integer_field, []), | |
| 83 | + db_column("change_message", text_field, []), | |
| 84 | + ], | |
| 85 | + "obj.object_repr" | |
| 86 | + ), | |
| 87 | + db_display( | |
| 88 | + //list_view | |
| 89 | + ["id", "action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message" ], | |
| 90 | + //list edit | |
| 91 | + ["action_time", "user_id", "content_type_id", "object_id", "object_repr", "action_flag", "change_message"] | |
| 92 | + ) | |
| 93 | + ). | |
| 94 | + | |
| 95 | +public define DB_Table production_macaddress_table = | |
| 96 | + db_table("production_macaddress", | |
| 97 | + db_model( | |
| 98 | + [ | |
| 99 | + db_column("id", p_key, []), | |
| 100 | + db_column("mac", char_field(20), []), | |
| 101 | + db_column("index", integer_field, []), | |
| 102 | + db_column("mailfountain_id", integer_field, []), | |
| 103 | + ], | |
| 104 | + "obj.mac+\" = MailFountain[\"+obj.mailfountain_id+\"]\"" | |
| 105 | + ), | |
| 106 | + db_display( | |
| 107 | + //list_view | |
| 108 | + ["id", "mac", "index", "mailfountain_id"], | |
| 109 | + //list edit | |
| 110 | + ["mac", "index", "mailfountain_id"] | |
| 19 | 111 | ) |
| 20 | 112 | ). |
| 21 | 113 | |
| ... | ... | @@ -140,10 +232,13 @@ public define DB_Database |
| 140 | 232 | = |
| 141 | 233 | db_database("prod_manager", |
| 142 | 234 | [ |
| 143 | - settings_table, | |
| 235 | + mf_serial_table | |
| 236 | + /*settings_table, | |
| 144 | 237 | production_mass_storage_type_table, |
| 145 | 238 | production_mass_storage_model_table, |
| 146 | - production_memory_type_table | |
| 239 | + production_memory_type_table, | |
| 240 | + production_macaddress_table, | |
| 241 | + django_admin_log_table*/ | |
| 147 | 242 | //production_mass_storage_table, |
| 148 | 243 | //production_purchase_table |
| 149 | 244 | ]). | ... | ... |
src/types/db_model.anubis
| ... | ... | @@ -123,26 +123,20 @@ public type DB_Table: |
| 123 | 123 | |
| 124 | 124 | public type DB_Database: |
| 125 | 125 | db_database (String name, // name of the database |
| 126 | - List(DB_Table) tables). // list of all tables in the database | |
| 127 | - | |
| 128 | - Note: indexes are described via the attributes and will be generated accordingly. | |
| 126 | + List(DB_Table) tables). | |
| 127 | +// list of all tables in the database | |
| 128 | + | |
| 129 | 129 | |
| 130 | - | |
| 131 | - Dates (of type 'String' in Anubis) are stored into the database as ISO-8601 strings, | |
| 132 | - for example: 2013-05-24 09:34:23 | |
| 133 | - | |
| 134 | - We provide functions for conversion into Int (number of seconds since the 'epoch') and conversely | |
| 135 | - in 'library/tools/ISO-8601.anubis'. | |
| 136 | 130 | |
| 137 | -public define Maybe(String) convert_to_date (MaybeNull(ByteArray) b). | |
| 138 | -public define MaybeNull(String) convert_to_date_or_null (MaybeNull(ByteArray) b). | |
| 131 | +//public define Maybe(String) convert_to_date (MaybeNull(ByteArray) b). | |
| 132 | +//public define MaybeNull(String) convert_to_date_or_null (MaybeNull(ByteArray) b). | |
| 139 | 133 | |
| 140 | 134 | *** (8.3.6) Converting 'integer?' and 'integer?_or_null' to and fro. |
| 141 | 135 | |
| 142 | 136 | The next functions are used for integer16, integer32 and integer. |
| 143 | 137 | |
| 144 | -public define Maybe(Int) convert_to_integer (MaybeNull(ByteArray) b). | |
| 145 | -public define MaybeNull(Int) convert_to_integer_or_null (MaybeNull(ByteArray) b). | |
| 138 | +//public define Maybe(Int) convert_to_integer (MaybeNull(ByteArray) b). | |
| 139 | +//public define MaybeNull(Int) convert_to_integer_or_null (MaybeNull(ByteArray) b). | |
| 146 | 140 | |
| 147 | 141 | |
| 148 | 142 | *** (8.3.7) Converting 'char/text' and 'char_or_null/text_or_null' to and fro. |
| ... | ... | @@ -579,7 +573,7 @@ public define Maybe(String) |
| 579 | 573 | time_field(attrs) then success("time(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+")"), |
| 580 | 574 | datetime_field(attrs) then if attrs is |
| 581 | 575 | { |
| 582 | - none then success("datetime(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+")"), | |
| 576 | + none then success("datetime(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)"), | |
| 583 | 577 | auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)"), |
| 584 | 578 | auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime)") |
| 585 | 579 | }, | ... | ... |