Add optional attendance information to profile
This commit is contained in:
parent
dec5691d8f
commit
fd3effc673
|
|
@ -53,7 +53,12 @@ onMounted(() => {
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<h2 class="mb-2">{{ user.first_name }} {{ user.last_name }}</h2>
|
<h2 class="mb-2">{{ user.first_name }} {{ user.last_name }}</h2>
|
||||||
<p class="mb-2">{{ user.email }}</p>
|
<p class="mb-2">{{ user.email }}</p>
|
||||||
<p class="text-gray-800">{{ $t("a.Teilnehmer") }}</p>
|
<p class="text-gray-800">
|
||||||
|
{{ $t("a.Teilnehmer") }}
|
||||||
|
<span v-if="user.optional_attendance">
|
||||||
|
({{ $t("a.Optionale Anwesenheit") }})
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class UserSerializer(serializers.ModelSerializer):
|
||||||
course_session_experts = serializers.SerializerMethodField()
|
course_session_experts = serializers.SerializerMethodField()
|
||||||
country = CountrySerializer()
|
country = CountrySerializer()
|
||||||
organisation_country = CountrySerializer()
|
organisation_country = CountrySerializer()
|
||||||
|
optional_attendance = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
|
|
@ -83,6 +84,7 @@ class UserSerializer(serializers.ModelSerializer):
|
||||||
"organisation_postal_code",
|
"organisation_postal_code",
|
||||||
"organisation_city",
|
"organisation_city",
|
||||||
"organisation_country",
|
"organisation_country",
|
||||||
|
"optional_attendance",
|
||||||
]
|
]
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
"id",
|
"id",
|
||||||
|
|
@ -108,6 +110,11 @@ class UserSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
return [str(_id) for _id in (supervisor_in_session_ids | expert_in_session_ids)]
|
return [str(_id) for _id in (supervisor_in_session_ids | expert_in_session_ids)]
|
||||||
|
|
||||||
|
def get_optional_attendance(self, obj: User) -> bool:
|
||||||
|
return CourseSessionUser.objects.filter(
|
||||||
|
user=obj, optional_attendance=True
|
||||||
|
).values_list("course_session__id", flat=True)
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
country_data = validated_data.pop("country", None)
|
country_data = validated_data.pop("country", None)
|
||||||
organisation_country_data = validated_data.pop("organisation_country", None)
|
organisation_country_data = validated_data.pop("organisation_country", None)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue