Skip to content

Commit

Permalink
Add release year and country data to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavAndreasson committed Feb 11, 2024
1 parent 41e7bc4 commit 0002abc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.8 on 2024-02-11 11:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('records', '0019_rename_collectionupdated_artist_collection_updated'),
]

operations = [
migrations.AddField(
model_name='record',
name='release_country',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='record',
name='release_year',
field=models.IntegerField(blank=True, null=True),
),
]
4 changes: 4 additions & 0 deletions records/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Record(models.Model):
master = models.IntegerField(blank=True, null=True)
cover = models.CharField(max_length=255, blank=True, null=True)
year = models.IntegerField(blank=True, null=True)
release_year = models.IntegerField(blank=True, null=True)
release_country = models.CharField(max_length=255, blank=True, null=True)
updated = models.DateField(blank=True, null=True)
thumbnail = models.CharField(max_length=255, blank=True, null=True)
price = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True)
Expand All @@ -108,6 +110,8 @@ def to_dict(self):
"master": self.master,
"cover": self.cover_file.url if self.cover_file else self.cover,
"year": self.year,
"release_year": self.release_year,
"release_country": self.release_country,
"thumbnail": self.thumbnail_file.url if self.thumbnail_file else self.thumbnail, # type: ignore
"price": str(self.price) if self.price else None,
"genres": [genre.name for genre in self.genres.all()],
Expand Down
5 changes: 3 additions & 2 deletions records/services/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def createRecord(id: int, data: dict) -> Record:
"master": master_id,
"cover": data.get("cover"),
"thumbnail": data.get("thumbnail"),
"year": data.get("year"),
"release_year": data.get("year"),
},
)
if created:
Expand Down Expand Up @@ -96,7 +96,8 @@ def updateRecord(record: Record) -> bool:
"Error when downloading cover art for " + record.name + " (" + str(record.id) + ")\n" + str(e)
)
__updateListens(record, release_data.videos or [])
record.year = release_data.year
record.release_year = release_data.year
record.release_country = release_data.country
if release_data.formats:
RecordFormats.objects.filter(record=record).delete()
r_formats = __getFormats(release_data.formats)
Expand Down

0 comments on commit 0002abc

Please sign in to comment.