can add a show repeating or non repeating. need a better dialog though with more validation. Also added additional sql files to build directory.

This commit is contained in:
naomiaro 2010-12-08 00:47:51 -05:00
parent 184ee30775
commit ac27a2f79c
20 changed files with 267 additions and 29 deletions

View file

@ -53,6 +53,7 @@
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
<actionMethod actionName="eventFeed"/> <actionMethod actionName="eventFeed"/>
<actionMethod actionName="addShowDialog"/> <actionMethod actionName="addShowDialog"/>
<actionMethod actionName="addShow"/>
</controllerFile> </controllerFile>
</controllersDirectory> </controllersDirectory>
<formsDirectory> <formsDirectory>
@ -166,6 +167,9 @@
<viewControllerScriptsDirectory forControllerName="Schedule"> <viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="addShowDialog"/> <viewScriptFile forActionName="addShowDialog"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="addShow"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -1,6 +1,6 @@
<?php <?php
// This file generated by Propel 1.5.2 convert-conf target // This file generated by Propel 1.5.2 convert-conf target
// from XML runtime conf file /home/naomiaro/campcaster-refactor/campcaster/build/runtime-conf.xml // from XML runtime conf file /home/naomiaro/dev-campcaster/campcaster/build/runtime-conf.xml
$conf = array ( $conf = array (
'datasources' => 'datasources' =>
array ( array (

View file

@ -13,6 +13,7 @@ class ScheduleController extends Zend_Controller_Action
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('event-feed', 'json') $ajaxContext->addActionContext('event-feed', 'json')
->addActionContext('add-show-dialog', 'json') ->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json')
->initContext(); ->initContext();
} }
@ -39,11 +40,38 @@ class ScheduleController extends Zend_Controller_Action
public function addShowDialogAction() public function addShowDialogAction()
{ {
$user = new User(); $user = new User();
$this->view->hosts = $user->getHosts(); $this->view->hosts = $user->getHosts();
} }
public function addShowAction()
{
//name, description, hosts, allDay, repeats,
//start_time, duration, start_date, end_date, dofw
$name = $this->_getParam('name', 'Default Name');
$description = $this->_getParam('description', '');
$hosts = $this->_getParam('hosts');
$allDay = $this->_getParam('all_day', false);
$repeats = $this->_getParam('repeats', false);
$startTime = $this->_getParam('start_time');
$duration = $this->_getParam('duration');
$startDate = $this->_getParam('start_date');
$endDate = $this->_getParam('end_date', null);
$dofw = $this->_getParam('dofw');
if($repeats === false)
$endDate = $startDate;
$repeats = $repeats ? 1 : 0;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type);
$show->addShow($name, $startDate, $endDate, $startTime, $duration, $repeats, $dofw, $description);
}
} }
@ -51,3 +79,5 @@ class ScheduleController extends Zend_Controller_Action

View file

@ -35,12 +35,51 @@ class Show {
return $event; return $event;
} }
public function addShow() { public function addShow($name, $startDate, $endDate, $startTime, $duration, $repeats, $days, $description) {
$sql = 'INSERT INTO cc_show $con = Propel::getConnection("campcaster");
("name", "first_show", "last_show", "start_time", "end_time",
"repeats", "day", "description", "show_id") $sql = "SELECT time '{$startTime}' + INTERVAL '{$duration} hour' ";
VALUES ()'; $r = $con->query($sql);
$endTime = $r->fetchColumn(0);
$sql = "SELECT nextval('schedule_group_id_seq')";
$r = $con->query($sql);
$showId = $r->fetchColumn(0);
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$startDate} {$startTime}')";
$r = $con->query($sql);
$startDow = $r->fetchColumn(0);
foreach ($days as $day) {
if($startDow !== $day){
if($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
$sql = "SELECT date '{$startDate}' + INTERVAL '{$daysAdd} day' ";
$r = $con->query($sql);
$start = $r->fetchColumn(0);
}
else {
$start = $startDate;
}
$show = new CcShow();
$show->setDbName($name);
$show->setDbFirstShow($start);
$show->setDbLastShow($endDate);
$show->setDbStartTime($startTime);
$show->setDbEndTime($endTime);
$show->setDbRepeats($repeats);
$show->setDbDay($day);
$show->setDbDescription($description);
$show->setDbShowId($showId);
$show->save();
}
} }

View file

@ -47,6 +47,7 @@ class CcShowTableMap extends TableMap {
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null); $this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null); $this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('SHOW_ID', 'DbShowId', 'INTEGER', true, null, null);
// validators // validators
} // initialize() } // initialize()

View file

@ -35,7 +35,8 @@ class CcSubjsTableMap extends TableMap {
$this->setPhpName('CcSubjs'); $this->setPhpName('CcSubjs');
$this->setClassname('CcSubjs'); $this->setClassname('CcSubjs');
$this->setPackage('campcaster'); $this->setPackage('campcaster');
$this->setUseIdGenerator(false); $this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_subjs_id_seq');
// columns // columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, ''); $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');

View file

@ -79,6 +79,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/ */
protected $description; protected $description;
/**
* The value for the show_id field.
* @var int
*/
protected $show_id;
/** /**
* Flag to prevent endless save loop, if this object is referenced * Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction. * by another object which falls in this transaction.
@ -296,6 +302,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->description; return $this->description;
} }
/**
* Get the [show_id] column value.
*
* @return int
*/
public function getDbShowId()
{
return $this->show_id;
}
/** /**
* Set the value of [id] column. * Set the value of [id] column.
* *
@ -592,6 +608,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this; return $this;
} // setDbDescription() } // setDbDescription()
/**
* Set the value of [show_id] column.
*
* @param int $v new value
* @return CcShow The current object (for fluent API support)
*/
public function setDbShowId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->show_id !== $v) {
$this->show_id = $v;
$this->modifiedColumns[] = CcShowPeer::SHOW_ID;
}
return $this;
} // setDbShowId()
/** /**
* Indicates whether the columns in this object are only set to default values. * Indicates whether the columns in this object are only set to default values.
* *
@ -637,6 +673,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; $this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
$this->resetModified(); $this->resetModified();
$this->setNew(false); $this->setNew(false);
@ -645,7 +682,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->ensureConsistency(); $this->ensureConsistency();
} }
return $startcol + 9; // 9 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS). return $startcol + 10; // 10 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating CcShow object", $e); throw new PropelException("Error populating CcShow object", $e);
@ -971,6 +1008,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8: case 8:
return $this->getDbDescription(); return $this->getDbDescription();
break; break;
case 9:
return $this->getDbShowId();
break;
default: default:
return null; return null;
break; break;
@ -1003,6 +1043,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$keys[6] => $this->getDbRepeats(), $keys[6] => $this->getDbRepeats(),
$keys[7] => $this->getDbDay(), $keys[7] => $this->getDbDay(),
$keys[8] => $this->getDbDescription(), $keys[8] => $this->getDbDescription(),
$keys[9] => $this->getDbShowId(),
); );
return $result; return $result;
} }
@ -1061,6 +1102,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8: case 8:
$this->setDbDescription($value); $this->setDbDescription($value);
break; break;
case 9:
$this->setDbShowId($value);
break;
} // switch() } // switch()
} }
@ -1094,6 +1138,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]); if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]); if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]); if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]);
} }
/** /**
@ -1114,6 +1159,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats); if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day); if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day);
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcShowPeer::SHOW_ID)) $criteria->add(CcShowPeer::SHOW_ID, $this->show_id);
return $criteria; return $criteria;
} }
@ -1183,6 +1229,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$copyObj->setDbRepeats($this->repeats); $copyObj->setDbRepeats($this->repeats);
$copyObj->setDbDay($this->day); $copyObj->setDbDay($this->day);
$copyObj->setDbDescription($this->description); $copyObj->setDbDescription($this->description);
$copyObj->setDbShowId($this->show_id);
$copyObj->setNew(true); $copyObj->setNew(true);
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
@ -1240,6 +1287,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->repeats = null; $this->repeats = null;
$this->day = null; $this->day = null;
$this->description = null; $this->description = null;
$this->show_id = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->alreadyInValidation = false; $this->alreadyInValidation = false;
$this->clearAllReferences(); $this->clearAllReferences();

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
const TM_CLASS = 'CcShowTableMap'; const TM_CLASS = 'CcShowTableMap';
/** The total number of columns. */ /** The total number of columns. */
const NUM_COLUMNS = 9; const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */ /** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0; const NUM_LAZY_LOAD_COLUMNS = 0;
@ -58,6 +58,9 @@ abstract class BaseCcShowPeer {
/** the column name for the DESCRIPTION field */ /** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_show.DESCRIPTION'; const DESCRIPTION = 'cc_show.DESCRIPTION';
/** the column name for the SHOW_ID field */
const SHOW_ID = 'cc_show.SHOW_ID';
/** /**
* An identiy map to hold any loaded instances of CcShow objects. * An identiy map to hold any loaded instances of CcShow objects.
* This must be public so that other peer classes can access this when hydrating from JOIN * This must be public so that other peer classes can access this when hydrating from JOIN
@ -74,12 +77,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
private static $fieldNames = array ( private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ), BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', 'DbShowId', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', 'dbShowId', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, ), BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, self::SHOW_ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', ), BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', 'SHOW_ID', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', ), BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', 'show_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
); );
/** /**
@ -89,12 +92,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/ */
private static $fieldKeys = array ( private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, ), BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, 'DbShowId' => 9, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, 'dbShowId' => 9, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, ), BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, self::SHOW_ID => 9, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, ), BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, 'SHOW_ID' => 9, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, ), BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, 'show_id' => 9, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
); );
/** /**
@ -175,6 +178,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn(CcShowPeer::REPEATS); $criteria->addSelectColumn(CcShowPeer::REPEATS);
$criteria->addSelectColumn(CcShowPeer::DAY); $criteria->addSelectColumn(CcShowPeer::DAY);
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION); $criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
$criteria->addSelectColumn(CcShowPeer::SHOW_ID);
} else { } else {
$criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.NAME');
@ -185,6 +189,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn($alias . '.REPEATS'); $criteria->addSelectColumn($alias . '.REPEATS');
$criteria->addSelectColumn($alias . '.DAY'); $criteria->addSelectColumn($alias . '.DAY');
$criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.SHOW_ID');
} }
} }

View file

@ -15,6 +15,7 @@
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column * @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
* @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day column * @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day column
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column * @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcShowQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
* *
* @method CcShowQuery groupByDbId() Group by the id column * @method CcShowQuery groupByDbId() Group by the id column
* @method CcShowQuery groupByDbName() Group by the name column * @method CcShowQuery groupByDbName() Group by the name column
@ -25,6 +26,7 @@
* @method CcShowQuery groupByDbRepeats() Group by the repeats column * @method CcShowQuery groupByDbRepeats() Group by the repeats column
* @method CcShowQuery groupByDbDay() Group by the day column * @method CcShowQuery groupByDbDay() Group by the day column
* @method CcShowQuery groupByDbDescription() Group by the description column * @method CcShowQuery groupByDbDescription() Group by the description column
* @method CcShowQuery groupByDbShowId() Group by the show_id column
* *
* @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -42,6 +44,7 @@
* @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column * @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column
* @method CcShow findOneByDbDay(int $day) Return the first CcShow filtered by the day column * @method CcShow findOneByDbDay(int $day) Return the first CcShow filtered by the day column
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column * @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
* @method CcShow findOneByDbShowId(int $show_id) Return the first CcShow filtered by the show_id column
* *
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column * @method array findByDbId(int $id) Return CcShow objects filtered by the id column
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column * @method array findByDbName(string $name) Return CcShow objects filtered by the name column
@ -52,6 +55,7 @@
* @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column * @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column
* @method array findByDbDay(int $day) Return CcShow objects filtered by the day column * @method array findByDbDay(int $day) Return CcShow objects filtered by the day column
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column * @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
* @method array findByDbShowId(int $show_id) Return CcShow objects filtered by the show_id column
* *
* @package propel.generator.campcaster.om * @package propel.generator.campcaster.om
*/ */
@ -408,6 +412,37 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison); return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison);
} }
/**
* Filter the query on the show_id column
*
* @param int|array $dbShowId The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowQuery The current query, for fluid interface
*/
public function filterByDbShowId($dbShowId = null, $comparison = null)
{
if (is_array($dbShowId)) {
$useMinMax = false;
if (isset($dbShowId['min'])) {
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbShowId['max'])) {
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId, $comparison);
}
/** /**
* Exclude object from result * Exclude object from result
* *

View file

@ -699,13 +699,21 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
if (!$this->alreadyInSave) { if (!$this->alreadyInSave) {
$this->alreadyInSave = true; $this->alreadyInSave = true;
if ($this->isNew() ) {
$this->modifiedColumns[] = CcSubjsPeer::ID;
}
// If this object has been modified, then save it to the database. // If this object has been modified, then save it to the database.
if ($this->isModified()) { if ($this->isModified()) {
if ($this->isNew()) { if ($this->isNew()) {
$criteria = $this->buildCriteria(); $criteria = $this->buildCriteria();
if ($criteria->keyContainsValue(CcSubjsPeer::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
}
$pk = BasePeer::doInsert($criteria, $con); $pk = BasePeer::doInsert($criteria, $con);
$affectedRows = 1; $affectedRows = 1;
$this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false); $this->setNew(false);
} else { } else {
$affectedRows = CcSubjsPeer::doUpdate($this, $con); $affectedRows = CcSubjsPeer::doUpdate($this, $con);
@ -1127,7 +1135,6 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
*/ */
public function copyInto($copyObj, $deepCopy = false) public function copyInto($copyObj, $deepCopy = false)
{ {
$copyObj->setId($this->id);
$copyObj->setLogin($this->login); $copyObj->setLogin($this->login);
$copyObj->setPass($this->pass); $copyObj->setPass($this->pass);
$copyObj->setType($this->type); $copyObj->setType($this->type);
@ -1180,6 +1187,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
$copyObj->setNew(true); $copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
} }
/** /**

View file

@ -529,6 +529,10 @@ abstract class BaseCcSubjsPeer {
$criteria = $values->buildCriteria(); // build Criteria from CcSubjs object $criteria = $values->buildCriteria(); // build Criteria from CcSubjs object
} }
if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
}
// Set the correct dbName // Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME); $criteria->setDbName(self::DATABASE_NAME);

View file

@ -0,0 +1 @@
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>addShow</b></center>

View file

@ -1,4 +1,4 @@
project.home = /home/naomiaro/campcaster-refactor/campcaster project.home = /home/naomiaro/dev-campcaster/campcaster
project.build = ${project.home}/build project.build = ${project.home}/build
#Database driver #Database driver

View file

@ -0,0 +1 @@
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));

View file

@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
"repeats" INT2 NOT NULL, "repeats" INT2 NOT NULL,
"day" INT2 NOT NULL, "day" INT2 NOT NULL,
"description" VARCHAR(512), "description" VARCHAR(512),
"show_id" INTEGER NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
CREATE TABLE "cc_subjs" CREATE TABLE "cc_subjs"
( (
"id" INTEGER NOT NULL, "id" serial NOT NULL,
"login" VARCHAR(255) default '' NOT NULL, "login" VARCHAR(255) default '' NOT NULL,
"pass" VARCHAR(255) default '' NOT NULL, "pass" VARCHAR(255) default '' NOT NULL,
"type" CHAR(1) default 'U' NOT NULL, "type" CHAR(1) default 'U' NOT NULL,

7
build/sql/sequences.sql Normal file
View file

@ -0,0 +1,7 @@
DROP SEQUENCE schedule_group_id_seq CASCADE;
CREATE SEQUENCE schedule_group_id_seq;
DROP SEQUENCE show_group_id_seq CASCADE;
CREATE SEQUENCE show_group_id_seq;

View file

@ -1,2 +1,6 @@
# Sqlfile -> Database map # Sqlfile -> Database map
schema.sql=campcaster schema.sql=campcaster
sequences.sql=campcaster
views.sql=campcaster
triggers.sql=campcaster
defaultdata.sql=campcaster

23
build/sql/triggers.sql Normal file
View file

@ -0,0 +1,23 @@
----------------------------------------------------------------------------------
--calculate_position()
----------------------------------------------------------------------------------
DROP FUNCTION calculate_position() CASCADE;
CREATE FUNCTION calculate_position() RETURNS trigger AS
'
BEGIN
IF(TG_OP=''INSERT'') THEN
UPDATE cc_playlistcontents SET position = (position + 1)
WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
END IF;
IF(TG_OP=''DELETE'') THEN
UPDATE cc_playlistcontents SET position = (position - 1)
WHERE (playlist_id = old.playlist_id AND position > old.position);
END IF;
RETURN NULL;
END;
'
LANGUAGE 'plpgsql';
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
FOR EACH ROW EXECUTE PROCEDURE calculate_position();

11
build/sql/views.sql Normal file
View file

@ -0,0 +1,11 @@
-------------------------------------------------------
---cc_playlisttimes
-------------------------------------------------------
CREATE VIEW cc_playlisttimes AS
SELECT pl.id, COALESCE(t.length, '00:00:00'::time without time zone) AS length
FROM cc_playlist pl
LEFT JOIN ( SELECT cc_playlistcontents.playlist_id AS id,
sum(cc_playlistcontents.cliplength::interval)::time without time zone AS length
FROM cc_playlistcontents
GROUP BY cc_playlistcontents.playlist_id) t ON pl.id = t.id;

View file

@ -60,13 +60,13 @@ function createDateInput(name, label) {
} }
function submitShow() { function submitShow() {
var name, description, hosts, allDay, repeats, var name, description, hosts, all_day, repeats,
start_time, duration, start_date, end_date, dofw; start_time, duration, start_date, end_date, dofw;
name = $("#schedule_dialog_name").val(); name = $("#schedule_dialog_name").val();
description = $("#schedule_dialog_description").val(); description = $("#schedule_dialog_description").val();
hosts = $("#schedule_dialog_hosts").val(); hosts = $("#schedule_dialog_hosts").val();
allDay = $("#schedule_dialog_all_day").attr("checked"); all_day = $("#schedule_dialog_all_day").attr("checked");
repeats = $("#schedule_dialog_repeats").attr("checked"); repeats = $("#schedule_dialog_repeats").attr("checked");
start_time = $("#schedule_dialog_start_time").val(); start_time = $("#schedule_dialog_start_time").val();
duration = $("#schedule_dialog_duration").val(); duration = $("#schedule_dialog_duration").val();
@ -76,6 +76,21 @@ function submitShow() {
return $(this).val(); return $(this).val();
}).get(); }).get();
if(dofw.length === 0) {
var time, date;
time = start_date.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
dofw.push(date.getDay());
}
$.post("/Schedule/add-show/format/json",
{ name: name, description: description, hosts: hosts, all_day: all_day, repeats: repeats,
start_time: start_time, duration: duration, start_date: start_date, end_date: end_date, dofw: dofw },
function(data){
$('#schedule_calendar').fullCalendar( 'refetchEvents' );
});
$(this).remove(); $(this).remove();
} }