From 6adc8f0cde39e6ff7a7b64229d009c5a899ac8a4 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Thu, 20 Jul 2017 23:25:01 +0200 Subject: [PATCH 1/4] Fixed #37: do not pass recursive flag on import unless needed --- .../audiofile/management/commands/import_files.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py index 8a99156cb..a34e36b4b 100644 --- a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py +++ b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py @@ -29,7 +29,17 @@ class Command(BaseCommand): def handle(self, *args, **options): # self.stdout.write(self.style.SUCCESS('Successfully closed poll "%s"' % poll_id)) - matching = glob.glob(options['path'], recursive=options['recursive']) + + # Recursive is supported only on Python 3.5+, so we pass the option + # only if it's True to avoid breaking on older versions of Python + glob_kwargs = {} + if options['recursive']: + glob_kwargs['recursive'] = True + try: + matching = glob.glob(options['path'], **glob_kwargs) + except TypeError: + raise Exception('You need Python 3.5 to use the --recursive flag') + self.stdout.write('This will import {} files matching this pattern: {}'.format( len(matching), options['path'])) From ee1449bdd090ac61b562327c4faf3237c5c6a7a7 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Mon, 11 Dec 2017 19:32:56 +0100 Subject: [PATCH 2/4] added real file in track factory --- api/funkwhale_api/music/tests/factories.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/music/tests/factories.py b/api/funkwhale_api/music/tests/factories.py index dfa7a75e2..d4ec04810 100644 --- a/api/funkwhale_api/music/tests/factories.py +++ b/api/funkwhale_api/music/tests/factories.py @@ -1,4 +1,7 @@ import factory +import os + +SAMPLES_PATH = os.path.dirname(os.path.abspath(__file__)) class ArtistFactory(factory.django.DjangoModelFactory): @@ -33,7 +36,8 @@ class TrackFactory(factory.django.DjangoModelFactory): class TrackFileFactory(factory.django.DjangoModelFactory): track = factory.SubFactory(TrackFactory) - audio_file = factory.django.FileField() + audio_file = factory.django.FileField( + from_path=os.path.join(SAMPLES_PATH, 'test.ogg')) class Meta: model = 'music.TrackFile' From 03f15ada4e668d8f4282f8eb02fc999293de7a57 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Mon, 11 Dec 2017 21:09:17 +0100 Subject: [PATCH 3/4] added shortcuts for play, volume and restore --- front/package.json | 1 + front/src/audio/queue.js | 6 +++++- front/src/components/Sidebar.vue | 8 +++++++- front/src/components/audio/Player.vue | 13 ++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/front/package.json b/front/package.json index 7cec50319..55e773fba 100644 --- a/front/package.json +++ b/front/package.json @@ -18,6 +18,7 @@ "js-logger": "^1.3.0", "semantic-ui-css": "^2.2.10", "vue": "^2.3.3", + "vue-global-events": "^1.0.2", "vue-resource": "^1.3.4", "vue-router": "^2.3.1", "vuedraggable": "^2.14.1" diff --git a/front/src/audio/queue.js b/front/src/audio/queue.js index 25b27f00e..77fe6bf2b 100644 --- a/front/src/audio/queue.js +++ b/front/src/audio/queue.js @@ -86,6 +86,8 @@ class Queue { cache.remove('queue') } setVolume (newValue) { + newValue = Math.min(newValue, 1) + newValue = Math.max(newValue, 0) this.state.volume = newValue if (this.audio.setVolume) { this.audio.setVolume(newValue) @@ -94,7 +96,9 @@ class Queue { } cache.set('volume', newValue) } - + incrementVolume (value) { + this.setVolume(this.state.volume + value) + } reorder (oldIndex, newIndex) { // called when the user uses drag / drop to reorder // tracks in queue diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index e39dd16b9..0ce16a75f 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -87,10 +87,15 @@
+