Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
funkwhale
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
172
Issues
172
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
funkwhale
funkwhale
Commits
dcb66690
Verified
Commit
dcb66690
authored
Dec 13, 2017
by
Agate
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #7: store release-group id on Album
parent
4c9469ac
Pipeline
#267
passed with stage
in 47 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
4 deletions
+93
-4
CHANGELOG
CHANGELOG
+8
-0
api/funkwhale_api/music/migrations/0013_auto_20171213_2211.py
...funkwhale_api/music/migrations/0013_auto_20171213_2211.py
+28
-0
api/funkwhale_api/music/models.py
api/funkwhale_api/music/models.py
+6
-1
api/funkwhale_api/music/tests/factories.py
api/funkwhale_api/music/tests/factories.py
+1
-0
api/funkwhale_api/music/tests/test_models.py
api/funkwhale_api/music/tests/test_models.py
+41
-0
dev.yml
dev.yml
+9
-3
No files found.
CHANGELOG
0 → 100644
View file @
dcb66690
Changelog
=========
0.2.4 (unreleased)
------------------
Models: now store relese group mbid on Album model (#7)
api/funkwhale_api/music/migrations/0013_auto_20171213_2211.py
0 → 100644
View file @
dcb66690
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-12-13 22:11
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'music'
,
'0012_auto_20161122_1905'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'importjob'
,
options
=
{
'ordering'
:
(
'id'
,)},
),
migrations
.
AlterModelOptions
(
name
=
'track'
,
options
=
{
'ordering'
:
[
'album'
,
'position'
]},
),
migrations
.
AddField
(
model_name
=
'album'
,
name
=
'release_group_id'
,
field
=
models
.
UUIDField
(
blank
=
True
,
null
=
True
),
),
]
api/funkwhale_api/music/models.py
View file @
dcb66690
...
...
@@ -110,13 +110,14 @@ class Album(APIModelMixin):
title
=
models
.
CharField
(
max_length
=
255
)
artist
=
models
.
ForeignKey
(
Artist
,
related_name
=
'albums'
)
release_date
=
models
.
DateField
(
null
=
True
)
release_group_id
=
models
.
UUIDField
(
null
=
True
,
blank
=
True
)
cover
=
VersatileImageField
(
upload_to
=
'albums/covers/%Y/%m/%d'
,
null
=
True
,
blank
=
True
)
TYPE_CHOICES
=
(
(
'album'
,
'Album'
),
)
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
30
,
default
=
'album'
)
api_includes
=
[
'artist-credits'
,
'recordings'
,
'media'
]
api_includes
=
[
'artist-credits'
,
'recordings'
,
'media'
,
'release-groups'
]
api
=
musicbrainz
.
api
.
releases
musicbrainz_model
=
'release'
musicbrainz_mapping
=
{
...
...
@@ -127,6 +128,10 @@ class Album(APIModelMixin):
'musicbrainz_field_name'
:
'release-list'
,
'converter'
:
lambda
v
:
int
(
v
[
0
][
'medium-list'
][
0
][
'position'
]),
},
'release_group_id'
:
{
'musicbrainz_field_name'
:
'release-group'
,
'converter'
:
lambda
v
:
v
[
'id'
],
},
'title'
:
{
'musicbrainz_field_name'
:
'title'
,
},
...
...
api/funkwhale_api/music/tests/factories.py
View file @
dcb66690
...
...
@@ -18,6 +18,7 @@ class AlbumFactory(factory.django.DjangoModelFactory):
release_date
=
factory
.
Faker
(
'date'
)
cover
=
factory
.
django
.
ImageField
()
artist
=
factory
.
SubFactory
(
ArtistFactory
)
release_group_id
=
factory
.
Faker
(
'uuid4'
)
class
Meta
:
model
=
'music.Album'
...
...
api/funkwhale_api/music/tests/test_models.py
0 → 100644
View file @
dcb66690
import
pytest
from
funkwhale_api.music
import
models
from
funkwhale_api.music
import
importers
from
.
import
factories
def
test_can_store_release_group_id_on_album
(
db
):
album
=
factories
.
AlbumFactory
()
assert
album
.
release_group_id
is
not
None
def
test_import_album_stores_release_group
(
db
):
album_data
=
{
"artist-credit"
:
[
{
"artist"
:
{
"disambiguation"
:
"George Shaw"
,
"id"
:
"62c3befb-6366-4585-b256-809472333801"
,
"name"
:
"Adhesive Wombat"
,
"sort-name"
:
"Wombat, Adhesive"
}
}
],
"artist-credit-phrase"
:
"Adhesive Wombat"
,
"country"
:
"XW"
,
"date"
:
"2013-06-05"
,
"id"
:
"a50d2a81-2a50-484d-9cb4-b9f6833f583e"
,
"status"
:
"Official"
,
"title"
:
"Marsupial Madness"
,
'release-group'
:
{
'id'
:
'447b4979-2178-405c-bfe6-46bf0b09e6c7'
}
}
artist
=
factories
.
ArtistFactory
(
mbid
=
album_data
[
'artist-credit'
][
0
][
'artist'
][
'id'
]
)
cleaned_data
=
models
.
Album
.
clean_musicbrainz_data
(
album_data
)
album
=
importers
.
load
(
models
.
Album
,
cleaned_data
,
album_data
,
import_hooks
=
[])
assert
album
.
release_group_id
==
album_data
[
'release-group'
][
'id'
]
assert
album
.
artist
==
artist
dev.yml
View file @
dcb66690
...
...
@@ -33,9 +33,12 @@ services:
-
redis
command
:
python manage.py celery worker
environment
:
-
C_FORCE_ROOT=true
-
"
DATABASE_URL=postgresql://postgres@postgres/postgres"
-
"
CACHE_URL=redis://redis:6379/0"
-
"
DJANGO_ALLOWED_HOSTS=localhost"
-
"
DJANGO_SETTINGS_MODULE=config.settings.local"
-
"
DJANGO_SECRET_KEY=dev"
-
C_FORCE_ROOT=true
-
"
DATABASE_URL=postgresql://postgres@postgres/postgres"
-
"
CACHE_URL=redis://redis:6379/0"
volumes
:
-
./api:/app
-
./data/music:/music
...
...
@@ -49,6 +52,9 @@ services:
-
./api:/app
-
./data/music:/music
environment
:
-
"
DJANGO_ALLOWED_HOSTS=localhost"
-
"
DJANGO_SETTINGS_MODULE=config.settings.local"
-
"
DJANGO_SECRET_KEY=dev"
-
"
DATABASE_URL=postgresql://postgres@postgres/postgres"
-
"
CACHE_URL=redis://redis:6379/0"
ports
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment