Forum OpenACS Development: Re: subsite- and CR-enabled ecommerce package

Collapse
Posted by James Thornton on
I think I figured it out. I created a content type moto_vehicle with a supertype of es_product, and I made the moto_vehicle primary key reference es_product_revision. I see that the automatically generated views, moto_vehiclex and moto_vehiclei, include the es_product attributes.

Inside moto_vehicle__new I'll call es_product__new, and then I'll call content_revision__new, passing in the revision_id returned from es_product__new.

Did I do it right? Am I missing something?

select content_type__create_type (
      'moto_vehicle',         -- content_type
      'es_product',         -- supertype,
      'Moto Vehicle',         -- pretty_name,
      'Moto Vehicles',         -- pretty_plural,
      'moto_vehicle',         -- table_name,
      'vehicle_revision_id',     -- id_column,
      null             -- name_method
);

create table moto_vehicle (
      vehicle_revision_id    int
                              constraint moto_vehicle_revision_id_fk
                      references es_product_revision(product_revision_id)
                  on delete cascade
                  constraint moto_vehicle_revision_id_pk
                  primary key,
      year                  numeric(4) not null,
      new_p                  bool not null,
      category_id            int not null references es_category,
      make_id                  int not null references es_category,
      -- find or write a plpgsql strip fuction to query model
      model                  text not null,
      payment                numeric(10,2),
      usage                  real,
      usage_hours_p          bool not null,
      color                  text not null,
      engine               text,
      financing_p          bool not null,
      warranty_p            bool not null,
      date_sold              timestamptz,
      dealer_id              int not null references moto_dealer,
      location_id           int not null references moto_dealer_location
);