From 1f3f790f63ff49f065666901d19d4e66dee78e1d Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Thu, 9 May 2019 12:13:00 +0200
Subject: [PATCH] Fix #819: Fixed invalid required fields in Upload django's
 admin

---
 api/funkwhale_api/federation/models.py | 10 +++++++---
 api/funkwhale_api/music/models.py      |  8 ++++----
 changes/changelog.d/819.bugfix         |  1 +
 3 files changed, 12 insertions(+), 7 deletions(-)
 create mode 100644 changes/changelog.d/819.bugfix

diff --git a/api/funkwhale_api/federation/models.py b/api/funkwhale_api/federation/models.py
index 3e3cb0e5..d530c62d 100644
--- a/api/funkwhale_api/federation/models.py
+++ b/api/funkwhale_api/federation/models.py
@@ -325,7 +325,9 @@ class Fetch(models.Model):
     )
     object = GenericForeignKey("object_content_type", "object_id")
     status = models.CharField(default="pending", choices=FETCH_STATUSES, max_length=20)
-    detail = JSONField(default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder)
+    detail = JSONField(
+        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
+    )
     actor = models.ForeignKey(Actor, related_name="fetches", on_delete=models.CASCADE)
 
     objects = FetchQuerySet.as_manager()
@@ -390,7 +392,9 @@ class Activity(models.Model):
     uuid = models.UUIDField(default=uuid.uuid4, unique=True)
     fid = models.URLField(unique=True, max_length=500, null=True, blank=True)
     url = models.URLField(max_length=500, null=True, blank=True)
-    payload = JSONField(default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder)
+    payload = JSONField(
+        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
+    )
     creation_date = models.DateTimeField(default=timezone.now, db_index=True)
     type = models.CharField(db_index=True, null=True, max_length=100)
 
@@ -506,7 +510,7 @@ class LibraryTrack(models.Model):
     album_title = models.CharField(max_length=500)
     title = models.CharField(max_length=500)
     metadata = JSONField(
-        default=empty_dict, max_length=10000, encoder=DjangoJSONEncoder
+        default=empty_dict, max_length=10000, encoder=DjangoJSONEncoder, blank=True
     )
 
     @property
diff --git a/api/funkwhale_api/music/models.py b/api/funkwhale_api/music/models.py
index fdc4f87f..309eb126 100644
--- a/api/funkwhale_api/music/models.py
+++ b/api/funkwhale_api/music/models.py
@@ -642,12 +642,12 @@ class Upload(models.Model):
 
     # metadata from federation
     metadata = JSONField(
-        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder
+        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
     )
     import_date = models.DateTimeField(null=True, blank=True)
     # optionnal metadata provided during import
     import_metadata = JSONField(
-        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder
+        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
     )
     # status / error details for the import
     import_status = models.CharField(
@@ -659,10 +659,10 @@ class Upload(models.Model):
 
     # optionnal metadata about import results (error messages, etc.)
     import_details = JSONField(
-        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder
+        default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
     )
     from_activity = models.ForeignKey(
-        "federation.Activity", null=True, on_delete=models.SET_NULL
+        "federation.Activity", null=True, on_delete=models.SET_NULL, blank=True
     )
 
     objects = UploadQuerySet.as_manager()
diff --git a/changes/changelog.d/819.bugfix b/changes/changelog.d/819.bugfix
new file mode 100644
index 00000000..a1977568
--- /dev/null
+++ b/changes/changelog.d/819.bugfix
@@ -0,0 +1 @@
+Fixed invalid required fields in Upload django's admin (#819)
-- 
GitLab