You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
2.0 KiB
47 lines
2.0 KiB
from rest_framework import serializers
|
|
from apps.diplomacy.models import RepresentativeReport, ReportStatus
|
|
|
|
|
|
class RepresentativeReportListSerializer(serializers.ModelSerializer):
|
|
representative_name = serializers.CharField(source='representative.get_full_name', read_only=True)
|
|
representative_email = serializers.EmailField(source='representative.email', read_only=True)
|
|
|
|
class Meta:
|
|
model = RepresentativeReport
|
|
fields = [
|
|
'id', 'title', 'representative_name',
|
|
'representative_email', 'region_hub', 'period',
|
|
'centers_visited_count', 'status', 'created_at',
|
|
]
|
|
|
|
|
|
class RepresentativeReportDetailSerializer(serializers.ModelSerializer):
|
|
representative_name = serializers.CharField(source='representative.get_full_name', read_only=True)
|
|
reviewer_name = serializers.CharField(source='reviewed_by.get_full_name', read_only=True)
|
|
|
|
class Meta:
|
|
model = RepresentativeReport
|
|
fields = [
|
|
'id', 'title', 'representative', 'representative_name',
|
|
'region_hub', 'period', 'activities_summary',
|
|
'centers_visited_count', 'key_achievements',
|
|
'challenges_and_needs', 'attachment', 'status',
|
|
'feedback_notes', 'reviewed_by', 'reviewer_name',
|
|
'created_at', 'updated_at',
|
|
]
|
|
read_only_fields = ['id', 'representative', 'status', 'feedback_notes', 'reviewed_by', 'created_at', 'updated_at']
|
|
|
|
|
|
class RepresentativeReportCreateSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = RepresentativeReport
|
|
fields = [
|
|
'id', 'title', 'region_hub', 'period',
|
|
'activities_summary', 'centers_visited_count',
|
|
'key_achievements', 'challenges_and_needs', 'attachment',
|
|
]
|
|
|
|
|
|
class RepresentativeReportReviewSerializer(serializers.Serializer):
|
|
status = serializers.ChoiceField(choices=ReportStatus.choices)
|
|
feedback_notes = serializers.CharField(required=False, allow_blank=True)
|