Index: openacs-4/packages/simulation/lib/simulations-available.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/simulations-available.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/lib/simulations-available.tcl 12 Jan 2004 15:52:44 -0000 1.3 +++ openacs-4/packages/simulation/lib/simulations-available.tcl 15 Jan 2004 14:56:26 -0000 1.4 @@ -11,9 +11,8 @@ } set package_id [ad_conn package_id] +set user_id [ad_conn user_id] -# TODO (.25h): if invited instead of open, say "accept invitation to enroll" - set elements { pretty_name { label "Simulation" @@ -26,9 +25,9 @@ } } enroll { - label "Enroll" + label "Join" display_template { - Self-enroll + Join } } @@ -37,34 +36,38 @@ template::list::create \ -name avail_sims \ -multirow avail_sims \ - -no_data "No simulations available to self-enroll." \ + -no_data "No simulations available to join." \ -elements $elements -# TODO (.25h): verify that the first half of this query returns the sims to which the user is invited (data model may have changed since this was coded) -# TODO (.25h): exclude simulations for which the user is currently enrolled - -db_multirow -extend {enroll_url} avail_sims select_avail_sims " - select w.workflow_id, - w.pretty_name, - w.description, - w.description_mime_type - from workflows w, - sim_party_sim_map spsm - where w.workflow_id = spsm.simulation_id - and spsm.simulation_id = :party_id - UNION - select w.workflow_id, - w.pretty_name, - w.description, - w.description_mime_type - from workflows w, - sim_simulations ss - where ss.simulation_id = w.workflow_id - and ss.enroll_start <= now() +db_multirow -extend { enroll_url } avail_sims select_avail_sims " +select w.workflow_id, + w.pretty_name, + w.description, + w.description_mime_type +from sim_simulations ss, + workflows w +where ss.simulation_id = w.workflow_id + and ss.sim_type = 'casting_sim' + and (ss.enroll_start <= now() and ss.enroll_end >= now() - and ss.enroll_type = 'open' + and ss.enroll_type = 'open' + or + exists (select 1 + from sim_party_sim_map spsm1, + party_approved_member_map pamm + where spsm1.simulation_id = ss.simulation_id + and spsm1.party_id = pamm.party_id + and pamm.member_id = :user_id + and spsm1.type = 'invited' + ) + ) + and not exists (select 1 + from sim_party_sim_map spsm2 + where spsm2.simulation_id = ss.simulation_id + and spsm2.party_id = :user_id + and spsm2.type = 'enrolled' + ) " { set enroll_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/enroll" {workflow_id} ] set description [ad_html_text_convert -from $description_mime_type -maxlen 200 -- $description] - }