Merge branch 'master' of dev.sourcefabric.org:airtime

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:15 -04:00
commit 03ab7edea0
11 changed files with 100 additions and 57 deletions

View File

@ -652,6 +652,11 @@ class ScheduleController extends Zend_Controller_Action
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
}
else {
//the form still needs to be "update" since
//the validity test failed.
if ($data['add_show_id'] != -1){
$this->view->addNewShow = false;
}
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
}

View File

@ -536,24 +536,26 @@ class Show {
//repeat option was toggled or show is recorded.
$p_show->deleteAllInstances();
}
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
//start date/time has changed
$newDate = strtotime($p_data['add_show_start_date']);
$oldDate = strtotime($p_show->getStartDate());
if ($newDate > $oldDate){
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
}
$p_show->updateStartDateTime($p_data, $p_endDate);
}
if ($p_data['add_show_duration'] != $p_show->getDuration()){
//duration has changed
$p_show->updateDurationTime($p_data);
}
if ($p_data['add_show_repeats']){
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
//start date/time has changed
$newDate = strtotime($p_data['add_show_start_date']);
$oldDate = strtotime($p_show->getStartDate());
if ($newDate > $oldDate){
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
}
$p_show->updateStartDateTime($p_data, $p_endDate);
}
if ($repeatType != $p_show->getRepeatType()){
//repeat type changed.
$p_show->deleteAllInstances();
@ -863,21 +865,26 @@ class Show {
$show = new Show($show_id);
if ($show->hasInstance()){
$showInstance = $show->getInstance();
$ccShowInstance = $show->getInstance();
$newInstance = false;
} else {
$showInstance = new CcShowInstances();
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
$showInstance->setDbShowId($show_id);
$showInstance->setDbStarts($start);
$showInstance->setDbEnds($end);
$showInstance->setDbRecord($record);
$showInstance->save();
//$show->addInstance($showInstance);
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($start);
$ccShowInstance->setDbEnds($end);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
$show_instance_id = $showInstance->getDbId();
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql);
@ -929,19 +936,24 @@ class Show {
$end = $CC_DBC->GetOne($sql);
if ($show->hasInstanceOnDate($start)){
$showInstance = $show->getInstanceOnDate($start);
$ccShowInstance = $show->getInstanceOnDate($start);
$newInstance = false;
} else {
$showInstance = new CcShowInstances();
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}
$showInstance->setDbShowId($show_id);
$showInstance->setDbStarts($start);
$showInstance->setDbEnds($end);
$showInstance->setDbRecord($record);
$showInstance->save();
//$show->addInstance($showInstance);
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($start);
$ccShowInstance->setDbEnds($end);
$ccShowInstance->setDbRecord($record);
$ccShowInstance->save();
$show_instance_id = $showInstance->getDbId();
$show_instance_id = $ccShowInstance->getDbId();
$showInstance = new ShowInstance($show_instance_id);
if (!$newInstance){
$showInstance->correctScheduleStartTimes();
}
foreach($rebroadcasts as $rebroadcast) {
@ -1292,16 +1304,32 @@ class ShowInstance {
$showInstance->updateDbTimeFilled($con);
}
public function moveScheduledShowContent($deltaDay, $deltaHours, $deltaMin)
{
public function correctScheduleStartTimes(){
global $CC_DBC;
$instance_id = $this->getShowInstanceId();
$sql = "SELECT starts from cc_schedule"
." WHERE instance_id = $instance_id"
." ORDER BY starts"
." LIMIT 1";
$sql = "UPDATE cc_schedule
SET starts = (starts + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}'),
ends = (ends + interval '{$deltaDay} days' + interval '{$deltaHours}:{$deltaMin}')
WHERE instance_id = '{$this->_instanceId}'";
$scheduleStarts = $CC_DBC->GetOne($sql);
if (!is_null($scheduleStarts)){
$scheduleStartsEpoch = strtotime($scheduleStarts);
$showStartsEpoch = strtotime($this->getShowStart());
$CC_DBC->query($sql);
$diff = $showStartsEpoch - $scheduleStartsEpoch;
if ($diff != 0){
$sql = "UPDATE cc_schedule"
." SET starts = starts + INTERVAL '$diff' second,"
." ends = ends + INTERVAL '$diff' second"
." WHERE instance_id = $instance_id";
$CC_DBC->query($sql);
}
}
RabbitMq::PushSchedule();
}
@ -1347,9 +1375,9 @@ class ShowInstance {
}
}
$this->moveScheduledShowContent($deltaDay, $hours, $mins);
$this->setShowStart($new_starts);
$this->setShowEnd($new_ends);
$this->correctScheduleStartTimes();
RabbitMq::PushSchedule();
}

View File

@ -10,12 +10,15 @@ function scheduleRefetchEvents() {
function openAddShowForm() {
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none')) {
$("#add-show-form").show();
var y = $("#schedule_calendar").width();
var z = $("#schedule-add-show").width();
$("#schedule_calendar").width(y-z-50);
$("#schedule_calendar").fullCalendar('render');
if($("#add-show-form").length == 1) {
if( ($("#add-show-form").css('display')=='none')) {
$("#add-show-form").show();
var y = $("#schedule_calendar").width();
var z = $("#schedule-add-show").width();
$("#schedule_calendar").width(y-z-50);
$("#schedule_calendar").fullCalendar('render');
}
$("#schedule-show-what").show();
}
}

View File

@ -1,2 +1,2 @@
#!/bin/sh
exec setuidgid pypo multilog t ./main
exec setuidgid pypo multilog t /var/log/airtime/pypo/main

View File

@ -72,9 +72,13 @@ try:
create_user("pypo")
print "Creating log directories"
create_path("/var/log/pypo")
os.system("chmod -R 755 /var/log/pypo")
os.system("chown -R pypo:pypo /var/log/pypo")
create_path("/var/log/airtime/pypo")
os.system("chmod -R 755 /var/log/airtime/pypo")
os.system("chown -R pypo:pypo /var/log/airtime/pypo")
create_path("/var/log/airtime/pypo-liquidsoap")
os.system("chmod -R 755 /var/log/airtime/pypo-liquidsoap")
os.system("chown -R pypo:pypo /var/log/airtime/pypo-liquidsoap")
create_path(BASE_PATH)
create_path(BASE_PATH+"bin")
@ -112,7 +116,7 @@ try:
create_path("/etc/service/pypo-liquidsoap")
create_path("/etc/service/pypo-liquidsoap/log")
shutil.copy("%s/pypo-daemontools-liquidsoap.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/run")
shutil.copy("%s/pypo-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/log/run")
shutil.copy("%s/pypo-liquidsoap-daemontools-logger.sh"%current_script_dir, "/etc/service/pypo-liquidsoap/log/run")
os.system("chmod -R 755 /etc/service/pypo-liquidsoap")
os.system("chown -R pypo:pypo /etc/service/pypo-liquidsoap")

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec setuidgid pypo multilog t /var/log/airtime/pypo-liquidsoap/main

View File

@ -32,7 +32,8 @@ try:
os.system("python %s/pypo-stop.py" % get_current_script_dir())
print "Removing log directories"
remove_path("/var/log/pypo")
remove_path("/var/log/airtime/pypo")
remove_path("/var/log/airtime/pypo-liquidsoap")
print "Removing pypo files"
remove_path(BASE_PATH)

View File

@ -7,7 +7,7 @@
# general settings #
###########################################
log_file = "/var/log/pypo/<script>.log"
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
log_level = 3
###########################################

View File

@ -1,2 +1,2 @@
#!/bin/sh
exec setuidgid pypo multilog t ./main
exec setuidgid pypo multilog t /var/log/airtime/recorder/main

View File

@ -80,9 +80,9 @@ try:
os.system("chown -R pypo:pypo /home/pypo/Music")
print "Creating log directories"
create_path("/var/log/recorder")
os.system("chmod -R 755 /var/log/recorder")
os.system("chown -R pypo:pypo /var/log/recorder")
create_path("/var/log/airtime/recorder")
os.system("chmod -R 755 /var/log/airtime/recorder")
os.system("chown -R pypo:pypo /var/log/airtime/recorder")
create_path(BASE_PATH)
create_path(BASE_PATH+"bin")

View File

@ -32,7 +32,7 @@ try:
os.system("python %s/recorder-stop.py" % get_current_script_dir())
print "Removing log directories"
remove_path("/var/log/recorder")
remove_path("/var/log/airtime/recorder")
print "Removing recorder files"
remove_path(BASE_PATH)