Skip to content
Snippets Groups Projects
Commit 3ad62870 authored by Julian's avatar Julian
Browse files

Display correct avatar content in person list

parent cd60350f
No related branches found
No related tags found
2 merge requests!1123Resolve "Finalise Vuetify app as SPA",!1066Translations update from Weblate
<template>
<ApolloQuery
:query="require('./avatarContent.graphql')"
:variables="{'id': id}"
class="fullwidth"
>
<template #default="{ result: { error, data, loading } }">
<template v-if="loading">
<v-row
class="fill-height ma-0"
align="center"
justify="center"
>
<v-progress-circular
indeterminate
color="grey lighten-5"
></v-progress-circular>
</v-row>
</template>
<v-img
v-if="data && data.person && data.person.image"
:src="data.person.image"
:alt="$t('person.avatar')"
max-width="100%"
:contain="contain"
/>
<v-icon
class="grey lighten-1"
dark
v-else
>
mdi-folder
</v-icon>
</template>
</ApolloQuery>
</template>
<script>
export default {
name: "AvatarContent",
props: {
id: {
type: String,
required: false,
},
contain: {
type: Boolean,
required: false,
default: false
}
}
}
</script>
<style scoped>
.fullwidth {
width: 100%;
}
</style>
......@@ -8,18 +8,12 @@
:to="{ name: 'core.personById', params: { id: person.id }}"
>
<v-list-item-avatar>
<!-- FIXME: correct avatar -->
<v-icon
class="grey lighten-1"
dark
>
mdi-folder
</v-icon>
</v-list-item-avatar>
<AvatarContent :id="person.id" />
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="person.fullName"></v-list-item-title>
</v-list-item-content>
<v-list-item-content>
<v-list-item-title v-text="person.fullName"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<p v-else>
......@@ -28,8 +22,11 @@
</template>
<script>
import AvatarContent from "./AvatarContent.vue";
export default {
name: "PersonList",
components: {AvatarContent},
props: {
persons: {
type: Array,
......
query avatarContent($id: ID) {
person: personByIdOrMe(id: $id) {
image: avatarContentUrl
}
}
......@@ -9,6 +9,7 @@ from graphene_django.forms.mutation import DjangoModelFormMutation
from ..forms import PersonForm
from ..models import DummyPerson, Person
from ..util.core_helpers import get_site_preferences
class FieldFileType(graphene.ObjectType):
......@@ -35,6 +36,7 @@ class PersonType(DjangoObjectType):
photo = graphene.Field(FieldFileType)
avatar = graphene.Field(FieldFileType)
avatar_url = graphene.String()
avatar_content_url = graphene.String()
is_dummy = graphene.Boolean()
preferences = graphene.Field(PersonPreferencesType)
......@@ -49,7 +51,7 @@ class PersonType(DjangoObjectType):
def resolve_avatar(root, info, **kwargs):
if info.context.user.has_perm("core.view_avatar_rule", root):
return root.photo
return root.avatar
return None
def resolve_avatar_url(root, info, **kwargs):
......@@ -57,6 +59,21 @@ class PersonType(DjangoObjectType):
return root.avatar.url
return root.identicon_url
def resolve_avatar_content_url(root, info, **kwargs): # noqa
if get_site_preferences()["account__person_prefer_photo"]:
if info.context.user.has_perm("core.view_photo_rule", root) and root.photo:
return root.photo.url
elif info.context.user.has_perm("core.view_avatar_rule", root) and root.avatar:
return root.avatar.url
else:
if info.context.user.has_perm("core.view_avatar_rule", root) and root.avatar:
return root.avatar.url
elif info.context.user.has_perm("core.view_photo_rule", root) and root.photo:
return root.photo.url
return root.identicon_url
def resolve_is_dummy(root: Union[Person, DummyPerson], info, **kwargs):
return root.is_dummy if hasattr(root, "is_dummy") else False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment