Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-08-29 11:05:14 -04:00
commit 8b5f94fa9f
10 changed files with 87 additions and 21 deletions

View File

@ -686,7 +686,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$dir_id = $request->getParam('dir_id');
$this->view->files = Application_Model_StoredFile::listAllFiles($dir_id);
$this->view->files =
Application_Model_StoredFile::listAllFiles($dir_id,$all=true);
}
public function listAllWatchedDirsAction()
@ -859,7 +860,8 @@ class ApiController extends Zend_Controller_Action
$watchDir = Application_Model_MusicDir::getDirByPath($rd);
// get all the files that is under $dirPath
$files = Application_Model_StoredFile::listAllFiles($dir->getId(), true);
$files = Application_Model_StoredFile::listAllFiles(
$dir->getId(),$all=false, true);
foreach ($files as $f) {
// if the file is from this mount
if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) {

View File

@ -13,6 +13,7 @@ class UsersettingsController extends Zend_Controller_Action
->addActionContext('get-timeline-datatable', 'json')
->addActionContext('set-timeline-datatable', 'json')
->addActionContext('remindme', 'json')
->addActionContext('remindme-never', 'json')
->addActionContext('donotshowregistrationpopup', 'json')
->initContext();
}
@ -88,6 +89,13 @@ class UsersettingsController extends Zend_Controller_Action
Zend_Session::namespaceUnset('referrer');
Application_Model_Preference::SetRemindMeDate();
}
public function remindmeNeverAction()
{
Zend_Session::namespaceUnset('referrer');
//pass in true to indicate 'Remind me never' was clicked
Application_Model_Preference::SetRemindMeDate(true);
}
public function donotshowregistrationpopupAction()
{

View File

@ -35,7 +35,7 @@ class Application_Model_Email
);
} else {
$config = array(
'ssl' => 'ssl'
'ssl' => 'tls'
);
}

View File

@ -587,10 +587,14 @@ class Application_Model_Preference
}
}
public static function SetRemindMeDate()
public static function SetRemindMeDate($p_never = false)
{
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
if ($p_never) {
self::setValue("remindme", -1);
} else {
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
}
}
public static function GetRemindMeDate()
@ -1105,9 +1109,13 @@ class Application_Model_Preference
{
$today = mktime(0, 0, 0, gmdate("m"), gmdate("d"), gmdate("Y"));
$remindDate = Application_Model_Preference::GetRemindMeDate();
if ($remindDate == NULL || $today >= $remindDate) {
return true;
$retVal = false;
if ($remindDate == NULL || ($remindDate != -1 && $today >= $remindDate)) {
$retVal = true;
}
return $retVal;
}
public static function getCurrentLibraryTableSetting()

View File

@ -1006,19 +1006,21 @@ class Application_Model_StoredFile
* @param $dir_id - if this is not provided, it returns all files with full path constructed.
* @param $propelObj - if this is true, it returns array of proepl obj
*/
public static function listAllFiles($dir_id=null, $propelObj=false)
public static function listAllFiles($dir_id=null, $all, $propelObj=false)
{
$con = Propel::getConnection();
$file_exists = $all ? "" : "and f.file_exists = 'TRUE'";
if ($propelObj) {
$sql = "SELECT m.directory || f.filepath as fp"
." FROM CC_MUSIC_DIRS m"
." LEFT JOIN CC_FILES f"
." ON m.id = f.directory WHERE m.id = $dir_id and f.file_exists = 'TRUE'";
." ON m.id = f.directory WHERE m.id = $dir_id $file_exists";
} else {
$sql = "SELECT filepath as fp"
." FROM CC_FILES"
." WHERE directory = $dir_id and file_exists = 'TRUE'";
." FROM CC_FILES as f"
." WHERE f.directory = $dir_id $file_exists";
}
$rows = $con->query($sql)->fetchAll();

View File

@ -231,6 +231,25 @@ class Application_Model_User
$this->_userInstance->delete();
}
}
public function getOwnedFiles()
{
$user = $this->_userInstance;
// do we need a find call at the end here?
return $user->getCcFilessRelatedByDbOwnerId();
}
public function donateFilesTo($user)
{
$my_files = $this->getOwnedFiles();
foreach ($my_files as $file) {
$file->reassignTo($user);
}
}
public function deleteAllFiles()
{
$my_files = $this->getOwnedFiles();
}
private function createUser()
{

View File

@ -40,5 +40,8 @@ class CcFiles extends BaseCcFiles {
return $this;
}
public function reassignTo($user) {
$this->setDbOwnerId( $user->getDbId() );
}
} // CcFiles

View File

@ -26,6 +26,18 @@ $(document).ready(function(){
$(this).dialog("close");
}
},
{
id: "remind_never",
text: "Remind me never",
click: function() {
var url ='/Usersettings/remindme-never';
$.ajax({
url: url,
data: {format:"json"}
});
$(this).dialog("close");
}
},
{
id: "help_airtime",
text: "Yes, help Airtime",

View File

@ -79,9 +79,16 @@ class Manager(Loggable):
watch_dir)
self.remove_watch_directory(normpath(watch_dir))
def watch_signal(self): return self.watch_listener.signal
def watch_signal(self):
"""
Return the signal string our watch_listener is reading events from
"""
return self.watch_listener.signal
def __remove_watch(self,path):
"""
Remove path from being watched (first will check if 'path' is watched)
"""
# only delete if dir is actually being watched
if path in self.__wd_path:
wd = self.__wd_path[path]
@ -89,11 +96,16 @@ class Manager(Loggable):
del(self.__wd_path[path])
def __add_watch(self,path,listener):
"""
Start watching 'path' using 'listener'. First will check if directory
is being watched before adding another watch
"""
self.logger.info("Adding listener '%s' to '%s'" %
( listener.__class__.__name__, path) )
wd = self.wm.add_watch(path, pyinotify.ALL_EVENTS, rec=True,
auto_add=True, proc_fun=listener)
self.__wd_path[path] = wd.values()[0]
if not self.has_watch(path):
wd = self.wm.add_watch(path, pyinotify.ALL_EVENTS, rec=True,
auto_add=True, proc_fun=listener)
if wd: self.__wd_path[path] = wd.values()[0]
def __create_organizer(self, target_path, recorded_path):
"""

View File

@ -14,8 +14,8 @@ from configobj import ConfigObj
from media.monitor.exceptions import FailedToSetLocale, FailedToCreateDir
supported_extensions = [u"mp3", u"ogg", u"oga"]
#supported_extensions = [u"mp3", u"ogg", u"oga", u"flac", u"aac", u"bwf"]
#supported_extensions = [u"mp3", u"ogg", u"oga"]
supported_extensions = [u"mp3", u"ogg", u"oga", u"flac", u"aac", u"bwf"]
unicode_unknown = u'unknown'
path_md = ['MDATA_KEY_TITLE', 'MDATA_KEY_CREATOR', 'MDATA_KEY_SOURCE',
@ -285,11 +285,11 @@ def organized_path(old_path, root_path, orig_md):
# MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this
# into 254kbps
normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f)
if normal_md['MDATA_KEY_BITRATE']:
try:
formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000)
normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps'
else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown
except:
normal_md['MDATA_KEY_BITRATE'] = unicode_unknown
if is_airtime_recorded(normal_md):
title_re = re.match("(?P<show>.+)-(?P<date>\d+-\d+-\d+-\d+:\d+:\d+)$",