mirror of
https://github.com/fergalmoran/dss.api.git
synced 2026-02-05 15:24:24 +00:00
Merge branch 'feature/embed' into develop
This commit is contained in:
@@ -146,7 +146,9 @@ class MixSerializer(serializers.ModelSerializer):
|
||||
'waveform_url',
|
||||
'waveform_progress_url',
|
||||
'mix_image',
|
||||
'download_allowed',
|
||||
'is_featured',
|
||||
'is_downloadable',
|
||||
'is_private',
|
||||
'can_edit',
|
||||
'genres',
|
||||
'likes',
|
||||
|
||||
10
api/views.py
10
api/views.py
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist, SuspiciousOperation
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
@@ -15,7 +14,6 @@ from rest_framework.permissions import IsAuthenticated, IsAuthenticatedOrReadOnl
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.status import HTTP_202_ACCEPTED, HTTP_401_UNAUTHORIZED, HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND, \
|
||||
HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_500_INTERNAL_SERVER_ERROR
|
||||
|
||||
from api import serializers
|
||||
from dss import settings
|
||||
from spa import tasks
|
||||
@@ -116,8 +114,11 @@ class MixViewSet(viewsets.ModelViewSet):
|
||||
raise PermissionDenied("Not allowed")
|
||||
if 'random' in self.request.query_params:
|
||||
return Mix.objects.order_by('?').all()
|
||||
else:
|
||||
if 'slug' in self.kwargs:
|
||||
""" could be private mix so don't filter """
|
||||
return Mix.objects.all()
|
||||
else:
|
||||
return Mix.objects.filter(is_private=False)
|
||||
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(user=self.request.user.userprofile)
|
||||
@@ -181,6 +182,7 @@ class SearchResultsView(views.APIView):
|
||||
|
||||
class PartialMixUploadView(views.APIView):
|
||||
parser_classes = (FileUploadParser,)
|
||||
|
||||
# TODO have to make this anonymous (for now) because dropzone doesn't play nice with JWT
|
||||
# permission_classes = (IsAuthenticated,)
|
||||
|
||||
@@ -218,7 +220,7 @@ class PartialMixUploadView(views.APIView):
|
||||
(
|
||||
tasks.create_waveform_task.s(input_file, uid) |
|
||||
tasks.upload_to_cdn_task.subtask(('mp3', uid, 'mixes'), immutable=True) |
|
||||
tasks.upload_to_cdn_task.subtask (('png', uid, 'waveforms'), immutable=True) |
|
||||
tasks.upload_to_cdn_task.subtask(('png', uid, 'waveforms'), immutable=True) |
|
||||
tasks.notify_subscriber.subtask((session_id, uid), immutable=True)
|
||||
).delay()
|
||||
logger.debug("Waveform task started")
|
||||
|
||||
28
spa/migrations/0021_auto_20151112_2017.py
Normal file
28
spa/migrations/0021_auto_20151112_2017.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('spa', '0020_blogcomment'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='mix',
|
||||
name='download_allowed',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mix',
|
||||
name='is_downloadable',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mix',
|
||||
name='is_private',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
||||
24
spa/migrations/0022_auto_20151112_2017.py
Normal file
24
spa/migrations/0022_auto_20151112_2017.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('spa', '0021_auto_20151112_2017'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='mix',
|
||||
name='is_featured',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='mix',
|
||||
name='is_private',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -71,14 +71,15 @@ class Mix(BaseModel):
|
||||
upload_date = models.DateTimeField(auto_now_add=True)
|
||||
mix_image = models.ImageField(max_length=1024, blank=True, upload_to=mix_image_name)
|
||||
is_active = models.BooleanField(default=True)
|
||||
is_featured = models.BooleanField(default=True)
|
||||
is_featured = models.BooleanField(default=False)
|
||||
is_private = models.BooleanField(default=False)
|
||||
is_downloadable = models.BooleanField(default=True)
|
||||
user = models.ForeignKey(UserProfile, related_name='mixes')
|
||||
waveform_generated = models.BooleanField(default=False)
|
||||
waveform_version = models.IntegerField(default=1)
|
||||
mp3tags_updated = models.BooleanField(default=False)
|
||||
uid = models.CharField(max_length=38, blank=True, unique=True)
|
||||
filetype = models.CharField(max_length=10, blank=False, default="mp3")
|
||||
download_allowed = models.BooleanField(default=False)
|
||||
duration = models.IntegerField(null=True, blank=True)
|
||||
archive_path = models.CharField(max_length=2048, null=True, blank=True)
|
||||
archive_updated = models.BooleanField(default=False)
|
||||
|
||||
Reference in New Issue
Block a user