# Path: db/campaigns/models.py
# class Parameter(vera.BaseParameter):
#     campaign = models.ForeignKey(Campaign, related_name='parameters')
#     description = models.TextField()
# 
#     # Inherited from vera's params.BaseParameter:
#     #   name = models.CharField()
#     #   slug = models.CharField()
#     #   is_numeric = models.BooleanField()
#     #   units = models.CharField()
# 
#     class Meta:
#         ordering = ['pk']
# 
# class Report(vera.BaseReport):
#     photo = models.ImageField(
#         null=True, blank=True, upload_to='reports'
#     )
# 
#     # Inherited from vera's series.BaseReport:
#     #   event = models.ForeignKey(Event)
#     #   entered = models.DateTimeField()
#     #   user = models.ForeignKey('auth.User')
#     #   status = models.ForeignKey('vera.ReportStatus')


from rest_framework import serializers
from wq.db.rest.serializers import ModelSerializer
from wq.db.patterns import serializers as patterns
from vera.models import Site
from .models import Parameter, Report
from vera.results.serializers import ResultSerializer as VeraResultSerializer
from vera.series.serializers import ReportSerializer as VeraReportSerializer


class ParameterInlineSerializer(patterns.AttachmentSerializer):
    class Meta(patterns.AttachmentSerializer.Meta):
        model = Parameter
        exclude = ('campaign',)
        object_field = 'campaign'


class CampaignSerializer(patterns.AttachedModelSerializer):

# Path: db/campaigns/models.py
# class Parameter(vera.BaseParameter):
#     campaign = models.ForeignKey(Campaign, related_name='parameters')
#     description = models.TextField()
# 
#     # Inherited from vera's params.BaseParameter:
#     #   name = models.CharField()
#     #   slug = models.CharField()
#     #   is_numeric = models.BooleanField()
#     #   units = models.CharField()
# 
#     class Meta:
#         ordering = ['pk']
# 
# class Report(vera.BaseReport):
#     photo = models.ImageField(
#         null=True, blank=True, upload_to='reports'
#     )
# 
#     # Inherited from vera's series.BaseReport:
#     #   event = models.ForeignKey(Event)
#     #   entered = models.DateTimeField()
#     #   user = models.ForeignKey('auth.User')
#     #   status = models.ForeignKey('vera.ReportStatus')


# Path: db/campaigns/serializers.py
from rest_framework import serializers
from wq.db.rest.serializers import ModelSerializer
from wq.db.patterns import serializers as patterns
from vera.models import Site
from .models import Parameter, Report
from vera.results.serializers import ResultSerializer as VeraResultSerializer
from vera.series.serializers import ReportSerializer as VeraReportSerializer



class ParameterInlineSerializer(patterns.AttachmentSerializer):
    class Meta(patterns.AttachmentSerializer.Meta):
        model = Parameter
        exclude = ('campaign',)
        object_field = 'campaign'


class CampaignSerializer(patterns.AttachedModelSerializer):

    parameters = ParameterInlineSerializer(many=True, required=False)