Fix #869: broken user admin for users with non-digit or letters in their username

plugins
Eliot Berriot 2019-06-27 14:50:56 +02:00
rodzic cbe496e47b
commit dc5db3a0c1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
4 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

@ -44,12 +44,14 @@ class ManageUserSimpleSerializer(serializers.ModelSerializer):
class ManageUserSerializer(serializers.ModelSerializer):
permissions = PermissionsSerializer(source="*")
upload_quota = serializers.IntegerField(allow_null=True)
actor = serializers.SerializerMethodField()
class Meta:
model = users_models.User
fields = (
"id",
"username",
"actor",
"email",
"name",
"is_active",
@ -82,6 +84,10 @@ class ManageUserSerializer(serializers.ModelSerializer):
)
return instance
def get_actor(self, obj):
if obj.actor:
return ManageBaseActorSerializer(obj.actor).data
class ManageInvitationSerializer(serializers.ModelSerializer):
users = ManageUserSimpleSerializer(many=True, required=False)

Wyświetl plik

@ -291,7 +291,7 @@ class ManageUserViewSet(
mixins.UpdateModelMixin,
viewsets.GenericViewSet,
):
queryset = users_models.User.objects.all().order_by("-id")
queryset = users_models.User.objects.all().select_related("actor").order_by("-id")
serializer_class = serializers.ManageUserSerializer
filterset_class = filters.ManageUserFilterSet
required_scope = "instance:users"

Wyświetl plik

@ -0,0 +1 @@
Fixed broken user admin for users with non-digit or letters in their username (#869)

Wyświetl plik

@ -45,7 +45,8 @@
</template>
<template slot="row-cells" slot-scope="scope">
<td>
<router-link :to="{name: 'manage.moderation.accounts.detail', params: {id: scope.obj.full_username }}">{{ scope.obj.username }}</router-link>
<router-link v-if="scope.obj.actor" :to="{name: 'manage.moderation.accounts.detail', params: {id: scope.obj.actor.full_username }}">{{ scope.obj.username }}</router-link>
<router-link v-else :to="{name: 'manage.moderation.accounts.detail', params: {id: scope.obj.full_username }}">{{ scope.obj.username }}</router-link>
</td>
<td>
<span>{{ scope.obj.email }}</span>