4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 13:16:37 +00:00

Create Convention admin page, general admin cleanup, add API import for conventions.

This commit is contained in:
Buster Neece 2014-07-19 07:53:00 -05:00
parent a3a26fad31
commit 95b32a7b58
9 changed files with 283 additions and 12 deletions

3
.gitignore vendored
View File

@ -29,6 +29,7 @@ web/static/stations/*
web/static/podcasts/*
web/static/rotators/*
web/static/songs/*
web/static/conventions/*
# Log files.
util/php_errors.log
@ -252,4 +253,4 @@ pip-log.txt
*.mo
#Mr Developer
.mr.developer.cfg
.mr.developer.cfg

View File

@ -13,7 +13,11 @@ class Convention extends \DF\Doctrine\Entity
{
public function __construct()
{
$this->coverage_level = 'full';
$this->signup_enabled = true;
$this->archives = new ArrayCollection();
$this->signups = new ArrayCollection();
}
/**
@ -23,12 +27,15 @@ class Convention extends \DF\Doctrine\Entity
*/
protected $id;
/** @Column(name="name", type="string", length=400, nullable=true) */
/** @Column(name="name", type="string", length=400) */
protected $name;
/** @Column(name="location", type="string", length=400, nullable=true) */
protected $location;
/** @Column(name="coverage_level", type="string", length=50) */
protected $coverage_level;
/** @Column(name="start_date", type="date") */
protected $start_date;
@ -53,6 +60,8 @@ class Convention extends \DF\Doctrine\Entity
if ($this->image_url && $this->image_url != $new_url)
@unlink(DF_UPLOAD_FOLDER.DIRECTORY_SEPARATOR.$this->image_url);
echo $new_url;
$new_path = DF_UPLOAD_FOLDER.DIRECTORY_SEPARATOR.$new_url;
\DF\Image::resizeImage($new_path, $new_path, 1150, 200);
@ -69,6 +78,16 @@ class Convention extends \DF\Doctrine\Entity
/** @Column(name="signup_enabled", type="boolean") */
protected $signup_enabled;
/**
* @OneToMany(targetEntity="ConventionSignup", mappedBy="convention")
*/
protected $signups;
/**
* @OneToMany(targetEntity="ConventionArchive", mappedBy="convention")
*/
protected $archives;
/**
* Static Functions
*/
@ -91,6 +110,39 @@ class Convention extends \DF\Doctrine\Entity
public static function getConventionsWithArchives()
{
$em = self::getEntityManager();
$conventions = $em->createQuery('SELECT c FROM '.__CLASS__.' c LEFT JOIN c.archives ca WHERE ca.id IS NOT NULL AND (c.start_date <= :now) ORDER BY c.start_date DESC')
->setParameter('now', gmdate('Y-m-d', time()))
->useResultCache(true, 1800, 'pvl_archived_conventions')
->getArrayResult();
return $conventions;
}
public static function getCoverageLevels()
{
return array(
'streaming' => array(
'text' => 'PVL Full Streaming & Coverage',
'icon' => 'icon-globe',
'short' => '@',
),
'full' => array(
'text' => 'PVL Full Recorded Coverage',
'icon' => 'icon-star',
'short' => '*',
),
'partial' => array(
'text' => 'PVL Partial Recorded Coverage',
'icon' => 'icon-star-half-full',
'short' => '+',
),
'none' => array(
'text' => 'No Coverage',
'icon' => 'icon-flag',
'short' => '!',
),
);
}
}

View File

@ -0,0 +1,80 @@
<?php
$coverage_options_raw = \Entity\Convention::getCoverageLevels();
$coverage_options = array();
foreach($coverage_options_raw as $c_key => $c_opt)
{
$coverage_options[$c_key] = '&nbsp;<i class="'.$c_opt['icon'].'"></i> '.$c_opt['text'];
}
return array(
'method' => 'post',
'enctype' => 'multipart/form-data',
'elements' => array(
'name' => array('text', array(
'label' => 'Convention Name',
'class' => 'half-width',
'required' => true,
)),
'location' => array('text', array(
'label' => 'Convention Location',
'class' => 'half-width',
'required' => true,
)),
'coverage_level' => array('radio', array(
'label' => 'PVL Coverage Level',
'multiOptions' => $coverage_options,
'escape' => false,
'default' => 'full',
'required' => true,
)),
'start_date' => array('unixdate', array(
'label' => 'Start Date',
)),
'end_date' => array('unixdate', array(
'label' => 'End Date',
)),
'web_url' => array('text', array(
'label' => 'Homepage URL',
'class' => 'half-width',
)),
'image_url' => array('file', array(
'label' => 'Convention Image',
'description' => 'Use the same size image as the main PVL banner rotator (1150x200). PNG preferred.',
)),
'schedule_url' => array('text', array(
'label' => 'Schedule URL',
'class' => 'half-width',
)),
'signup_enabled' => array('radio', array(
'label' => 'Signup Enabled?',
'description' => 'Enable the convention signup form for camera operators and other staff.',
'multiOptions' => array(0 => 'No', 1 => 'Yes'),
'default' => 1,
'required' => true,
)),
'signup_notes' => array('textarea', array(
'label' => 'Special Signup Notes',
'description' => 'If there are special considerations for this convention, include them here and they will appear in the signup form.',
'class' => 'full-width half-height',
)),
'submit' => array('submit', array(
'type' => 'submit',
'label' => 'Save Changes',
'helper' => 'formButton',
'class' => 'ui-button',
)),
),
);

View File

@ -1,7 +1,68 @@
<?php
/**
* Created by PhpStorm.
* User: Buster Neece
* Date: 7/13/14
* Time: 1:09 PM
*/
use \Entity\Convention as Record;
use \Entity\Convention;
use \Entity\ConventionSignup;
use \Entity\ConventionArchive;
class Admin_ConventionsController extends \DF\Controller\Action
{
public function permissions()
{
return $this->acl->isAllowed('administer conventions');
}
public function indexAction()
{
$this->view->coverage = Convention::getCoverageLevels();
$query = $this->em->createQuery('SELECT c FROM Entity\Convention c ORDER BY c.start_date DESC');
$this->view->pager = new \DF\Paginator\Doctrine($query, $this->_getParam('page', 1), 50);
}
public function editAction()
{
$form = new \DF\Form($this->current_module_config->forms->convention);
if ($this->_hasParam('id'))
{
$id = (int)$this->_getParam('id');
$record = Record::find($id);
$form->setDefaults($record->toArray(TRUE, TRUE));
}
if($_POST && $form->isValid($_POST) )
{
$data = $form->getValues();
if (!($record instanceof Record))
$record = new Record;
$files = $form->processFiles('conventions');
\DF\Utilities::print_r($files);
foreach($files as $file_field => $file_paths)
$data[$file_field] = $file_paths[1];
$record->fromArray($data);
$record->save();
$this->alert('Changes saved.', 'green');
$this->redirectFromHere(array('action' => 'index', 'id' => NULL));
return;
}
$this->view->headTitle('Edit Record');
$this->renderForm($form);
}
public function deleteAction()
{
$record = Record::find($this->_getParam('id'));
if ($record)
$record->delete();
$this->alert('Record deleted.', 'green');
$this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'csrf' => NULL));
}
}

View File

@ -0,0 +1,75 @@
<?
$this->headTitle('Manage Conventions');
?>
<div class="buttons">
<?=$this->button(array(
'type' => 'link',
'class' => 'large success',
'href' => $this->routeFromHere(array('action' => 'edit')),
'icon' => 'icon-plus-sign',
'text' => 'Add New Convention',
)) ?>
</div>
<?=$this->paginate($this->pager) ?>
<table class="table table-striped table-nopadding">
<colgroup>
<col width="20%" />
<col width="3%" />
<col width="27%" />
<col width="30%" />
<col width="20%" />
</colgroup>
<thead>
<tr>
<th>Actions</th>
<th>&nbsp;</th>
<th>Name</th>
<th>Image</th>
<th>URLs</th>
</tr>
</thead>
<tbody>
<? foreach($this->pager as $record): ?>
<tr class="input">
<td class="center">
<div class="btn-group">
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-pencil',
'href' => $this->routeFromHere(array('action' => 'edit', 'id' => $record['id'])),
'text' => 'Edit',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-trash',
'class' => 'danger confirm-delete',
'href' => $this->routeFromHere(array('action' => 'delete', 'id' => $record['id'])),
'text' => 'Delete',
)) ?>
</div>
</td>
<td class="center">
<?
$level = $this->coverage[$record['coverage_level']];
?>
<div title="<?=$level['text'] ?>"><i class="large-icon <?=$level['icon'] ?>"></i></div>
</td>
<td>
<big><?=$record['name'] ?></big><br>
<?=$record['location'] ?><br>
<?=$record['start_date']->format('F j') ?> to <?=$record['end_date']->format('F j, Y') ?>
</td>
<td class="center"><img src="<?=\DF\Url::content($record['image_url']) ?>" style="width: 100%;"></td>
<td>
Web: <a href="<?=$record['web_url'] ?>" target="_blank"><?=$record['web_url'] ?></a><br>
Schedule: <a href="<?=$record['schedule_url'] ?>" target="_blank"><?=$record['schedule_url'] ?></a>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
<?=$this->paginate($this->pager) ?>

View File

@ -25,6 +25,7 @@ if ($skin == "dark")
<li><a href="<?=$this->route(array('module' => 'admin', 'controller' => 'podcasts')) ?>"><i class="icon-rss"></i> Podcasts</a></li>
<li><a href="<?=$this->route(array('module' => 'admin', 'controller' => 'rotators')) ?>"><i class="icon-refresh"></i> Rotating Banners</a></li>
<li><a href="<?=$this->route(array('module' => 'admin', 'controller' => 'affiliates')) ?>"><i class="icon-group"></i> Affiliates</a></li>
<li><a href="<?=$this->route(array('module' => 'admin', 'controller' => 'conventions')) ?>"><i class="icon-flag"></i> Conventions</a></li>
<li class="nav-header">Network Statistics</li>
<li><a href="<?=$this->route(array('module' => 'admin', 'controller' => 'songs', 'action' => 'votes')) ?>"><i class="icon-sort-by-order"></i> Top Songs for Week</a></li>

View File

@ -3,7 +3,7 @@ $this->headTitle('Manage Permissions');
$this->layout()->manual = TRUE;
?>
<div class="row">
<div class="row-fluid">
<div class="span6">
<div class="floating">
<h2>Roles</h2>

View File

@ -7,7 +7,7 @@ $this->headTitle('Manage Podcasts');
'type' => 'link',
'class' => 'large success',
'href' => $this->routeFromHere(array('action' => 'edit')),
'icon' => 'add',
'icon' => 'icon-plus-sign',
'text' => 'Add New Podcast',
)) ?>
</div>
@ -38,13 +38,13 @@ $this->headTitle('Manage Podcasts');
<div class="btn-group">
<?=$this->button(array(
'type' => 'small',
'icon' => 'pencil',
'icon' => 'icon-pencil',
'href' => $this->routeFromHere(array('action' => 'edit', 'id' => $record['id'])),
'text' => 'Edit',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'delete',
'icon' => 'icon-trash',
'class' => 'danger confirm-delete',
'href' => $this->routeFromHere(array('action' => 'delete', 'id' => $record['id'])),
'text' => 'Delete',

View File

@ -88,6 +88,7 @@ class Api_DevController extends \PVL\Controller\Action\Api
'rotators',
'songs',
'stations',
'conventions',
);
$static_files = array();