CC-3548: Schedule: Separate repeate show template and single instance on 'When' section

-in progress
This commit is contained in:
Martin Konecny 2012-04-12 11:54:51 -04:00
parent 071874626e
commit 5a8df0321e
4 changed files with 91 additions and 16 deletions

View file

@ -21,6 +21,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('get-current-playlist', 'json') ->addActionContext('get-current-playlist', 'json')
->addActionContext('remove-group', 'json') ->addActionContext('remove-group', 'json')
->addActionContext('populate-show-form', 'json') ->addActionContext('populate-show-form', 'json')
->addActionContext('populate-show-instance-form', 'json')
->addActionContext('cancel-show', 'json') ->addActionContext('cancel-show', 'json')
->addActionContext('cancel-current-show', 'json') ->addActionContext('cancel-current-show', 'json')
->addActionContext('get-form', 'json') ->addActionContext('get-form', 'json')
@ -265,7 +266,7 @@ class ScheduleController extends Zend_Controller_Action
} else { } else {
if($instance->isRepeating()){ if($instance->isRepeating()){
$menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array()); $menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array());
$menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/populate-show-form"); $menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/populate-show-instance-form");
$menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/populate-show-form"); $menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/populate-show-form");
}else{ }else{
if($instance->isRebroadcast()){ if($instance->isRebroadcast()){
@ -286,7 +287,7 @@ class ScheduleController extends Zend_Controller_Action
if($instance->isRepeating()){ if($instance->isRepeating()){
$menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array()); $menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array());
$menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/populate-show-form"); $menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/populate-show-instance-form");
$menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/populate-show-form"); $menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/populate-show-form");
}else{ }else{
if($instance->isRebroadcast()){ if($instance->isRebroadcast()){
@ -438,6 +439,67 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->showContent); unset($this->view->showContent);
} }
public function populateShowInstanceFormAction(){
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->live = $formLive;
$this->view->addNewShow = false;
$showInstanceId = $this->_getParam('id');
$show_instance = CcShowInstancesQuery::create()->findPK($showInstanceId);
$starts_string = $show_instance->getDbStarts();
$ends_string = $show_instance->getDbEnds();
$starts_datetime = new DateTime($starts_string, new DateTimeZone("UTC"));
$ends_datetime = new DateTime($ends_string, new DateTimeZone("UTC"));
$starts_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$ends_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$instance_duration = $starts_datetime->diff($ends_datetime);
$formValues = array('add_show_start_date' => $starts_datetime->format("Y-m-d"),
'add_show_start_time' => $starts_datetime->format("H:i"),
'add_show_end_date_no_repeat' => $ends_datetime->format("Y-m-d"),
'add_show_end_time' => $ends_datetime->format("H:i"),
'add_show_duration' => $instance_duration->format("%h"));
$formWhen->populate($formValues);
$formWhat->disable();
$formWho->disable();
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formStyle->disable();
/*
$formRecord->disable();
$formAbsoluteRebroadcast->disable();
$formRebroadcast->disable();
*/
$this->view->action = "edit-show-instance";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
}
public function populateShowFormAction() public function populateShowFormAction()
{ {
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -450,9 +512,7 @@ class ScheduleController extends Zend_Controller_Action
// repeating shows. It's value is either "instance","rebroadcast", or "all" // repeating shows. It's value is either "instance","rebroadcast", or "all"
$type = $this->_getParam('type'); $type = $this->_getParam('type');
if ($type == "instance"){ if($type == "rebroadcast") {
$this->view->action = "edit-show-instance";
} else if($type == "rebroadcast") {
$this->view->action = "edit-show-rebroadcast"; $this->view->action = "edit-show-rebroadcast";
} else { } else {
$this->view->action = "edit-show"; $this->view->action = "edit-show";
@ -500,6 +560,7 @@ class ScheduleController extends Zend_Controller_Action
$show = new Application_Model_Show($showInstance->getShowId()); $show = new Application_Model_Show($showInstance->getShowId());
$formWhat->populate(array('add_show_id' => $show->getId(), $formWhat->populate(array('add_show_id' => $show->getId(),
'add_show_instance_id' => $showInstanceId,
'add_show_name' => $show->getName(), 'add_show_name' => $show->getName(),
'add_show_url' => $show->getUrl(), 'add_show_url' => $show->getUrl(),
'add_show_genre' => $show->getGenre(), 'add_show_genre' => $show->getGenre(),
@ -590,7 +651,7 @@ class ScheduleController extends Zend_Controller_Action
$i++; $i++;
} }
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
if(!$isAdminOrPM || $type == "instance"){ if(!$isAdminOrPM){
$formRecord->disable(); $formRecord->disable();
$formAbsoluteRebroadcast->disable(); $formAbsoluteRebroadcast->disable();
$formRebroadcast->disable(); $formRebroadcast->disable();
@ -605,14 +666,6 @@ class ScheduleController extends Zend_Controller_Action
$formStyle->disable(); $formStyle->disable();
} }
if($type == "instance"){
$formWhat->disable();
$formWho->disable();
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formStyle->disable();
}
if($type == "rebroadcast"){ if($type == "rebroadcast"){
$formWhen->disable(); $formWhen->disable();
} }
@ -668,6 +721,17 @@ class ScheduleController extends Zend_Controller_Action
} }
$start_dt = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
$start_dt->setTimezone(new DateTimeZone('UTC'));
$end_dt = new DateTime($data['add_show_end_date_no_repeat']." ".$data['add_show_end_time'], new DateTimeZone(date_default_timezone_get()));
$end_dt->setTimezone(new DateTimeZone('UTC'));
//add_show_instance_id not being populated by populateShowInstanceFormAction.
$ccShowInstance = CcShowInstancesQuery::create()->findPK($data["add_show_instance_id"]);
$ccShowInstance->setDbStarts($start_dt);
$ccShowInstance->setDbEnds($end_dt);
$ccShowInstance->save();
} }
public function editShowAction(){ public function editShowAction(){

View file

@ -14,6 +14,12 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'decorators' => array('ViewHelper') 'decorators' => array('ViewHelper')
)); ));
// Hidden element to indicate the instance id of the show
// being edited.
$this->addElement('hidden', 'add_show_instance_id', array(
'decorators' => array('ViewHelper')
));
// Add name element // Add name element
$this->addElement('text', 'add_show_name', array( $this->addElement('text', 'add_show_name', array(
'label' => 'Name:', 'label' => 'Name:',

View file

@ -543,7 +543,11 @@ class Application_Model_Preference
} }
public static function GetAirtimeVersion(){ public static function GetAirtimeVersion(){
return self::GetValue("system_version"); if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development"){
return self::GetValue("system_version")."+".exec("git rev-parse --short HEAD");
} else {
return self::GetValue("system_version");
}
} }
public static function GetLatestVersion(){ public static function GetLatestVersion(){

View file

@ -592,7 +592,8 @@ class Application_Model_Schedule {
$p_view->style = $formStyle; $p_view->style = $formStyle;
$p_view->live = $formLive; $p_view->live = $formLive;
$formWhat->populate(array('add_show_id' => '-1')); $formWhat->populate(array('add_show_id' => '-1',
'add_show_instance_id' => '-1'));
$formWhen->populate(array('add_show_start_date' => date("Y-m-d"), $formWhen->populate(array('add_show_start_date' => date("Y-m-d"),
'add_show_start_time' => '00:00', 'add_show_start_time' => '00:00',
'add_show_end_date_no_repeate' => date("Y-m-d"), 'add_show_end_date_no_repeate' => date("Y-m-d"),