Verified Commit 20eaa5e6 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch 'release/0.2.5'

parents 142a8050 5ac9d261
......@@ -19,14 +19,14 @@ class RadioSessionViewSet(mixins.CreateModelMixin,
def get_queryset(self):
queryset = super().get_queryset()
if self.request.user.is_authenticated():
if self.request.user.is_authenticated:
return queryset.filter(user=self.request.user)
else:
return queryset.filter(session_key=self.request.session.session_key)
def get_serializer_context(self):
context = super().get_serializer_context()
if self.request.user.is_authenticated():
if self.request.user.is_authenticated:
context['user'] = self.request.user
else:
context['session_key'] = self.request.session.session_key
......@@ -44,7 +44,7 @@ class RadioSessionTrackViewSet(mixins.CreateModelMixin,
serializer.is_valid(raise_exception=True)
session = serializer.validated_data['session']
try:
if request.user.is_authenticated():
if request.user.is_authenticated:
assert request.user == session.user
else:
assert request.session.session_key == session.session_key
......
class AnonymousSessionMiddleware(object):
def process_request(self, request):
class AnonymousSessionMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if not request.session.session_key:
request.session.save()
response = self.get_response(request)
return response
......@@ -38,7 +38,7 @@ class Migration(migrations.Migration):
'verbose_name_plural': 'users',
},
managers=[
(b'objects', django.contrib.auth.models.UserManager()),
('objects', django.contrib.auth.models.UserManager()),
],
),
]
......@@ -2,7 +2,7 @@
from __future__ import unicode_literals, absolute_import
from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
......
# Bleeding edge Django
django==1.11
django>=2.0,<2.1
# Configuration
django-environ==0.4.0
django-secure==1.0.1
whitenoise==2.0.6
# Models
django-model-utils==2.3.1
django-environ>=0.4,<0.5
whitenoise>=3.3,<3.4
# Images
Pillow==3.0.0
Pillow>=4.3,<4.4
# For user registration, either via email or social
# Well-built with regular release cycles!
django-allauth==0.24.1
django-allauth>=0.34,<0.35
# Python-PostgreSQL Database Adapter
psycopg2==2.6.1
psycopg2>=2.7,<=2.8
# Time zones support
pytz==2015.7
pytz==2017.3
# Redis support
django-redis==4.3.0
redis>=2.10.0
django-redis>=4.5,<4.6
redis>=2.10,<2.11
celery==3.1.19
celery>=3.1,<3.2
# Your custom requirements go here
django-cors-headers==2.1.0
django-cors-headers>=2.1,<2.2
musicbrainzngs==0.6
youtube_dl>=2015.12.21
djangorestframework==3.6.3
djangorestframework-jwt==1.11.0
django-celery==3.2.1
django-mptt==0.8.7
google-api-python-client==1.6.2
arrow==0.10.0
django-taggit==0.22.1
persisting-theory==0.2.1
django-versatileimagefield==1.7.1
django-cachalot==1.5.0
django-filter==1.1
django-rest-auth==0.9.1
beautifulsoup4==4.6.0
Markdown==2.6.8
ipython==6.1.0
mutagen==1.38
youtube_dl>=2017.12.14
djangorestframework>=3.7,<3.8
djangorestframework-jwt>=1.11,<1.12
django-celery>=3.2,<3.3
django-mptt>=0.9,<0.10
google-api-python-client>=1.6,<1.7
arrow>=0.12,<0.13
persisting-theory>=0.2,<0.3
django-versatileimagefield>=1.8,<1.9
django-filter>=1.1,<1.2
django-rest-auth>=0.9,<0.10
beautifulsoup4>=4.6,<4.7
Markdown>=2.6,<2.7
ipython>=6,<7
mutagen>=1.39,<1.40
# Until this is merged
#django-taggit>=0.22,<0.23
git+https://github.com/jdufresne/django-taggit.git@e8f7f216f04c9781bebc84363ab24d575f948ede
# Until this is merged
git+https://github.com/EliotBerriot/PyMemoize.git@django
# Until this is merged
#django-cachalot==1.5.0
git+https://github.com/EliotBerriot/django-cachalot.git@django-2
django-dynamic-preferences>=1.3,<1.4
django-dynamic-preferences>=1.5,<1.6
# Local development dependencies go here
-r base.txt
coverage==4.0.3
django_coverage_plugin==1.1
Sphinx==1.6.2
django-extensions==1.5.9
Werkzeug==0.11.2
django-test-plus==1.0.11
coverage>=4.4,<4.5
django_coverage_plugin>=1.5,<1.6
Sphinx>=1.6,<1.7
django-extensions>=1.9,<1.10
Werkzeug>=0.13,<0.14
django-test-plus>=1.0.20
factory_boy>=2.8.1
# django-debug-toolbar that works with Django 1.5+
django-debug-toolbar>=1.5,<1.6
django-debug-toolbar>=1.9,<1.10
# improved REPL
ipdb==0.8.1
# Pro-tip: Try not to put anything here. There should be no dependency in
# production that isn't in development.
-r base.txt
# WSGI Handler
# ------------------------------------------------
......
# Test dependencies go here.
-r local.txt
flake8==2.5.0
model-mommy==1.3.2
flake8
pytest
pytest-django
pytest-mock
......
......@@ -26,6 +26,7 @@ class Audio {
if (options.onEnded) {
this.onEnded = options.onEnded
}
this.onError = options.onError
this.state = {
preload: preload,
......@@ -60,8 +61,12 @@ class Audio {
init (src, options = {}) {
if (!src) throw Error('src must be required')
this.state.startLoad = true
if (this.state.tried === this.state.try) {
if (this.state.tried >= this.state.try) {
this.state.failed = true
logger.default.error('Cannot fetch audio', src)
if (this.onError) {
this.onError(src)
}
return
}
this.$Audio = new window.Audio(src)
......
......@@ -140,7 +140,6 @@ class Queue {
} else {
index = index || this.tracks.length
}
console.log('INDEEEEEX', index)
tracks.forEach((t) => {
self.append(t, index, true)
index += 1
......@@ -243,7 +242,11 @@ class Queue {
rate: 1,
loop: false,
volume: this.state.volume,
onEnded: this.handleAudioEnded.bind(this)
onEnded: this.handleAudioEnded.bind(this),
onError: function (src) {
self.errored = true
self.next()
}
})
this.audio = audio
audio.updateHook('playState', function (e) {
......
<template>
<div class="main pusher">
<div class="ui vertical stripe segment">
<div class="ui text container">
<h1 class="ui huge header">
<i class="warning icon"></i>
<div class="content">
<strike>Whale</strike> Page not found!
</div>
</h1>
<p>We're sorry, the page you asked for does not exists.</p>
<p>Requested URL: <a :href="path">{{ path }}</a></p>
<router-link class="ui icon button" to="/">
Go to home page
<i class="right arrow icon"></i>
</router-link>
</div>
</div>
</div>
</template>
<script>
export default {
data: function () {
return {
path: window.location.href
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
......@@ -43,6 +43,9 @@ import auth from '@/auth'
export default {
name: 'login',
props: {
next: {type: String}
},
data () {
return {
// We need to initialize the component with any
......@@ -69,7 +72,7 @@ export default {
}
// We need to pass the component's this context
// to properly make use of http in the auth service
auth.login(this, credentials, {path: '/library'}, function (response) {
auth.login(this, credentials, {path: this.next}, function (response) {
// error callback
if (response.status === 400) {
self.error = 'invalid_credentials'
......
......@@ -12,6 +12,10 @@
<label>{{ t }}</label>
</div>
</div>
<div class="field">
<label>Query template</label>
<input v-model="customQueryTemplate" />
</div>
</div>
</form>
<template
......@@ -22,6 +26,7 @@
:backends="backends"
:defaultEnabled="false"
:default-backend-id="defaultBackendId"
:query-template="customQueryTemplate"
@import-data-changed="recordReleaseData"
@enabled="recordReleaseEnabled"
></release-import>
......
......@@ -13,10 +13,12 @@ export default {
metadata: {type: Object, required: true},
defaultEnabled: {type: Boolean, default: true},
backends: {type: Array},
defaultBackendId: {type: String}
defaultBackendId: {type: String},
queryTemplate: {type: String, default: '$artist $title'}
},
data () {
return {
customQueryTemplate: this.queryTemplate,
currentBackendId: this.defaultBackendId,
isImporting: false,
enabled: this.defaultEnabled
......@@ -56,6 +58,9 @@ export default {
return this.backends.filter(b => {
return b.id === self.currentBackendId
})[0]
},
realQueryTemplate () {
}
},
watch: {
......@@ -70,6 +75,14 @@ export default {
},
enabled (newValue) {
this.$emit('enabled', this.importData, newValue)
},
queryTemplate (newValue, oldValue) {
// we inherit from the prop template unless the component changed
// the value
if (oldValue === this.customQueryTemplate) {
// no changed from prop, we keep the sync
this.customQueryTemplate = newValue
}
}
}
}
......
......@@ -20,6 +20,7 @@
:release-metadata="metadata"
:backends="backends"
:default-backend-id="defaultBackendId"
:query-template="customQueryTemplate"
@import-data-changed="recordTrackData"
@enabled="recordTrackEnabled"
></track-import>
......
......@@ -92,13 +92,7 @@ export default Vue.extend({
releaseMetadata: {type: Object, required: true}
},
data () {
let queryParts = [
this.releaseMetadata['artist-credit'][0]['artist']['name'],
this.releaseMetadata['title'],
this.metadata['recording']['title']
]
return {
query: queryParts.join(' '),
isLoading: false,
results: [],
currentResultIndex: 0,
......@@ -151,6 +145,18 @@ export default Vue.extend({
mbid: this.metadata.recording.id,
source: this.importedUrl
}
},
query () {
let queryMapping = [
['artist', this.releaseMetadata['artist-credit'][0]['artist']['name']],
['album', this.releaseMetadata['title']],
['title', this.metadata['recording']['title']]
]
let query = this.customQueryTemplate
queryMapping.forEach(e => {
query = query.split('$' + e[0]).join(e[1])
})
return query
}
},
watch: {
......
......@@ -32,7 +32,7 @@ Vue.http.interceptors.push(function (request, next) {
// redirect to login form when we get unauthorized response from server
if (response.status === 401) {
logger.default.warn('Received 401 response from API, redirecting to login form')
router.push({name: 'login'})
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
})
})
......
import Vue from 'vue'
import Router from 'vue-router'
import PageNotFound from '@/components/PageNotFound'
import Home from '@/components/Home'
import Login from '@/components/auth/Login'
import Profile from '@/components/auth/Profile'
......@@ -30,7 +31,8 @@ export default new Router({
{
path: '/login',
name: 'login',
component: Login
component: Login,
props: (route) => ({ next: route.query.next || '/library' })
},
{
path: '/logout',
......@@ -71,7 +73,7 @@ export default new Router({
},
{ path: 'import/batches/:id', name: 'library.import.batches.detail', component: BatchDetail, props: true }
]
}
},
{ path: '*', component: PageNotFound }
]
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment