From adddd1085cfd60a08182c07a9acf841ac19eda4a Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 12 Apr 2012 18:00:38 +0200 Subject: [PATCH 1/2] CC-3592 : Calendar-> Recorded Shows do not get Rebroadcasted at the moment added a flag whether to check user permissions or not. --- airtime_mvc/application/models/Scheduler.php | 11 +++++++++-- airtime_mvc/application/models/ShowInstance.php | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index ea179af4e..7515ac0b4 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -16,8 +16,10 @@ class Application_Model_Scheduler { private $epochNow; private $nowDT; private $user; + + private $checkUserPermissions = true; - public function __construct($id = null) { + public function __construct() { $this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); @@ -27,6 +29,11 @@ class Application_Model_Scheduler { $this->user = Application_Model_User::GetCurrentUser(); } + public function setCheckUserPermissions($value) { + $this->checkUserPermissions = $value; + } + + /* * make sure any incoming requests for scheduling are ligit. * @@ -83,7 +90,7 @@ class Application_Model_Scheduler { $id = $instance->getDbId(); $show = $instance->getCcShow($this->con); - if ($this->user->canSchedule($show->getDbId()) === false) { + if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) { throw new Exception("You are not allowed to schedule show {$show->getDbName()}."); } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 142b2998c..8e096aad3 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -352,7 +352,7 @@ class Application_Model_ShowInstance { * @param int $plId * Playlist ID. */ - public function addPlaylistToShow($pl_id) + public function addPlaylistToShow($pl_id, $checkUserPerm = true) { $ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0; $id = $this->_showInstance->getDbId(); @@ -369,12 +369,13 @@ class Application_Model_ShowInstance { * * @param int $file_id */ - public function addFileToShow($file_id) + public function addFileToShow($file_id, $checkUserPerm = true) { $ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0; $id = $this->_showInstance->getDbId(); $scheduler = new Application_Model_Scheduler(); + $scheduler->setCheckUserPermissions($checkUserPerm); $scheduler->scheduleAfter( array(array("id" => 0, "instance" => $id, "timestamp" => $ts)), array(array("id" => $file_id, "type" => "audioclip")) @@ -553,7 +554,7 @@ class Application_Model_ShowInstance { try { $rebroad = new Application_Model_ShowInstance($rebroadcast->getDbId()); - $rebroad->addFileToShow($file_id); + $rebroad->addFileToShow($file_id, false); } catch (Exception $e) { Logging::log("{$e->getFile()}"); From e2adaff5cff841e27118b55095e087612c9e3cf7 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Thu, 12 Apr 2012 18:07:16 +0200 Subject: [PATCH 2/2] CC-3630 : Deleting files from organize folder if they don't have correct Meta data --- .../airtimefilemonitor/airtimeprocessevent.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index a5c6055dc..40022f571 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -137,8 +137,13 @@ class AirtimeProcessEvent(ProcessEvent): if self.mmc.is_parent_directory(pathname, self.config.organize_directory): #file was created in /srv/airtime/stor/organize. Need to process and move #to /srv/airtime/stor/imported + oldPath = pathname pathname = self.mmc.organize_new_file(pathname) - name = os.path.basename(pathname) + + #delete files from organize if they can not be read properly. + if pathname is None: + os.remove(oldPath) + return self.mmc.set_needed_file_permissions(pathname, dir) is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory) @@ -237,6 +242,11 @@ class AirtimeProcessEvent(ProcessEvent): del self.cookies_IN_MOVED_FROM[event.cookie] if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory): filepath = self.mmc.organize_new_file(event.pathname) + + #delete files from organize if they can not be read properly. + if filepath is None: + os.remove(event.pathname) + else: filepath = event.pathname @@ -244,7 +254,11 @@ class AirtimeProcessEvent(ProcessEvent): self.file_events.append({'filepath': filepath, 'mode': self.config.MODE_MOVED}) else: if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory): - self.mmc.organize_new_file(event.pathname) + filepath = self.mmc.organize_new_file(event.pathname) + + #delete files from organize if they can not be read properly. + if filepath is None: + os.remove(event.pathname) else: #show dragged from unwatched folder into a watched folder. Do not "organize".:q! if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory): @@ -285,8 +299,10 @@ class AirtimeProcessEvent(ProcessEvent): if not dir: if self.mmc.is_audio_file(pathname): if pathname in self.ignore_event: + self.logger.info("pathname in ignore event") self.ignore_event.remove(pathname) elif not self.mmc.is_parent_directory(pathname, self.config.organize_directory): + self.logger.info("deleting a file not in organize") #we don't care if a file was deleted from the organize directory. self.file_events.append({'filepath': pathname, 'mode': self.config.MODE_DELETE})