<commit_before># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Transaction, TransactionSector

from .rsr_serializer import BaseRSRSerializer
from .organisation import OrganisationBasicSerializer

from rest_framework import serializers


class TransactionRawSerializer(BaseRSRSerializer):

    class Meta:
        fields = '__all__'
        model = Transaction


class TransactionRawDeepSerializer(TransactionRawSerializer):

    provider_organisation = OrganisationBasicSerializer()
    receiver_organisation = OrganisationBasicSerializer()

    class Meta:
        fields = '__all__'
        model = Transaction


class TransactionSerializer(TransactionRawSerializer):

    provider_organisation_show_link = serializers.ReadOnlyField()
    receiver_organisation_show_link = serializers.ReadOnlyField()
    currency_label = serializers.ReadOnlyField(source='iati_currency_unicode')
    transaction_type_label = serializers.ReadOnlyField(source='iati_transaction_type_unicode')
    aid_type_label = serializers.ReadOnlyField(source='iati_aid_type_unicode')
    disbursement_channel_label = serializers.ReadOnlyField(source='iati_disbursement_channel_unicode')
    finance_type_label = serializers.ReadOnlyField(source='iati_finance_type_unicode')
    flow_type_label = serializers.ReadOnlyField(source='iati_flow_type_unicode')
    tied_status_label = serializers.ReadOnlyField(source='iati_tied_status_unicode')
    recipient_country_label = serializers.ReadOnlyField(source='iati_recipient_country_unicode')
    recipient_region_label = serializers.ReadOnlyField(source='iati_recipient_region_unicode')
    recipient_region_vocabulary_label = serializers.ReadOnlyField(source='iati_recipient_region_vocabulary_unicode')


class TransactionSectorSerializer(BaseRSRSerializer):

    transaction_unicode = serializers.ReadOnlyField(source='transaction.__unicode__')
    code_label = serializers.ReadOnlyField(source='iati_sector_unicode')
    vocabulary_label = serializers.ReadOnlyField(source='iati_vocabulary_unicode')

    class Meta:
        fields = '__all__'
        model = TransactionSector<commit_msg>[#3652] Send transaction sectors array in transaction endpoint<commit_after># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


from akvo.rsr.models import Transaction, TransactionSector

from .rsr_serializer import BaseRSRSerializer
from .organisation import OrganisationBasicSerializer

from rest_framework import serializers


class TransactionRawSerializer(BaseRSRSerializer):

    class Meta:
        fields = '__all__'
        model = Transaction


class TransactionRawDeepSerializer(TransactionRawSerializer):

    provider_organisation = OrganisationBasicSerializer()
    receiver_organisation = OrganisationBasicSerializer()

    class Meta:
        fields = '__all__'
        model = Transaction


class TransactionSectorSerializer(BaseRSRSerializer):

    transaction_unicode = serializers.ReadOnlyField(source='transaction.__unicode__')
    code_label = serializers.ReadOnlyField(source='iati_sector_unicode')
    vocabulary_label = serializers.ReadOnlyField(source='iati_vocabulary_unicode')

    class Meta:
        fields = '__all__'
        model = TransactionSector


class TransactionSerializer(TransactionRawSerializer):

    provider_organisation_show_link = serializers.ReadOnlyField()
    receiver_organisation_show_link = serializers.ReadOnlyField()
    currency_label = serializers.ReadOnlyField(source='iati_currency_unicode')
    transaction_type_label = serializers.ReadOnlyField(source='iati_transaction_type_unicode')
    aid_type_label = serializers.ReadOnlyField(source='iati_aid_type_unicode')
    disbursement_channel_label = serializers.ReadOnlyField(source='iati_disbursement_channel_unicode')
    finance_type_label = serializers.ReadOnlyField(source='iati_finance_type_unicode')
    flow_type_label = serializers.ReadOnlyField(source='iati_flow_type_unicode')
    tied_status_label = serializers.ReadOnlyField(source='iati_tied_status_unicode')
    recipient_country_label = serializers.ReadOnlyField(source='iati_recipient_country_unicode')
    recipient_region_label = serializers.ReadOnlyField(source='iati_recipient_region_unicode')
    recipient_region_vocabulary_label = serializers.ReadOnlyField(source='iati_recipient_region_vocabulary_unicode')
    sectors = TransactionSectorSerializer(many=True, read_only=True)
{'fraction_non_alphanumeric': 0.07054709995886467, 'fraction_numerical': 0.0012340600575894694, 'mean_word_length': 6.193786982248521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1768875', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1326, 'n_words': 245}