Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale_OLD
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jovuit
funkwhale_OLD
Commits
df632521
Verified
Commit
df632521
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Models and migrations for custom radios
parent
c7636c95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/radios/migrations/0004_auto_20180107_1813.py
+36
-0
36 additions, 0 deletions
...unkwhale_api/radios/migrations/0004_auto_20180107_1813.py
api/funkwhale_api/radios/models.py
+30
-0
30 additions, 0 deletions
api/funkwhale_api/radios/models.py
with
66 additions
and
0 deletions
api/funkwhale_api/radios/migrations/0004_auto_20180107_1813.py
0 → 100644
+
36
−
0
View file @
df632521
# Generated by Django 2.0 on 2018-01-07 18:13
from
django.conf
import
settings
import
django.contrib.postgres.fields.jsonb
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'
radios
'
,
'
0003_auto_20160521_1708
'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'
Radio
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
name
'
,
models
.
CharField
(
max_length
=
100
)),
(
'
description
'
,
models
.
TextField
(
blank
=
True
)),
(
'
creation_date
'
,
models
.
DateTimeField
(
default
=
django
.
utils
.
timezone
.
now
)),
(
'
is_public
'
,
models
.
BooleanField
(
default
=
False
)),
(
'
version
'
,
models
.
PositiveIntegerField
(
default
=
0
)),
(
'
config
'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
()),
(
'
user
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
radios
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
migrations
.
AddField
(
model_name
=
'
radiosession
'
,
name
=
'
custom_radio
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
sessions
'
,
to
=
'
radios.Radio
'
),
),
]
This diff is collapsed.
Click to expand it.
api/funkwhale_api/radios/models.py
+
30
−
0
View file @
df632521
from
django.db
import
models
from
django.utils
import
timezone
from
django.core.exceptions
import
ValidationError
from
django.contrib.postgres.fields
import
JSONField
from
django.contrib.contenttypes.fields
import
GenericForeignKey
from
django.contrib.contenttypes.models
import
ContentType
from
funkwhale_api.music.models
import
Track
from
.
import
filters
class
Radio
(
models
.
Model
):
CONFIG_VERSION
=
0
user
=
models
.
ForeignKey
(
'
users.User
'
,
related_name
=
'
radios
'
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
CASCADE
)
name
=
models
.
CharField
(
max_length
=
100
)
description
=
models
.
TextField
(
blank
=
True
)
creation_date
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
is_public
=
models
.
BooleanField
(
default
=
False
)
version
=
models
.
PositiveIntegerField
(
default
=
0
)
config
=
JSONField
()
def
get_candidates
(
self
):
return
filters
.
run
(
self
.
config
)
class
RadioSession
(
models
.
Model
):
user
=
models
.
ForeignKey
(
'
users.User
'
,
...
...
@@ -15,6 +38,12 @@ class RadioSession(models.Model):
on_delete
=
models
.
CASCADE
)
session_key
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
blank
=
True
)
radio_type
=
models
.
CharField
(
max_length
=
50
)
custom_radio
=
models
.
ForeignKey
(
Radio
,
related_name
=
'
sessions
'
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
CASCADE
)
creation_date
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
related_object_content_type
=
models
.
ForeignKey
(
ContentType
,
...
...
@@ -51,6 +80,7 @@ class RadioSession(models.Model):
from
.
import
radios
return
registry
[
self
.
radio_type
](
session
=
self
)
class
RadioSessionTrack
(
models
.
Model
):
session
=
models
.
ForeignKey
(
RadioSession
,
related_name
=
'
session_tracks
'
,
on_delete
=
models
.
CASCADE
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment