From 684710ebae320d95a7d84f448421c77bb396569a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 9 Apr 2018 14:55:02 +0200 Subject: [PATCH] Add south-specific hacks --- marietje/api/views.py | 2 +- .../management/commands/importhistory.py | 15 ++--- marietje/marietje/settings.py | 57 ++++--------------- 3 files changed, 19 insertions(+), 55 deletions(-) diff --git a/marietje/api/views.py b/marietje/api/views.py index d0cde8d..358312c 100644 --- a/marietje/api/views.py +++ b/marietje/api/views.py @@ -259,7 +259,7 @@ def upload(request): for i, file in enumerate(files): duration = File(file).info.length - hash = send_to_bertha(file) + hash = send_to_bertha(file).decode('ascii') if not hash: return JsonResponse({'success': False, 'errorMessage': 'Files not uploaded correctly.'}) song = Song(user=request.user, artist=artists[i], title=titles[i], hash=hash, duration=duration) diff --git a/marietje/marietje/management/commands/importhistory.py b/marietje/marietje/management/commands/importhistory.py index fe68831..a7d2321 100644 --- a/marietje/marietje/management/commands/importhistory.py +++ b/marietje/marietje/management/commands/importhistory.py @@ -47,17 +47,18 @@ class Command(BaseCommand): for line in fp: # RequestID TrackID RequestedBy Played import_req = line.strip(b'\n').split(b'\t') - song = Song.objects.filter(old_id=import_req[1]).first() - user = User.objects.filter(username=import_req[3]).first() - if song is None or user is None or playlist is None: + song = Song.objects.filter(old_id=int(import_req[1])).first() + user = User.objects.filter(username=import_req[2].decode('ascii')).first() + playlist = get_first_queue().playlist + print((song, user, playlist, import_req[2])) + if song is None or user is None: continue playlist_song = PlaylistSong( - playlist=get_first_queue().playlist, + playlist=playlist, song=song, user=user, - state=2, # already played - order=0) + state=2) try: - playlist_song.save() + pass#playlist_song.save() except OperationalError as e: print('Error: {}'.format(e)) continue diff --git a/marietje/marietje/settings.py b/marietje/marietje/settings.py index 402a1dd..a2b8b5d 100644 --- a/marietje/marietje/settings.py +++ b/marietje/marietje/settings.py @@ -1,34 +1,14 @@ """ Django settings for marietje project. - -Generated by 'django-admin startproject' using Django 1.10.4. - -For more information on this file, see -https://docs.djangoproject.com/en/1.10/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'v_k0xdni55(jslu7od7f-h@8m7+l$7yy=+pg*a9)90*4g6p3&_' - -# SECURITY WARNING: don't run with debug turned on in production! +SECRET_KEY = 'sae2hahHao1soo0Ocoz5Ieh1Ushae6feJe4mooliooj0Ula8' DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition +ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django.contrib.admin', @@ -74,25 +54,18 @@ TEMPLATES = [ WSGI_APPLICATION = 'marietje.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'marietje', 'USER': 'marietje', - 'PASSWORD': 'UYmINKUDXIfY1qudVhbr5UhJ61kVwZPA', + 'PASSWORD': 'v8TzZwdAdSi7Tk5I', 'HOST': 'localhost', 'PORT': '3306', + 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" }, } } - -# Password validation -# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators - AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -119,19 +92,10 @@ PASSWORD_HASHERS = [ ] AUTH_USER_MODEL = 'marietje.User' - - -# Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ - LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'Europe/Amsterdam' - USE_I18N = True - USE_L10N = True - USE_TZ = True @@ -140,21 +104,20 @@ USE_TZ = True STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' - LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/' -BERTHA_HOST = ('hardcoding.nl', 1819) - -MAIL_FROM = 'marietje@hardcoding.nl' - +# App specific settings +BERTHA_HOST = ('bach.science.ru.nl', 1234) +MAIL_FROM = 'marietje@marietje.science.ru.nl' MAX_MINUTES_IN_A_ROW = 20 # Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect. -LIMIT_ALWAYS = False -LIMIT_HOURS = (12, 16) +LIMIT_HOURS = (12, 13) +LIMIT_MINUTES = (15, 45) +LIMIT_ALWAYS = 45 CONTACT_EMAIL = 'marietje@science.ru.nl'