diff --git a/.env.dev b/.env.dev
index d42cdad02..9923c3148 100644
--- a/.env.dev
+++ b/.env.dev
@@ -1,4 +1,3 @@
API_AUTHENTICATION_REQUIRED=True
-CACHALOT_ENABLED=False
RAVEN_ENABLED=false
RAVEN_DSN=https://44332e9fdd3d42879c7d35bf8562c6a4:0062dc16a22b41679cd5765e5342f716@sentry.eliotberriot.com/5
diff --git a/.gitignore b/.gitignore
index 66ec5a41d..1e1017c8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,3 +84,5 @@ front/test/unit/coverage
front/test/e2e/reports
front/selenium-debug.log
docs/_build
+
+data/
diff --git a/CHANGELOG b/CHANGELOG
index 19cd704a1..6881b7bf0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,27 @@ Changelog
.. towncrier
+0.6.1 (unreleased)
+------------------
+
+Features:
+
+- Can now skip acoustid on file import with the --no-acoustid flag (#111)
+
+
+Bugfixes:
+
+- Added missing batch id in output during import (#112)
+- Added some feedback on the play button (#100)
+- Smarter pagination which takes a fixed size (#84)
+
+
+Other:
+
+- Completely removed django-cachalot from the codebase (#110). You can safely
+ remove the CACHALOT_ENABLED setting from your .env file
+
+
0.6 (2018-03-04)
----------------
diff --git a/api/compose/django/daphne.sh b/api/compose/django/daphne.sh
index 16b4d50b8..4fa304143 100755
--- a/api/compose/django/daphne.sh
+++ b/api/compose/django/daphne.sh
@@ -1,3 +1,3 @@
#!/bin/bash -eux
python /app/manage.py collectstatic --noinput
-/usr/local/bin/daphne --root-path=/app -b 0.0.0.0 -p 5000 config.asgi:application
+/usr/local/bin/daphne -b 0.0.0.0 -p 5000 config.asgi:application
diff --git a/api/compose/django/entrypoint.sh b/api/compose/django/entrypoint.sh
index 7e789968b..ac85f1164 100755
--- a/api/compose/django/entrypoint.sh
+++ b/api/compose/django/entrypoint.sh
@@ -4,16 +4,19 @@ set -e
# Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple
# environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint
# does all this for us.
-export CACHE_URL=redis://redis:6379/0
+export CACHE_URL=${CACHE_URL:="redis://redis:6379/0"}
-# the official postgres image uses 'postgres' as default user if not set explictly.
-if [ -z "$POSTGRES_ENV_POSTGRES_USER" ]; then
+if [ -z "$DATABASE_URL" ]; then
+ # the official postgres image uses 'postgres' as default user if not set explictly.
+ if [ -z "$POSTGRES_ENV_POSTGRES_USER" ]; then
export POSTGRES_ENV_POSTGRES_USER=postgres
+ fi
+ export DATABASE_URL=postgres://$POSTGRES_ENV_POSTGRES_USER:$POSTGRES_ENV_POSTGRES_PASSWORD@postgres:5432/$POSTGRES_ENV_POSTGRES_USER
fi
-export DATABASE_URL=postgres://$POSTGRES_ENV_POSTGRES_USER:$POSTGRES_ENV_POSTGRES_PASSWORD@postgres:5432/$POSTGRES_ENV_POSTGRES_USER
-
-export CELERY_BROKER_URL=$CACHE_URL
+if [ -z "$CELERY_BROKER_URL" ]; then
+ export CELERY_BROKER_URL=$CACHE_URL
+fi
# we copy the frontend files, if any so we can serve them from the outside
if [ -d "frontend" ]; then
diff --git a/api/config/settings/common.py b/api/config/settings/common.py
index bff43b233..1def68824 100644
--- a/api/config/settings/common.py
+++ b/api/config/settings/common.py
@@ -55,7 +55,6 @@ THIRD_PARTY_APPS = (
'rest_framework',
'rest_framework.authtoken',
'taggit',
- 'cachalot',
'rest_auth',
'rest_auth.registration',
'mptt',
@@ -310,7 +309,7 @@ CELERY_BROKER_URL = env(
"CELERY_BROKER_URL", default=env('CACHE_URL', default=CACHE_DEFAULT))
########## END CELERY
# Location of root django.contrib.admin URL, use {% url 'admin:index' %}
-ADMIN_URL = r'^admin/'
+
# Your common stuff: Below this line define 3rd party library settings
CELERY_TASK_DEFAULT_RATE_LIMIT = 1
CELERY_TASK_TIME_LIMIT = 300
@@ -371,9 +370,6 @@ MUSICBRAINZ_CACHE_DURATION = env.int(
default=300
)
-CACHALOT_ENABLED = env.bool('CACHALOT_ENABLED', default=True)
-
-
# Custom Admin URL, use {% url 'admin:index' %}
ADMIN_URL = env('DJANGO_ADMIN_URL', default='^api/admin/')
CSRF_USE_SESSIONS = True
diff --git a/api/demo/load-demo-data.sh b/api/demo/load-demo-data.sh
index c09c5075e..fab0de8b3 100755
--- a/api/demo/load-demo-data.sh
+++ b/api/demo/load-demo-data.sh
@@ -6,8 +6,8 @@ python manage.py migrate --noinput
echo "Creating demo user..."
-cat demo/demo-user.py | python manage.py shell --plain
+cat demo/demo-user.py | python manage.py shell -i python
echo "Importing demo tracks..."
-python manage.py import_files "/music/**/*.ogg" --recursive --noinput
+python manage.py import_files "/music/**/*.ogg" --recursive --noinput --username demo
diff --git a/api/funkwhale_api/__init__.py b/api/funkwhale_api/__init__.py
index c384dc521..841f2a299 100644
--- a/api/funkwhale_api/__init__.py
+++ b/api/funkwhale_api/__init__.py
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
-__version__ = '0.6'
+__version__ = '0.6.1'
__version_info__ = tuple([int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.')])
diff --git a/api/funkwhale_api/common/auth.py b/api/funkwhale_api/common/auth.py
index 6f99b3bba..75839b936 100644
--- a/api/funkwhale_api/common/auth.py
+++ b/api/funkwhale_api/common/auth.py
@@ -9,6 +9,7 @@ from rest_framework import exceptions
from rest_framework_jwt.settings import api_settings
from rest_framework_jwt.authentication import BaseJSONWebTokenAuthentication
+from funkwhale_api.users.models import User
class TokenHeaderAuth(BaseJSONWebTokenAuthentication):
@@ -40,7 +41,7 @@ class TokenAuthMiddleware:
auth = TokenHeaderAuth()
try:
user, token = auth.authenticate(scope)
- except exceptions.AuthenticationFailed:
+ except (User.DoesNotExist, exceptions.AuthenticationFailed):
user = AnonymousUser()
scope['user'] = user
diff --git a/api/funkwhale_api/music/tasks.py b/api/funkwhale_api/music/tasks.py
index cb4a737c9..bf7a847d0 100644
--- a/api/funkwhale_api/music/tasks.py
+++ b/api/funkwhale_api/music/tasks.py
@@ -1,5 +1,7 @@
from django.core.files.base import ContentFile
+from dynamic_preferences.registries import global_preferences_registry
+
from funkwhale_api.taskapp import celery
from funkwhale_api.providers.acoustid import get_acoustid_client
from funkwhale_api.providers.audiofile.tasks import import_track_data_from_path
@@ -23,21 +25,22 @@ def set_acoustid_on_track_file(track_file):
return update(result['id'])
-def _do_import(import_job, replace):
+def _do_import(import_job, replace, use_acoustid=True):
from_file = bool(import_job.audio_file)
mbid = import_job.mbid
acoustid_track_id = None
duration = None
track = None
- if not mbid and from_file:
+ manager = global_preferences_registry.manager()
+ use_acoustid = use_acoustid and manager['providers_acoustid__api_key']
+ if not mbid and use_acoustid and from_file:
# we try to deduce mbid from acoustid
client = get_acoustid_client()
match = client.get_best_match(import_job.audio_file.path)
- if not match:
- raise ValueError('Cannot get match')
- duration = match['recordings'][0]['duration']
- mbid = match['recordings'][0]['id']
- acoustid_track_id = match['id']
+ if match:
+ duration = match['recordings'][0]['duration']
+ mbid = match['recordings'][0]['id']
+ acoustid_track_id = match['id']
if mbid:
track, _ = models.Track.get_or_create_from_api(mbid=mbid)
else:
@@ -77,13 +80,13 @@ def _do_import(import_job, replace):
models.ImportJob.objects.filter(
status__in=['pending', 'errored']),
'import_job')
-def import_job_run(self, import_job, replace=False):
+def import_job_run(self, import_job, replace=False, use_acoustid=True):
def mark_errored():
import_job.status = 'errored'
- import_job.save()
+ import_job.save(update_fields=['status'])
try:
- return _do_import(import_job, replace)
+ return _do_import(import_job, replace, use_acoustid=use_acoustid)
except Exception as exc:
if not settings.DEBUG:
try:
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 17a199473..2fa5e464c 100644
--- a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py
+++ b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py
@@ -34,6 +34,13 @@ class Command(BaseCommand):
default=False,
help='Will launch celery tasks for each file to import instead of doing it synchronously and block the CLI',
)
+ parser.add_argument(
+ '--no-acoustid',
+ action='store_true',
+ dest='no_acoustid',
+ default=False,
+ help='Use this flag to completely bypass acoustid completely',
+ )
parser.add_argument(
'--noinput', '--no-input', action='store_false', dest='interactive',
help="Do NOT prompt the user for input of any kind.",
@@ -81,13 +88,12 @@ class Command(BaseCommand):
raise CommandError("Import cancelled.")
batch = self.do_import(matching, user=user, options=options)
-
message = 'Successfully imported {} tracks'
if options['async']:
message = 'Successfully launched import for {} tracks'
self.stdout.write(message.format(len(matching)))
self.stdout.write(
- "For details, please refer to import batch #".format(batch.pk))
+ "For details, please refer to import batch #{}".format(batch.pk))
@transaction.atomic
def do_import(self, matching, user, options):
@@ -109,7 +115,10 @@ class Command(BaseCommand):
job.save()
try:
- utils.on_commit(import_handler, import_job_id=job.pk)
+ utils.on_commit(
+ import_handler,
+ import_job_id=job.pk,
+ use_acoustid=not options['no_acoustid'])
except Exception as e:
self.stdout.write('Error: {}'.format(e))
diff --git a/api/funkwhale_api/templates/404.html b/api/funkwhale_api/templates/404.html
deleted file mode 100644
index b9cb60846..000000000
--- a/api/funkwhale_api/templates/404.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}Page Not found{% endblock %}
-
-{% block content %}
-
This is not the page you were looking for.
-{% endblock content %}
diff --git a/api/funkwhale_api/templates/500.html b/api/funkwhale_api/templates/500.html
deleted file mode 100644
index 21df60665..000000000
--- a/api/funkwhale_api/templates/500.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}Server Error{% endblock %}
-
-{% block content %}
-We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing.
-{% endblock content %}
-
-
diff --git a/api/funkwhale_api/templates/base.html b/api/funkwhale_api/templates/base.html
deleted file mode 100644
index e8788f44a..000000000
--- a/api/funkwhale_api/templates/base.html
+++ /dev/null
@@ -1,107 +0,0 @@
-{% load staticfiles i18n %}
-
-
-
-