Add south-specific hacks

This commit is contained in:
root
2018-04-09 14:55:02 +02:00
parent 32f2aaac7a
commit 684710ebae
3 changed files with 19 additions and 55 deletions

View File

@ -259,7 +259,7 @@ def upload(request):
for i, file in enumerate(files): for i, file in enumerate(files):
duration = File(file).info.length duration = File(file).info.length
hash = send_to_bertha(file) hash = send_to_bertha(file).decode('ascii')
if not hash: if not hash:
return JsonResponse({'success': False, 'errorMessage': 'Files not uploaded correctly.'}) return JsonResponse({'success': False, 'errorMessage': 'Files not uploaded correctly.'})
song = Song(user=request.user, artist=artists[i], title=titles[i], hash=hash, duration=duration) song = Song(user=request.user, artist=artists[i], title=titles[i], hash=hash, duration=duration)

View File

@ -47,17 +47,18 @@ class Command(BaseCommand):
for line in fp: for line in fp:
# RequestID TrackID RequestedBy Played # RequestID TrackID RequestedBy Played
import_req = line.strip(b'\n').split(b'\t') import_req = line.strip(b'\n').split(b'\t')
song = Song.objects.filter(old_id=import_req[1]).first() song = Song.objects.filter(old_id=int(import_req[1])).first()
user = User.objects.filter(username=import_req[3]).first() user = User.objects.filter(username=import_req[2].decode('ascii')).first()
if song is None or user is None or playlist is None: playlist = get_first_queue().playlist
print((song, user, playlist, import_req[2]))
if song is None or user is None:
continue continue
playlist_song = PlaylistSong( playlist_song = PlaylistSong(
playlist=get_first_queue().playlist, playlist=playlist,
song=song, user=user, song=song, user=user,
state=2, # already played state=2)
order=0)
try: try:
playlist_song.save() pass#playlist_song.save()
except OperationalError as e: except OperationalError as e:
print('Error: {}'.format(e)) print('Error: {}'.format(e))
continue continue

View File

@ -1,34 +1,14 @@
""" """
Django settings for marietje project. 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 import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'sae2hahHao1soo0Ocoz5Ieh1Ushae6feJe4mooliooj0Ula8'
# 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!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
@ -74,25 +54,18 @@ TEMPLATES = [
WSGI_APPLICATION = 'marietje.wsgi.application' WSGI_APPLICATION = 'marietje.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'marietje', 'NAME': 'marietje',
'USER': 'marietje', 'USER': 'marietje',
'PASSWORD': 'UYmINKUDXIfY1qudVhbr5UhJ61kVwZPA', 'PASSWORD': 'v8TzZwdAdSi7Tk5I',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '3306', '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 = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
@ -119,19 +92,10 @@ PASSWORD_HASHERS = [
] ]
AUTH_USER_MODEL = 'marietje.User' AUTH_USER_MODEL = 'marietje.User'
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Europe/Amsterdam' TIME_ZONE = 'Europe/Amsterdam'
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True USE_TZ = True
@ -140,21 +104,20 @@ USE_TZ = True
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/' STATIC_URL = '/static/'
LOGIN_URL = '/login/' LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/'
BERTHA_HOST = ('hardcoding.nl', 1819) # App specific settings
MAIL_FROM = 'marietje@hardcoding.nl'
BERTHA_HOST = ('bach.science.ru.nl', 1234)
MAIL_FROM = 'marietje@marietje.science.ru.nl'
MAX_MINUTES_IN_A_ROW = 20 MAX_MINUTES_IN_A_ROW = 20
# Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect. # Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect.
LIMIT_ALWAYS = False LIMIT_HOURS = (12, 13)
LIMIT_HOURS = (12, 16) LIMIT_MINUTES = (15, 45)
LIMIT_ALWAYS = 45
CONTACT_EMAIL = 'marietje@science.ru.nl' CONTACT_EMAIL = 'marietje@science.ru.nl'