From 0ce51d25d493e8c691eadbdfb7791d205e00e2ed Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Tue, 9 Apr 2019 11:11:05 +0200
Subject: [PATCH] Can now edit track copyright information

---
 api/funkwhale_api/music/mutations.py       |  2 +-
 api/tests/music/test_mutations.py          | 11 +++++++++++
 front/src/components/library/TrackEdit.vue |  5 ++++-
 front/src/edits.js                         | 23 ++++++++++++++--------
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/api/funkwhale_api/music/mutations.py b/api/funkwhale_api/music/mutations.py
index 51efa0ab8..4d78b8ea9 100644
--- a/api/funkwhale_api/music/mutations.py
+++ b/api/funkwhale_api/music/mutations.py
@@ -21,4 +21,4 @@ class TrackMutationSerializer(mutations.UpdateMutationSerializer):
 
     class Meta:
         model = models.Track
-        fields = ["license", "title", "position"]
+        fields = ["license", "title", "position", "copyright"]
diff --git a/api/tests/music/test_mutations.py b/api/tests/music/test_mutations.py
index 062d00f98..bc9e81f8e 100644
--- a/api/tests/music/test_mutations.py
+++ b/api/tests/music/test_mutations.py
@@ -36,6 +36,17 @@ def test_track_title_mutation(factories, now):
     assert track.title == "bar"
 
 
+def test_track_copyright_mutation(factories, now):
+    track = factories["music.Track"](copyright="foo")
+    mutation = factories["common.Mutation"](
+        type="update", target=track, payload={"copyright": "bar"}
+    )
+    mutation.apply()
+    track.refresh_from_db()
+
+    assert track.copyright == "bar"
+
+
 def test_track_position_mutation(factories):
     track = factories["music.Track"](position=4)
     mutation = factories["common.Mutation"](
diff --git a/front/src/components/library/TrackEdit.vue b/front/src/components/library/TrackEdit.vue
index 32b3a627a..945bae961 100644
--- a/front/src/components/library/TrackEdit.vue
+++ b/front/src/components/library/TrackEdit.vue
@@ -12,8 +12,11 @@
         :object="object"
         :can-edit="canEdit"
         :licenses="licenses"></edit-form>
+      <div v-else class="ui inverted active dimmer">
+        <div class="ui loader"></div>
       </div>
-    </section>
+    </div>
+  </section>
 </template>
 
 <script>
diff --git a/front/src/edits.js b/front/src/edits.js
index 4e6a85c73..c72cb4b09 100644
--- a/front/src/edits.js
+++ b/front/src/edits.js
@@ -10,13 +10,6 @@ export default {
             label: this.$pgettext('Content/Track/*/Noun', 'Title'),
             getValue: (obj) => { return obj.title }
           },
-          {
-            id: 'license',
-            type: 'license',
-            required: false,
-            label: this.$pgettext('Content/*/*/Noun', 'License'),
-            getValue: (obj) => { return obj.license },
-          },
           {
             id: 'position',
             type: 'text',
@@ -24,7 +17,21 @@ export default {
             required: false,
             label: this.$pgettext('*/*/*/Short, Noun', 'Position'),
             getValue: (obj) => { return obj.position }
-          }
+          },
+          {
+            id: 'copyright',
+            type: 'text',
+            required: false,
+            label: this.$pgettext('Content/Track/*/Noun', 'Copyright'),
+            getValue: (obj) => { return obj.copyright }
+          },
+          {
+            id: 'license',
+            type: 'license',
+            required: false,
+            label: this.$pgettext('Content/*/*/Noun', 'License'),
+            getValue: (obj) => { return obj.license },
+          },
         ]
       }
     }
-- 
GitLab