CC-3036: Deleted Show instances reappear

-done.
This commit is contained in:
Martin Konecny 2011-11-14 22:37:34 -05:00
parent 2fc46cd29b
commit e3395ae1e5
11 changed files with 155 additions and 32 deletions

View file

@ -1176,7 +1176,7 @@ class Application_Model_Show {
}
$sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description,
color, background_color, file_id, cc_show_instances.id AS instance_id
color, background_color, file_id, deleted_instance, cc_show_instances.id AS instance_id
FROM cc_show_instances
LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id";
@ -1275,20 +1275,22 @@ class Application_Model_Show {
$today_timestamp = date("Y-m-d H:i:s");
foreach ($shows as $show) {
$options = array();
//only bother calculating percent for week or day view.
if(intval($days) <= 7) {
$show_instance = new Application_Model_ShowInstance($show["instance_id"]);
$options["percent"] = $show_instance->getPercentScheduled();
}
if ($show["deleted_instance"] != "t"){
$options = array();
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
$options["editable"] = true;
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
}
else {
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
//only bother calculating percent for week or day view.
if(intval($days) <= 7) {
$show_instance = new Application_Model_ShowInstance($show["instance_id"]);
$options["percent"] = $show_instance->getPercentScheduled();
}
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
$options["editable"] = true;
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
} else {
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
}
}
}
@ -1317,6 +1319,7 @@ class Application_Model_Show {
$event["description"] = $show["description"];
$event["showId"] = $show["show_id"];
$event["record"] = intval($show["record"]);
$event["deleted_instance"] = $show["deleted_instance"];
$event["rebroadcast"] = intval($show["rebroadcast"]);
// get soundcloud_id

View file

@ -136,6 +136,11 @@ class Application_Model_ShowInstance {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
$this->_showInstance->updateDbTimeFilled($con);
}
public function isDeleted()
{
$this->_showInstance->getDbDeletedInstance();
}
public function correctScheduleStartTimes(){
global $CC_DBC;
@ -392,16 +397,23 @@ class Application_Model_ShowInstance {
CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->delete();
->setDbDeletedInstance(true)
->save();
// check if we can safely delete the show
$showInstancesRow = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbDeletedInstance(false)
->findOne();
/* If we didn't find any instances of the show that haven't
* been deleted, then just erase everything related to that show.
* We can just delete, the show and the foreign key-constraint should
* take care of deleting all of its instances. */
if(is_null($showInstancesRow)){
$sql = "DELETE FROM cc_show WHERE id = '$showId'";
$CC_DBC->query($sql);
CcShowQuery::create()
->filterByDbId($showId)
->delete();
}
Application_Model_RabbitMq::PushSchedule();

View file

@ -47,6 +47,7 @@ class CcShowInstancesTableMap extends TableMap {
$this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
$this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null);
$this->addColumn('TIME_FILLED', 'DbTimeFilled', 'TIME', false, null, null);
$this->addColumn('DELETED_INSTANCE', 'DbDeletedInstance', 'BOOLEAN', true, null, false);
// validators
} // initialize()

View file

@ -80,6 +80,13 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/
protected $time_filled;
/**
* The value for the deleted_instance field.
* Note: this column has a database default value of: false
* @var boolean
*/
protected $deleted_instance;
/**
* @var CcShow
*/
@ -129,6 +136,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
{
$this->record = 0;
$this->rebroadcast = 0;
$this->deleted_instance = false;
}
/**
@ -300,6 +308,16 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
}
}
/**
* Get the [deleted_instance] column value.
*
* @return boolean
*/
public function getDbDeletedInstance()
{
return $this->deleted_instance;
}
/**
* Set the value of [id] column.
*
@ -579,6 +597,26 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this;
} // setDbTimeFilled()
/**
* Set the value of [deleted_instance] column.
*
* @param boolean $v new value
* @return CcShowInstances The current object (for fluent API support)
*/
public function setDbDeletedInstance($v)
{
if ($v !== null) {
$v = (boolean) $v;
}
if ($this->deleted_instance !== $v || $this->isNew()) {
$this->deleted_instance = $v;
$this->modifiedColumns[] = CcShowInstancesPeer::DELETED_INSTANCE;
}
return $this;
} // setDbDeletedInstance()
/**
* Indicates whether the columns in this object are only set to default values.
*
@ -597,6 +635,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return false;
}
if ($this->deleted_instance !== false) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@ -628,6 +670,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->deleted_instance = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null;
$this->resetModified();
$this->setNew(false);
@ -636,7 +679,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 9; // 9 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 10; // 10 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShowInstances object", $e);
@ -1060,6 +1103,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
case 8:
return $this->getDbTimeFilled();
break;
case 9:
return $this->getDbDeletedInstance();
break;
default:
return null;
break;
@ -1093,6 +1139,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$keys[6] => $this->getDbOriginalShow(),
$keys[7] => $this->getDbRecordedFile(),
$keys[8] => $this->getDbTimeFilled(),
$keys[9] => $this->getDbDeletedInstance(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcShow) {
@ -1162,6 +1209,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
case 8:
$this->setDbTimeFilled($value);
break;
case 9:
$this->setDbDeletedInstance($value);
break;
} // switch()
}
@ -1195,6 +1245,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbDeletedInstance($arr[$keys[9]]);
}
/**
@ -1215,6 +1266,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id);
if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id);
if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled);
if ($this->isColumnModified(CcShowInstancesPeer::DELETED_INSTANCE)) $criteria->add(CcShowInstancesPeer::DELETED_INSTANCE, $this->deleted_instance);
return $criteria;
}
@ -1284,6 +1336,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$copyObj->setDbOriginalShow($this->instance_id);
$copyObj->setDbRecordedFile($this->file_id);
$copyObj->setDbTimeFilled($this->time_filled);
$copyObj->setDbDeletedInstance($this->deleted_instance);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@ -1801,6 +1854,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->instance_id = null;
$this->file_id = null;
$this->time_filled = null;
$this->deleted_instance = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer {
const TM_CLASS = 'CcShowInstancesTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 9;
const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -58,6 +58,9 @@ abstract class BaseCcShowInstancesPeer {
/** the column name for the TIME_FILLED field */
const TIME_FILLED = 'cc_show_instances.TIME_FILLED';
/** the column name for the DELETED_INSTANCE field */
const DELETED_INSTANCE = 'cc_show_instances.DELETED_INSTANCE';
/**
* An identiy map to hold any loaded instances of CcShowInstances objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@ -74,12 +77,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbDeletedInstance', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbDeletedInstance', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::DELETED_INSTANCE, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'DELETED_INSTANCE', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'deleted_instance', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@ -89,12 +92,12 @@ abstract class BaseCcShowInstancesPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbDeletedInstance' => 9, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbDeletedInstance' => 9, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::DELETED_INSTANCE => 9, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'DELETED_INSTANCE' => 9, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'deleted_instance' => 9, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@ -175,6 +178,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID);
$criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED);
$criteria->addSelectColumn(CcShowInstancesPeer::DELETED_INSTANCE);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.STARTS');
@ -185,6 +189,7 @@ abstract class BaseCcShowInstancesPeer {
$criteria->addSelectColumn($alias . '.INSTANCE_ID');
$criteria->addSelectColumn($alias . '.FILE_ID');
$criteria->addSelectColumn($alias . '.TIME_FILLED');
$criteria->addSelectColumn($alias . '.DELETED_INSTANCE');
}
}

View file

@ -15,6 +15,7 @@
* @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column
* @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column
* @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column
* @method CcShowInstancesQuery orderByDbDeletedInstance($order = Criteria::ASC) Order by the deleted_instance column
*
* @method CcShowInstancesQuery groupByDbId() Group by the id column
* @method CcShowInstancesQuery groupByDbStarts() Group by the starts column
@ -25,6 +26,7 @@
* @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column
* @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column
* @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column
* @method CcShowInstancesQuery groupByDbDeletedInstance() Group by the deleted_instance column
*
* @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowInstancesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -62,6 +64,7 @@
* @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column
* @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column
* @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column
* @method CcShowInstances findOneByDbDeletedInstance(boolean $deleted_instance) Return the first CcShowInstances filtered by the deleted_instance column
*
* @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column
* @method array findByDbStarts(string $starts) Return CcShowInstances objects filtered by the starts column
@ -72,6 +75,7 @@
* @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column
* @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column
* @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column
* @method array findByDbDeletedInstance(boolean $deleted_instance) Return CcShowInstances objects filtered by the deleted_instance column
*
* @package propel.generator.airtime.om
*/
@ -446,6 +450,23 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison);
}
/**
* Filter the query on the deleted_instance column
*
* @param boolean|string $dbDeletedInstance The value to use as filter.
* Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByDbDeletedInstance($dbDeletedInstance = null, $comparison = null)
{
if (is_string($dbDeletedInstance)) {
$deleted_instance = in_array(strtolower($dbDeletedInstance), array('false', 'off', '-', 'no', 'n', '0')) ? false : true;
}
return $this->addUsingAlias(CcShowInstancesPeer::DELETED_INSTANCE, $dbDeletedInstance, $comparison);
}
/**
* Filter the query by a related CcShow object
*