model.3.0.0.anubis 8.67 KB

read calexium_lib/database/model/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(
      [
        db_column("id", p_key, []),
        db_column("var_name", char_field(20),  []),
        db_column("var_value", char_field(20),  []),
      ],
      "obj.var_name+\" = \"+obj.var_value"
    ),
    db_display(
      //list_view
      ["id", "var_name", "var_value"],
      //list edit
      ["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"]
    )
  ).
  
public define DB_Table   production_memory_type_table =
  db_table("production_memory_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"],
      //list edit
      ["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"],
      //list edit
      ["type"]
    )
  ).
  
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,   []),     // 
        db_column("tr_min",        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.manufacturer"
    ),
    db_display(
      //list_view
      ["id", "manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"],
      //list_edit
      []
    )
  ).
  
public define DB_Table   production_mass_storage_table =
  db_table("production_mass_storage",
    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("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.purchase_id.string"
    ),
    db_display(
      //list_view
      ["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_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]),  
        db_column("order_ref",     char_field(50),   []),     // 
        db_column("description",   char_field(200),  []),     // description of the purchase
        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 
      ],
      ""
    ),
    db_display(
      //list_view
      ["date", "supplier_id", "description"],
      //list_edit
      ["date", "buyer_id", "supplier_id", "order_ref", "description", "comments"]
    )
  ).
        
public define DB_Database
  the_database_description
  =
  db_database("prod_manager", 
            [
              mf_serial_table
              /*settings_table,
              production_mass_storage_type_table,
              production_mass_storage_model_table,
              production_memory_type_table,
              production_macaddress_table,
              django_admin_log_table*/
              //production_mass_storage_table,
              //production_purchase_table
            ]).