Refactors en stemmen werkt

This commit is contained in:
2024-02-07 14:07:36 +01:00
parent 0f5090cadc
commit 48dcf3bd9d
8 changed files with 61 additions and 34 deletions
+1
View File
@@ -1,3 +1,4 @@
from .track import Track
from .artist import Artist
from .album import Album
from .vote import Vote
+1 -1
View File
@@ -1,7 +1,7 @@
from django.db import models
from random import choice
from .album import Album
from .artist import Artist
from .utils import from_json
class TrackManager(models.Manager):
def get_queryset(self):
-1
View File
@@ -1 +0,0 @@
from .json import from_json
-8
View File
@@ -1,8 +0,0 @@
def from_json(cls, json):
try:
return cls.objects.get(pk=json["id"])
except cls.DoesNotExist:
keys = [f.name for f in cls._meta.get_fields()]
subset = {key:json[key] for key in set(keys) & set(json.keys())}
return cls.objects.create(**subset)