See #170: display info that RSS feed is mirrored

environments/review-front-list-6rg6z1/deployments/4496
Eliot Berriot 2020-03-13 12:58:39 +01:00
rodzic ec99d52919
commit ae31b1e720
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6B501DFD73514E14
3 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -239,6 +239,7 @@ class ChannelSerializer(serializers.ModelSerializer):
actor = serializers.SerializerMethodField() actor = serializers.SerializerMethodField()
attributed_to = federation_serializers.APIActorSerializer() attributed_to = federation_serializers.APIActorSerializer()
rss_url = serializers.CharField(source="get_rss_url") rss_url = serializers.CharField(source="get_rss_url")
url = serializers.SerializerMethodField()
class Meta: class Meta:
model = models.Channel model = models.Channel
@ -250,6 +251,7 @@ class ChannelSerializer(serializers.ModelSerializer):
"creation_date", "creation_date",
"metadata", "metadata",
"rss_url", "rss_url",
"url",
] ]
def get_artist(self, obj): def get_artist(self, obj):
@ -269,6 +271,9 @@ class ChannelSerializer(serializers.ModelSerializer):
return None return None
return federation_serializers.APIActorSerializer(obj.actor).data return federation_serializers.APIActorSerializer(obj.actor).data
def get_url(self, obj):
return obj.actor.url
class SubscriptionSerializer(serializers.Serializer): class SubscriptionSerializer(serializers.Serializer):
approved = serializers.BooleanField(read_only=True) approved = serializers.BooleanField(read_only=True)

Wyświetl plik

@ -227,6 +227,7 @@ def test_channel_serializer_representation(factories, to_api_date):
).data, ).data,
"metadata": {}, "metadata": {},
"rss_url": channel.get_rss_url(), "rss_url": channel.get_rss_url(),
"url": channel.actor.url,
} }
expected["artist"]["description"] = common_serializers.ContentSerializer( expected["artist"]["description"] = common_serializers.ContentSerializer(
content content
@ -249,6 +250,7 @@ def test_channel_serializer_external_representation(factories, to_api_date):
).data, ).data,
"metadata": {}, "metadata": {},
"rss_url": channel.get_rss_url(), "rss_url": channel.get_rss_url(),
"url": channel.actor.url,
} }
expected["artist"]["description"] = common_serializers.ContentSerializer( expected["artist"]["description"] = common_serializers.ContentSerializer(
content content

Wyświetl plik

@ -128,6 +128,12 @@
<div class="sub header ellipsis" v-if="object.actor ":title="object.actor.full_username"> <div class="sub header ellipsis" v-if="object.actor ":title="object.actor.full_username">
{{ object.actor.full_username }} {{ object.actor.full_username }}
</div> </div>
<div v-else class="sub header ellipsis">
<a :href="object.url || object.rss_url" rel="noopener noreferrer" target="_blank">
<i class="external link icon"></i>
<translate :translate-params="{domain: externalDomain}" translate-context="Content/Channel/Paragraph">Mirrored from %{ domain }</translate>
</a>
</div>
</div> </div>
</h1> </h1>
<div class="header-buttons"> <div class="header-buttons">
@ -298,6 +304,12 @@ export default {
} }
}, },
computed: { computed: {
externalDomain () {
let parser = document.createElement('a')
parser.href = this.object.url || this.object.rss_url
return parser.hostname
},
isOwner () { isOwner () {
return this.$store.state.auth.authenticated && this.object.attributed_to.full_username === this.$store.state.auth.fullUsername return this.$store.state.auth.authenticated && this.object.attributed_to.full_username === this.$store.state.auth.fullUsername
}, },