Merge branch 'feature/radio_admin' into develop

This commit is contained in:
Fergal Moran
2015-10-19 21:06:56 +01:00
5 changed files with 52 additions and 14 deletions

View File

@@ -80,14 +80,27 @@ class RadioHelper(Helper):
return Response(data=ret, status=HTTP_200_OK)
def post(self, request):
if 'action' in request.query_params:
action = request.query_params.get('action')
if action == 'shuffle':
ice_scrobbler.shuffle()
return Response(status=HTTP_200_OK)
if 'update' in request.query_params and 'url' in request.query_params:
activity.post_activity('site:radio_changed', message={
'description': request.query_params.get('update'),
'url': request.query_params.get('url')
})
try:
if 'action' in request.query_params:
action = request.query_params.get('action')
if action == 'shuffle':
ice_scrobbler.shuffle()
return Response(status=HTTP_200_OK)
if action == 'play':
m = Mix.objects.get(slug=request.query_params.get('slug'))
item = {
'url': m.get_stream_url(),
'slug': m.get_full_url(),
'title': str(m)
}
ice_scrobbler.play(item)
return Response(status=HTTP_200_OK)
if 'update' in request.query_params and 'url' in request.query_params:
activity.post_activity('site:radio_changed', message={
'description': request.query_params.get('update'),
'url': request.query_params.get('url')
})
except Exception as ex:
pass
return Response(status=HTTP_400_BAD_REQUEST)

View File

@@ -42,9 +42,12 @@ def get_server_details():
def shuffle():
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
url = "http://{}:{}/a/shuffle".format(settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url)
def play(item):
url = "http://{}:{}/a/play".format(settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url, data=item)
if __name__ == '__main__':
d = get_server_details("localhost", "8000", "dss")

View File

@@ -82,7 +82,6 @@ MIDDLEWARE_CLASSES = (
'corsheaders.middleware.CorsMiddleware',
# 'htmlmin.middleware.HtmlMinifyMiddleware',
# 'htmlmin.middleware.MarkRequestMiddleware',
'django_user_agents.middleware.UserAgentMiddleware',
# 'spa.middleware.uploadify.SWFUploadMiddleware',
# 'spa.middleware.sqlprinter.SqlPrintingMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
@@ -120,7 +119,6 @@ INSTALLED_APPS = (
'gunicorn',
'spa.signals',
'core',
'django_user_agents',
'storages',
'social.apps.django_app.default',

View File

@@ -13,7 +13,6 @@ six==1.6.0
django-filter
django-grappelli==2.5.7
django-model_utils
django-user-agents
redis
git+git://github.com/llazzaro/django-scheduler.git#django-scheduler
django-celery

View File

@@ -0,0 +1,25 @@
from django.core.management.base import LabelCommand
import dropbox
from dss import settings
def _restore_database():
""" find latest database backup """
client = dropbox.client.DropboxClient(settings.DSS_DB_BACKUP_TOKEN)
class Command(LabelCommand):
help = (
"Handles restoring of items backed up"
)
missing_args_message = "Enter one of [database, settings, media, all]"
def handle_label(self, label, **options):
if label == "database":
_restore_database()
if label == "settings":
pass
if label == "media":
pass
if label == "all":
_restore_database()