def test_question_serializer(answer):
    with scope(event=answer.question.event):
        data = AnswerSerializer(answer).data
        assert set(data.keys()) == {
            "id",
            "question",
            "answer",
            "answer_file",
            "submission",
            "person",
            "review",
            "options",
        }
        data = QuestionSerializer(answer.question).data
    assert set(data.keys()) == {
        "id",
        "variant",
        "question",
        "required",
        "target",
        "options",
        "help_text",
        "default_answer",
        "contains_personal_data",
        "min_length",
        "max_length",
        "is_public",
        "is_visible_to_reviewers",
    }
Esempio n. 2
0
def test_question_serializer(answer):
    data = AnswerSerializer(answer).data
    assert set(data.keys()) == {
        'id', 'question', 'answer', 'answer_file', 'submission', 'person', 'options',
    }
    data = QuestionSerializer(answer.question).data
    assert set(data.keys()) == {
        'id', 'question', 'required', 'target', 'options',
    }
Esempio n. 3
0
def test_question_serializer(answer):
    with scope(event=answer.question.event):
        data = AnswerSerializer(answer).data
        assert set(data.keys()) == {
            "id",
            "question",
            "answer",
            "answer_file",
            "submission",
            "person",
            "options",
        }
        data = QuestionSerializer(answer.question).data
    assert set(
        data.keys()) == {"id", "question", "required", "target", "options"}
Esempio n. 4
0
class SpeakerOrgaSerializer(SpeakerSerializer):
    answers = AnswerSerializer(Answer.objects.all(), many=True, read_only=True)

    def get_submissions(self, obj):
        return obj.user.submissions.filter(event=obj.event).values_list(
            'code', flat=True)

    class Meta(SpeakerSerializer.Meta):
        fields = SpeakerSerializer.Meta.fields + ('answers', )
Esempio n. 5
0
class SubmissionOrgaSerializer(SubmissionSerializer):
    answers = AnswerSerializer(many=True)

    class Meta:
        model = Submission
        fields = SubmissionSerializer.Meta.fields + [
            'answers',
            'notes',
            'internal_notes',
        ]
Esempio n. 6
0
class SubmissionOrgaSerializer(SubmissionSerializer):
    answers = AnswerSerializer(many=True)
    created = SerializerMethodField()

    def get_created(self, obj):
        return obj.created.astimezone(obj.event.tz).isoformat()

    class Meta(SubmissionSerializer.Meta):
        fields = SubmissionSerializer.Meta.fields + [
            "created",
            "answers",
            "notes",
            "internal_notes",
        ]
Esempio n. 7
0
class SpeakerOrgaSerializer(SpeakerSerializer):
    email = CharField(source="user.email")
    answers = AnswerSerializer(Answer.objects.none(), many=True, read_only=True)
    availabilities = AvailabilitySerializer(
        Availability.objects.none(), many=True, read_only=True
    )

    def get_submissions(self, obj):
        return obj.user.submissions.filter(event=obj.event).values_list(
            "code", flat=True
        )

    class Meta(SpeakerSerializer.Meta):
        fields = SpeakerSerializer.Meta.fields + ("answers", "email", "availabilities")
Esempio n. 8
0
class SubmissionOrgaSerializer(SubmissionSerializer):
    answers = AnswerSerializer(many=True)
    created = SerializerMethodField()

    def get_created(self, obj):
        return obj.created.astimezone(obj.event.tz).isoformat()

    class Meta:
        model = Submission
        fields = SubmissionSerializer.Meta.fields + [
            'created',
            'answers',
            'notes',
            'internal_notes',
        ]
Esempio n. 9
0
class ReviewSerializer(I18nAwareModelSerializer):
    submission = SubmissionSerializer()
    answers = AnswerSerializer(many=True)
    user = serializers.SlugRelatedField(slug_field='nick', read_only=True)

    class Meta:
        model = Review
        fields = (
            'id',
            'submission',
            'user',
            'text',
            'score',
            'override_vote',
            'created',
            'updated',
            'answers',
        )
Esempio n. 10
0
class SubmissionReviewerSerializer(SubmissionOrgaSerializer):
    answers = AnswerSerializer(many=True, source="reviewer_answers")

    class Meta(SubmissionOrgaSerializer.Meta):
        pass
Esempio n. 11
0
 def get_answers(self, obj):
     if self.is_orga:
         return AnswerSerializer(Answer.objects.filter(submission=obj),
                                 many=True).data
     return []
Esempio n. 12
0
class SpeakerReviewerSerializer(SpeakerOrgaSerializer):
    answers = AnswerSerializer(many=True, source="reviewer_answers")

    class Meta(SpeakerOrgaSerializer.Meta):
        pass
Esempio n. 13
0
 def get_answers(self, obj):
     return AnswerSerializer(Answer.objects.filter(review=obj), many=True).data