コード例 #1
0
class GrantSerializer(serializers.ModelSerializer):
    """Handle serializing the Grant object."""

    admin_profile = ProfileSerializer()
    team_members = ProfileSerializer(many=True)

    class Meta:
        """Define the grant serializer metadata."""

        model = Grant
        fields = (
            'active',
            'title',
            'slug',
            'description',
            'reference_url',
            'logo',
            'admin_address',
            'amount_received',
            'token_address',
            'token_symbol',
            'contract_address',
            'metadata',
            'network',
            'required_gas_price',
            'admin_profile',
            'team_members',
            'clr_prediction_curve',
            'clr_round_num',
            'is_clr_active',
            'amount_received_in_round',
            'positive_round_contributor_count',
        )
コード例 #2
0
class GrantSerializer(serializers.ModelSerializer):
    """Handle serializing the Grant object."""

    admin_profile = ProfileSerializer()
    team_members = ProfileSerializer(many=True)

    class Meta:
        """Define the grant serializer metadata."""

        model = Grant
        fields = (
            'active',
            'title',
            'slug',
            'description',
            'reference_url',
            'logo',
            'admin_address',
            'amount_goal',
            'amount_received',
            'token_address',
            'token_symbol',
            'contract_address',
            'metadata',
            'network',
            'required_gas_price',
            'admin_profile',
            'team_members',
            'percentage_done',
        )
コード例 #3
0
class SubscriptionSerializer(serializers.ModelSerializer):
    """Handle serializing the Subscription object."""

    contributor_profile = ProfileSerializer()
    grant = GrantSerializer()

    class Meta:
        """Define the subscription serializer metadata."""

        model = Subscription
        fields = (
            'active',
            'subscription_hash',
            'contributor_signature',
            'contributor_address',
            'amount_per_period',
            'real_period_seconds',
            'frequency_unit',
            'frequency',
            'token_address',
            'token_symbol',
            'gas_price',
            'network',
            'grant',
            'contributor_profile',
        )
コード例 #4
0
class GrantCollectionSerializer(FlexFieldsModelSerializer):
    """Handle metadata of CLR rounds"""
    profile = ProfileSerializer()
    curators = ProfileSerializer(many=True)
    count = serializers.SerializerMethodField()

    class Meta:
        """Define the GrantCLR serializer metadata."""
        model = GrantCollection
        fields = ('id', 'title', 'description', 'cover', 'featured', 'cache',
                  'curators', 'grants', 'profile', 'count')

        expandable_fields = {
            'grants': ('grants.serializers.GrantSerializer', {
                'many': True,
                'fields': ['pk', 'title', 'logo']
            })
        }

    def get_count(self, obj):
        return obj.grants.count()