from rest_framework import serializers

from analytics.models import *


class NetworkSerializer(serializers.ModelSerializer):
    class Meta:
        model = Network


class CohortSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='cohort-detail')
    network_name = serializers.CharField(source="network.name")

    class Meta:
        model = Cohort
        

class ProjectSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='project-detail')

    class Meta:
        model = Project


class AnalyteSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='analyte-detail')
    subtrahend_name = serializers.CharField(source="subtrahend.name")

    class Meta:
        model = Analyte


class ConjugateSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='conjugate-detail')

    class Meta:
        model = Conjugate


class BufferSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='buffer-detail')

    class Meta:
        model = Buffer


class IsotypeSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='isotype-detail')

    class Meta:
        model = Isotype


class SampleTypeSerializer(serializers.ModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='sample-type-detail')

    class Meta:
        model = SampleType


class NotebookSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notebook


class ParticipantSerializer(serializers.ModelSerializer):
    cohort_name = serializers.CharField(
        source='cohort.name',
        read_only=True)
    species_name = serializers.CharField(
        source='species.name',
        read_only=True)

    class Meta:
        model = Participant
@@ -322,32 +322,41 @@
 izers.CharField(
+%0A        
 source=%22network.
@@ -356,24 +356,53 @@
 etwork.name%22
+,%0A        read_only=True%0A    
 )%0A%0A    class
@@ -431,24 +431,16 @@
  Cohort%0A
-        
 %0A%0Aclass 
@@ -778,16 +778,25 @@
 arField(
+%0A        
 source=%22
@@ -811,16 +811,45 @@
 nd.name%22
+,%0A        read_only=True%0A    
 )%0A%0A    c

make extra fields read only