Fixed some db stuff and fuck up

This commit is contained in:
Fergal Moran
2015-10-19 19:10:48 +01:00
parent 25bd272b6d
commit 2013130458
3 changed files with 47 additions and 10 deletions

View File

@@ -80,14 +80,22 @@ 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'))
ice_scrobbler.play(m.get_stream_url())
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:
pass
return Response(status=HTTP_400_BAD_REQUEST)

View File

@@ -45,6 +45,10 @@ def shuffle():
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url)
def play(url):
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
r = requests.post(url)
if __name__ == '__main__':
d = get_server_details("localhost", "8000", "dss")

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()