From be067b9ee35e5a7ff6abd98d627fc6309bec9c38 Mon Sep 17 00:00:00 2001
From: Eliot Berriot
Date: Mon, 23 Mar 2020 10:44:09 +0100
Subject: [PATCH] See #170: subscriptions management UI
---
api/funkwhale_api/audio/serializers.py | 9 +-
api/funkwhale_api/common/utils.py | 12 +-
api/tests/audio/test_serializers.py | 8 +-
front/src/components/RemoteSearchForm.vue | 188 ++++++++++++++++++
front/src/components/Sidebar.vue | 3 +
front/src/components/audio/ChannelCard.vue | 27 ++-
.../src/components/common/InlineSearchBar.vue | 7 +-
front/src/components/semantic/Modal.vue | 5 +-
front/src/filters.js | 30 ++-
front/src/router/index.js | 13 ++
front/src/style/_main.scss | 40 +++-
front/src/views/Search.vue | 154 +-------------
.../src/views/channels/SubscriptionsList.vue | 103 ++++++++++
13 files changed, 414 insertions(+), 185 deletions(-)
create mode 100644 front/src/components/RemoteSearchForm.vue
create mode 100644 front/src/views/channels/SubscriptionsList.vue
diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py
index cffa49b28..6b9227ded 100644
--- a/api/funkwhale_api/audio/serializers.py
+++ b/api/funkwhale_api/audio/serializers.py
@@ -384,12 +384,9 @@ def get_channel_from_rss_url(url, raise_exception=False):
library=channel.library,
delete_existing=True,
)
- latest_upload_date = max([upload.creation_date for upload in uploads])
- if (
- not channel.artist.modification_date
- or channel.artist.modification_date < latest_upload_date
- ):
- common_utils.update_modification_date(channel.artist)
+ if uploads:
+ latest_track_date = max([upload.track.creation_date for upload in uploads])
+ common_utils.update_modification_date(channel.artist, date=latest_track_date)
return channel, uploads
diff --git a/api/funkwhale_api/common/utils.py b/api/funkwhale_api/common/utils.py
index 98fd21355..6c4238fc4 100644
--- a/api/funkwhale_api/common/utils.py
+++ b/api/funkwhale_api/common/utils.py
@@ -410,15 +410,15 @@ def get_audio_mimetype(mt):
return aliases.get(mt, mt)
-def update_modification_date(obj, field="modification_date"):
+def update_modification_date(obj, field="modification_date", date=None):
IGNORE_DELAY = 60
current_value = getattr(obj, field)
- now = timezone.now()
- ignore = current_value is not None and current_value < now - datetime.timedelta(
+ date = date or timezone.now()
+ ignore = current_value is not None and current_value < date - datetime.timedelta(
seconds=IGNORE_DELAY
)
if ignore:
- setattr(obj, field, now)
- obj.__class__.objects.filter(pk=obj.pk).update(**{field: now})
+ setattr(obj, field, date)
+ obj.__class__.objects.filter(pk=obj.pk).update(**{field: date})
- return now
+ return date
diff --git a/api/tests/audio/test_serializers.py b/api/tests/audio/test_serializers.py
index f1dcd21c6..5ddef7c29 100644
--- a/api/tests/audio/test_serializers.py
+++ b/api/tests/audio/test_serializers.py
@@ -791,7 +791,7 @@ def test_get_channel_from_rss_url(db, r_mock, mocker):
Subtitle
Html content
]]>
- Wed, 11 Mar 2020 16:00:00 GMT
+ Wed, 11 Mar 2020 18:00:00 GMT
00:22:37
pop rock
2
@@ -806,7 +806,7 @@ def test_get_channel_from_rss_url(db, r_mock, mocker):
Subtitle
Html content]]>
- Wed, 11 Mar 2020 16:00:00 GMT
+ Wed, 11 Mar 2020 17:00:00 GMT
00:22:37
pop rock
2
@@ -865,7 +865,9 @@ def test_get_channel_from_rss_url(db, r_mock, mocker):
library=channel.library,
delete_existing=True,
)
- update_modification_date.assert_called_once_with(channel.artist)
+ update_modification_date.assert_called_once_with(
+ channel.artist, date=uploads[0].track.creation_date
+ )
def test_get_channel_from_rss_honor_mrf_inbox_before_http(
diff --git a/front/src/components/RemoteSearchForm.vue b/front/src/components/RemoteSearchForm.vue
new file mode 100644
index 000000000..56167216f
--- /dev/null
+++ b/front/src/components/RemoteSearchForm.vue
@@ -0,0 +1,188 @@
+
+
+
+
+
This kind of object isn't supported yet
+
+
+
+
diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue
index 732847ef5..a6e63f4d9 100644
--- a/front/src/components/Sidebar.vue
+++ b/front/src/components/Sidebar.vue
@@ -134,6 +134,9 @@
Favorites
+
@@ -31,6 +39,8 @@
import PlayButton from '@/components/audio/PlayButton'
import TagsList from "@/components/tags/List"
+import {momentFormat} from '@/filters'
+
export default {
props: {
object: {type: Object},
@@ -58,6 +68,11 @@ export default {
} else {
return this.object.uuid
}
+ },
+ updatedTitle () {
+ let d = momentFormat(this.object.artist.modification_date)
+ let message = this.$pgettext('*/*/*', 'Updated on %{ date }')
+ return this.$gettextInterpolate(message, {date: d})
}
}
}
diff --git a/front/src/components/common/InlineSearchBar.vue b/front/src/components/common/InlineSearchBar.vue
index 0ba6d85a9..3a32b84c0 100644
--- a/front/src/components/common/InlineSearchBar.vue
+++ b/front/src/components/common/InlineSearchBar.vue
@@ -4,8 +4,8 @@
-
-
+
+
@@ -15,7 +15,8 @@
diff --git a/front/src/views/channels/SubscriptionsList.vue b/front/src/views/channels/SubscriptionsList.vue
new file mode 100644
index 000000000..f3b3ff796
--- /dev/null
+++ b/front/src/views/channels/SubscriptionsList.vue
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+
+
+
+
+
+
+
+
+
+