예제 #1
0
class MappingUpdateSerializer(MappingBaseSerializer):
    map_type = serializers.CharField(required=False)
    retired = serializers.BooleanField(required=False)
    from_concept_url = ConceptURLField(view_name='concept-detail',
                                       queryset=Concept.objects.all(),
                                       lookup_kwarg='concept',
                                       lookup_field='concept',
                                       required=False,
                                       source='from_concept')
    to_concept_url = ConceptURLField(view_name='concept-detail',
                                     queryset=Concept.objects.all(),
                                     lookup_kwarg='concept',
                                     lookup_field='concept',
                                     required=False,
                                     source='to_concept')
    to_source_url = SourceURLField(view_name='source-detail',
                                   queryset=Concept.objects.all(),
                                   lookup_kwarg='source',
                                   lookup_field='source',
                                   required=False,
                                   source='to_source')
    to_concept_code = serializers.CharField(required=False)
    to_concept_name = serializers.CharField(required=False)
    external_id = serializers.CharField(required=False)

    def save_object(self, obj, **kwargs):
        request_user = self.context['request'].user
        errors = Mapping.persist_changes(obj, request_user)
        self._errors.update(errors)
예제 #2
0
class MappingCreateSerializer(MappingBaseSerializer):
    id = serializers.CharField(
        required=False,
        validators=[RegexValidator(regex=NAMESPACE_REGEX)],
        source='mnemonic')
    map_type = serializers.CharField(required=True)
    from_concept_url = ConceptURLField(view_name='concept-detail',
                                       queryset=Concept.objects.all(),
                                       lookup_kwarg='concept',
                                       lookup_field='concept',
                                       required=True,
                                       source='from_concept')
    to_concept_url = ConceptURLField(view_name='concept-detail',
                                     queryset=Concept.objects.all(),
                                     lookup_kwarg='concept',
                                     lookup_field='concept',
                                     required=False,
                                     source='to_concept')
    to_source_url = SourceURLField(view_name='source-detail',
                                   queryset=Concept.objects.all(),
                                   lookup_kwarg='source',
                                   lookup_field='source',
                                   required=False,
                                   source='to_source')
    to_concept_code = serializers.CharField(required=False)
    to_concept_name = serializers.CharField(required=False)
    external_id = serializers.CharField(required=False)

    def save_object(self, obj, **kwargs):
        request_user = self.context['request'].user
        errors = Mapping.persist_new(obj, request_user, **kwargs)
        self._errors.update(errors)