class ResponseFileSerializer(serializers.ModelSerializer):
    author = UserSerializer()
    creation_date = DateTimeFieldWihTZ(source='created', format='%A %d %B %Y')
    creation_time = DateTimeFieldWihTZ(source='created', format='%X')

    class Meta:
        model = ResponseFile
        fields = ('id', 'url', 'basename', 'creation_date', 'creation_time', 'author')
예제 #2
0
class InquirerSerializer(serializers.Serializer):
    inquirerId = serializers.IntegerField(source='id', read_only=True)
    inquirerTitle = serializers.CharField(source='title')
    inquirerStartDate = DateTimeFieldWihTZ(source='date_start')
    inquirerEndDate = DateTimeFieldWihTZ(source='date_end')

    def validate(self, data):
        if data['date_start'] >= data['date_end']:
            raise serializers.ValidationError({'inquirerStartDate': 'Дата начала не может быть больше даты окончания'})
        elif data['date_start'] <= datetime.now(pytz.timezone(settings.TIME_ZONE)):
            raise serializers.ValidationError({'inquirerStartDate': 'Дата начала не может быть в прошлом'})
        return data
예제 #3
0
class ControlDetailQuestionnaireSerializer(serializers.ModelSerializer):
    editor = ControlDetailUserSerializer(read_only=True, required=False)
    modified_date = DateTimeFieldWihTZ(source='modified',
                                       format='%a %d %B %Y',
                                       read_only=True)
    modified_time = DateTimeFieldWihTZ(source='modified',
                                       format='%X',
                                       read_only=True)

    class Meta:
        model = Questionnaire
        fields = ('id', 'title', 'numbering', 'url', 'is_draft', 'sent_date',
                  'end_date', 'editor', 'modified_date', 'modified_time')
예제 #4
0
class QuestionnaireSerializer(serializers.ModelSerializer):
    themes = ThemeSerializer(many=True, read_only=True)
    editor = ControlDetailUserSerializer(read_only=True, required=False)
    modified_date = DateTimeFieldWihTZ(source='modified',
                                       format='%a %d %B %Y',
                                       read_only=True)
    modified_time = DateTimeFieldWihTZ(source='modified',
                                       format='%X',
                                       read_only=True)

    class Meta:
        model = Questionnaire
        fields = ('id', 'title', 'sent_date', 'end_date', 'description',
                  'control', 'themes', 'is_draft', 'editor', 'title_display',
                  'numbering', 'modified_date', 'modified_time')

        extra_kwargs = {'control': {'required': True}}
예제 #5
0
class UserInquirerSerializer(serializers.Serializer):
    userInquirerId = serializers.IntegerField(source="id")
    inquirerTitle = serializers.CharField(source="inquirer.title")
    userTests = UserTestsSerializer(many=True, source="tests")
    dateStart = DateTimeFieldWihTZ(source="inquirer.date_start")
    dateEnd = DateTimeFieldWihTZ(source="inquirer.date_end")