From 33107ad3b12a52c492dd9b643ee999a9b8533800 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 16 Oct 2009 17:13:01 +0000 Subject: [PATCH] review the registration process to mark with ext_consortium_id=0 the pending sites this in turn will be used by monitor to avoid sending actions to those sites also made the address block optional pending sites rendering nicer --- planetlab/common/actions.php | 2 - planetlab/css/plc_style.css | 7 ++- planetlab/includes/plc_functions.php | 8 ++++ planetlab/includes/plc_header.php | 3 -- planetlab/sites/join_request.php | 64 +++++++++++++++++++--------- planetlab/sites/register.php | 23 +++++++--- planetlab/sites/site.php | 24 +++++++---- planetlab/sites/site_form.php | 44 +++++++++---------- planetlab/sites/sites.php | 8 +++- 9 files changed, 119 insertions(+), 64 deletions(-) diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index 1600eb4..a2dfd11 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -541,8 +541,6 @@ switch ($action) { drupal_set_error("Cannot renew slice that far in the future, max is $WEEKS weeks from now"); plc_redirect(l_slice($slice_id)); } - plc_debug('slice_id',$slice_id); - plc_debug('expires',$expires); if ($api->UpdateSlice ($slice_id, array('expires'=>$expires)) == 1) drupal_set_message("Slice renewed"); else diff --git a/planetlab/css/plc_style.css b/planetlab/css/plc_style.css index 8df53c4..87657d1 100644 --- a/planetlab/css/plc_style.css +++ b/planetlab/css/plc_style.css @@ -97,7 +97,7 @@ div.site-register { margin: 10px; } /* site registration */ -div.site-pending { +div.site-pending, div.sites-pending { background-color: #eadbc8; padding: 5px; margin: 10px; @@ -107,6 +107,11 @@ div.person-register { padding: 5px; margin: 10px; } +div.person-register { + background-color: #e3d1cb; + padding: 5px; + margin: 10px; +} /****************************************/ /* slice creation page */ diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index c72c598..4f10e8c 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -5,6 +5,13 @@ // will trash this eventually //require_once 'plc_functions_trash.php'; +# note: this needs to be consistent with the value in Monitor/monitor/wrapper/plc.py +global $PENDING_CONSORTIUM_ID; +$PENDING_CONSORTIUM_ID = 0; +# this one does not matter that much, just picking one +global $APPROVED_CONSORTIUM_ID; +$APPROVED_CONSORTIUM_ID = 999999; + // utility function my_is_int ($x) { return (is_numeric($x) ? intval($x) == $x : false); @@ -149,6 +156,7 @@ function l_reset_password() { return "/db/persons/reset_password.php"; } function l_person_register() { return "/db/persons/register.php"; } function l_site_register() { return "/db/sites/register.php"; } function l_sites_pending() { return "/db/sites/join_request.php"; } +function l_site_review_pending($site_id){ return "/db/sites/join_request.php?review=t&site_id=$site_id"; } //////////////////////////////////////////////////////////// nav tabs diff --git a/planetlab/includes/plc_header.php b/planetlab/includes/plc_header.php index ab710fc..c1f67a3 100644 --- a/planetlab/includes/plc_header.php +++ b/planetlab/includes/plc_header.php @@ -11,9 +11,6 @@ require_once 'plc_drupal.php'; -$PENDING_CONSORTIUM_ID = 0; -$APPROVED_CONSORTIUM_ID = 999999; - if (!function_exists('drupal_page_header')) { $title = drupal_get_title(); $head = drupal_get_html_head(); diff --git a/planetlab/sites/join_request.php b/planetlab/sites/join_request.php index 0540bf1..ce7b309 100644 --- a/planetlab/sites/join_request.php +++ b/planetlab/sites/join_request.php @@ -19,24 +19,46 @@ include 'plc_header.php'; require_once 'plc_functions.php'; require_once 'details.php'; require_once 'nifty.php'; +require_once 'table.php'; +require_once 'nifty.php'; include 'site_form.php'; //////////////////////////////////////// function render_all_join_requests($api) { - $sites = $api->GetSites( array("enabled" => False, "peer_id" => NULL, "ext_consortium_id" => $PENDING_CONSORTIUM_ID)); - if (!empty($sites)) { - print(""); - print(""); - foreach($sites as $site) { - printf("", $site['site_id'], $site['name']); - printf("", $site['site_id'], $site['site_id']); - printf("", date("d F Y, G:i",$site['date_created'])); - } - print("
Site Namesite_idSubmitted
%s %d %s
"); - } else { + global $PENDING_CONSORTIUM_ID; + $filter = array("peer_id" => NULL, "ext_consortium_id" => $PENDING_CONSORTIUM_ID); + $columns=array('site_id','name','enabled','date_created'); + $sites = $api->GetSites( $filter, $columns); + if (empty($sites)) { print("

No open join requests

"); + return; } + $headers = array(); + $headers['id']='int'; + $headers['Site Name']='string'; + # trying the sortEnglishDateTime stuff - not too lucky so far + # http://www.frequency-decoder.com/demo/table-sort-revisited/custom-sort-functions/ + $headers['submitted']='sortEnglishDateTime'; + $headers['enabled']='string'; + + $nifty=new PlekitNifty ('pending','sites-pending','medium'); + $nifty->start(); + $table=new PlekitTable ('pending',$headers,2, + array('pagesize_area'=>FALSE,'pagesize'=>10000)); + $table->start(); + foreach($sites as $site) { + $site_id=$site['site_id']; + $link = $site['enabled'] ? l_site($site_id) : l_site_review_pending($site_id); + $table->row_start(); + $table->cell(href($link,$site['site_id'])); + $table->cell(href($link,$site['name'])); + $table->cell(date("dS F Y",$site['date_created']) . " at " . date("G:i",$site['date_created'])); + $table->cell( $site['enabled'] ? plc_warning_html('yes') : 'no'); + $table->row_end(); + } + $table->end(); + $nifty->end(); } function render_join_request_review($api, $site_id) { @@ -52,11 +74,13 @@ function render_join_request_review($api, $site_id) { } $addresses = $api->GetAddresses ($site['address_ids']); if (empty ($addresses)) { - print("

No address found for site_id=$site_id

"); - return ; + drupal_set_message("Site $site_id has no address - never mind"); + $address=array('line1'=>''); + $address_id=0; + } else { + $address = $addresses[0]; + $address_id=$address['address_id']; } - $address = $addresses[0]; - $address_id=$address['address_id']; # just in case there is no person attached yet if (empty ($site['person_ids'])) { $persons=array(); @@ -87,6 +111,7 @@ function render_join_request_review($api, $site_id) { EOF; + // don't render the tech part if that was the same as the pi $site_form = build_site_form(FALSE); $input = array ('site' => $site, 'address'=> $address, 'pi' => $pi, 'tech' => $tech); @@ -215,9 +240,9 @@ else if ($_POST['submitted'] ) case 'Update': { $api->begin(); $api->UpdateSite($site_id,$site); - $api->UpdateAddress($address_id,$address); + if ($address_id) $api->UpdateAddress($address_id,$address); $api->UpdatePerson($pi_id,$pi); - $api->UpdatePerson($tech_id,$tech); + if ($tech_id != $pi_id) $api->UpdatePerson($tech_id,$tech); $api->commit(); $api_error=$api->error(); if (!empty($api_error)) { @@ -234,6 +259,7 @@ else if ($_POST['submitted'] ) // the PI's email address, which makes the whole thing *a lot* simpler // enable the site, enable the PI, and VerifyPerson the thec if different from the PI $site['enabled'] = True; + global $APPROVED_CONSORTIUM_ID; $site['ext_consortium_id'] = $APPROVED_CONSORTIUM_ID; $api->UpdateSite ($site_id,$site); $api_error=$api->error(); @@ -241,10 +267,10 @@ else if ($_POST['submitted'] ) $error .= $api->error(); $messages [] = "Could not enable site"; } else { - $messages[] = "Site " . $site['name'] . " enabled"; + $messages[] = l_site_t ($site_id,"Site '" . $site['name'] . "' enabled"); } - if (empty ($error)) { + if (empty ($error) && $address_id) { // Update Address $api->UpdateAddress($address_id,$address); $api_error=$api->error(); diff --git a/planetlab/sites/register.php b/planetlab/sites/register.php index 7a79eda..c9d59fc 100644 --- a/planetlab/sites/register.php +++ b/planetlab/sites/register.php @@ -34,6 +34,11 @@ $pi=$input['pi']; $tech=$input['tech']; $address=$input['address']; +# allow address to be left out +function non_empty_address ($address) { + return !empty($address['line1']); +} + if (! $empty_form ) { // Look for missing/blank entries $error = form_check_required ($site_form, $input); @@ -62,10 +67,12 @@ if (! $empty_form ) { // creating the site $site['enabled']=FALSE; + global $PENDING_CONSORTIUM_ID; + $site['ext_consortium_id']=$PENDING_CONSORTIUM_ID; $site_id=$adm->AddSite($site); $api_error .= $adm->error(); if (empty($api_error)) { - $verboses [] = "Site created as disabled"; + $verboses [] = "Site created as disabled, with ext_consortium_id=".$PENDING_CONSORTIUM_ID; } else { $error .= $api_error; } @@ -93,12 +100,14 @@ EOF; $messages [] = "Please send a message to " . PLC_MAIL_SUPPORT_ADDRESS . " if this request is not instructed within a few days."; // creating address - $adm->AddSiteAddress($site_id,$address); - $api_error = $adm->error(); - if (empty($api_error)) { - $verboses [] = "Address created"; - } else { - $error .= $api_error; + if (non_empty_address($address)) { + $adm->AddSiteAddress($site_id,$address); + $api_error = $adm->error(); + if (empty($api_error)) { + $verboses [] = "Address created"; + } else { + $error .= $api_error; + } } // creating PI diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php index ef5fe1e..807479d 100644 --- a/planetlab/sites/site.php +++ b/planetlab/sites/site.php @@ -48,6 +48,7 @@ $max_slivers= $site['max_slivers']; $max_slices= $site['max_slices']; $enabled = $site['enabled']; +$ext_consortium_id = $site ['ext_consortium_id']; // get peer $peer_id= $site['peer_id']; @@ -150,14 +151,21 @@ plekit_linetabs($tabs); // show gray background on foreign objects : start a
with proper class $peers->block_start ($peer_id); -if ( $local_peer && ( ! $enabled ) ) { - if ($site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID) { - plc_warning ("This site is not enabled - Please visit " . - href (l_sites_pending(),"this page") . - " to review pending applications."); - } else { - plc_warning ("This site is disabled."); - } +// sanity checks +if ( $local_peer ) { + // pending site + global $PENDING_CONSORTIUM_ID; + if ( $ext_consortium_id == $PENDING_CONSORTIUM_ID) { + if ( ! $enabled ) + plc_warning ("This site is under pending registration - Please visit " . + href (l_sites_pending(),"this page") . + " to review pending applications."); + else + plc_warning ("This site is pending but is also enabled - something is wrong. You should fix the issue with plcsh"); + } else { + if ( ! $enabled) + plc_warning ("This site is disabled."); + } } $can_update=(plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && plc_is_pi()); diff --git a/planetlab/sites/site_form.php b/planetlab/sites/site_form.php index e77d781..b602b1d 100644 --- a/planetlab/sites/site_form.php +++ b/planetlab/sites/site_form.php @@ -9,38 +9,21 @@ function build_site_form ($register_mode) { $form = array(); $form['site:name'] = array('title' => 'Site name', 'required' => TRUE, 'maxlength' => 40, 'size' => 20, - 'comment' => 'Site Information:'); + 'comment' => 'Site Information'); $form['site:login_base'] = array('title' => 'Login base', 'required' => TRUE, 'maxlength' => 16, 'size' => 10); $form['site:abbreviated_name'] = array('title' => 'Abbreviated name', 'required' => TRUE, 'maxlength' => 20, 'size' => 12); $form['site:url'] = array('title' => 'URL', 'required' => TRUE, 'maxlength' => 30, 'size' => 30); - $form['site:latitude'] = array('title' => 'Latitude', 'required' => FALSE, + $form['site:latitude'] = array('title' => 'Latitude', 'required' => TRUE, 'maxlength' => 10, 'size' => 10, 'type' => 'double'); - $form['site:longitude'] = array('title' => 'Longitude', 'required' => FALSE, + $form['site:longitude'] = array('title' => 'Longitude', 'required' => TRUE, 'maxlength' => 10, 'size' => 10, 'type' => 'double'); - $form['address:line1'] = array('title' => 'Address', 'required' => TRUE, - 'maxlength' => 40, 'size' => 30, - 'comment' => 'Postal address:'); - $form['address:line2'] = array('title' => 'Address (2)', 'required' => FALSE, - 'maxlength' => 40, 'size' => 30); - $form['address:line3'] = array('title' => 'Address (3)', 'required' => FALSE, - 'maxlength' => 40, 'size' => 30); - $form['address:city'] = array('title' => 'City', 'required' => TRUE, - 'maxlength' => 20, 'size' => 20); - $form['address:postalcode'] = array('title' => 'Postal Code', 'required' => TRUE, - 'maxlength' => 10, 'size' => 10); -# would have liked it *not* required but it is mandatory in the DB - sigh - $form['address:state'] = array('title' => 'State', 'required' => TRUE, - 'maxlength' => 20, 'size' => 20); - $form['address:country'] = array('title' => 'Country', 'required' => TRUE, - 'maxlength' => 20, 'size' => 20); - $form['pi:first_name'] = array('title' => 'PI First Name', 'required' => TRUE, 'maxlength' => 20, 'size' => 20, - 'comment' => 'Principal Investigator Information:'); + 'comment' => 'Principal Investigator Information'); $form['pi:last_name'] = array('title' => 'PI Last Name', 'required' => TRUE, 'maxlength' => 20, 'size' => 20); $form['pi:title'] = array('title' => 'PI Title', 'required' => FALSE, @@ -73,7 +56,7 @@ EOF; $form['tech:first_name'] = array('title' => 'Tech First Name', 'required' => TRUE, 'maxlength' => 20, 'size' => 20, - 'comment' => 'Technical Contact Information:' . $fill_from_pi_button); + 'comment' => 'Technical Contact Information' . $fill_from_pi_button); $form['tech:last_name'] = array('title' => 'Tech Last Name', 'required' => TRUE, 'maxlength' => 20, 'size' => 20); $form['tech:title'] = array('title' => 'Tech Title', 'required' => FALSE, @@ -88,6 +71,23 @@ EOF; $form['tech:user-role'] = array('type' => 'boolean', 'title' => 'Need user role', 'default' => TRUE); } + $form['address:line1'] = array('title' => 'Address', 'required' => FALSE, + 'maxlength' => 40, 'size' => 30, + 'comment' => 'Postal address (can be left blank)'); + $form['address:line2'] = array('title' => 'Address (2)', 'required' => FALSE, + 'maxlength' => 40, 'size' => 30); + $form['address:line3'] = array('title' => 'Address (3)', 'required' => FALSE, + 'maxlength' => 40, 'size' => 30); + $form['address:city'] = array('title' => 'City', 'required' => FALSE, + 'maxlength' => 20, 'size' => 20); + $form['address:postalcode'] = array('title' => 'Postal Code', 'required' => FALSE, + 'maxlength' => 10, 'size' => 10); +# would have liked it *not* required but it is mandatory in the DB - sigh + $form['address:state'] = array('title' => 'State', 'required' => FALSE, + 'maxlength' => 20, 'size' => 20); + $form['address:country'] = array('title' => 'Country', 'required' => FALSE, + 'maxlength' => 20, 'size' => 20); + return $form; } diff --git a/planetlab/sites/sites.php b/planetlab/sites/sites.php index 6b1c32d..8eb5a03 100644 --- a/planetlab/sites/sites.php +++ b/planetlab/sites/sites.php @@ -50,6 +50,9 @@ function site_status ($site) { // check that site is enabled if ( ! $site['enabled']) $messages [] = "Not enabled"; + global $PENDING_CONSORTIUM_ID; + if ( $site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID ) + $messages [] = "Pending registration"; // check that site has at least a PI and a tech global $api; @@ -95,8 +98,9 @@ if (! plc_is_admin()) { $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ); $site_filter = array_merge ($site_filter, array ("enabled" => TRUE)); } else { - $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" , "is_public", - "enabled", "person_ids", "max_slices", "slice_ids", "node_ids"); + $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" , + "is_public", "enabled", "ext_consortium_id", + "person_ids", "max_slices", "slice_ids", "node_ids"); } if (plc_is_admin()) -- 2.43.0