# Path: src/sa_api_v2/serializers.py
# class SimplePlaceSerializer (BasePlaceSerializer):
#     class Meta (BasePlaceSerializer.Meta):
#         read_only_fields = ('dataset',)
# 
# class SimpleSubmissionSerializer (BaseSubmissionSerializer):
#     class Meta (BaseSubmissionSerializer.Meta):
#         read_only_fields = ('dataset', 'place')
# 
# class SimpleDataSetSerializer (BaseDataSetSerializer, serializers.ModelSerializer):
#     keys = ApiKeySerializer(many=True, read_only=False)
#     origins = OriginSerializer(many=True, read_only=False)
#     groups = SimpleGroupSerializer(many=True, read_only=False)
#     permissions = DataSetPermissionSerializer(many=True, read_only=False)
# 
#     class Meta (BaseDataSetSerializer.Meta):
#         pass
# 
# Path: src/sa_api_v2/renderers.py
# class JSONPRenderer (JSONRenderer):
# class PaginatedCSVRenderer (CSVRenderer):
# class GeoJSONRenderer(JSONRenderer):
# class GeoJSONPRenderer(JSONPRenderer, GeoJSONRenderer):
# class NullJSONRenderer(JSONRenderer):
# class NullJSONPRenderer(JSONPRenderer, NullJSONRenderer):
#     def get_callback(self, renderer_context):
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#     def render(self, data, media_type=None, renderer_context=None):
#     def render(self, data, media_type=None, renderer_context=None):
#     def get_feature(self, data):
#     def render(self, data, media_type=None, renderer_context=None):


import requests
import ujson as json
import logging
from celery import shared_task
from celery.result import AsyncResult
from django.db import transaction
from django.test.client import RequestFactory
from django.utils.timezone import now
from itertools import chain
from .models import DataSnapshotRequest, DataSnapshot, DataSet, User, Place, Submission
from .serializers import SimplePlaceSerializer, SimpleSubmissionSerializer, SimpleDataSetSerializer
from .renderers import CSVRenderer, JSONRenderer, GeoJSONRenderer

                place_data.pop('id', None)
                place_data.pop('dataset', None)
                place_data.pop('created_datetime', None)
                place_data.pop('updated_datetime', None)
                submission_sets_data = place_data.pop('submission_sets', {})
                submitter_data = place_data.pop('submitter', None)

                serializer_context = {'view': view, 'request': view.request}
                serializer = SimplePlaceSerializer(data=place_data, context=serializer_context)
                assert serializer.is_valid(), list_errors(serializer.errors)

                place = Place()
                for attr, value in serializer.validated_data.items():
                    setattr(place, attr, value)
                place.dataset = dataset
                place.submitter = get_or_create_user(submitter_data, users_map)
                place.save(silent=True, reindex=False)

                for set_name, submissions_data in submission_sets_data.items():
                    for submission_data in submissions_data:
                        submission_data.pop('id', None)
                        submission_data.pop('place', None)
                        submission_data.pop('dataset', None)
                        submission_data.pop('attachments', None)
                        submission_data.pop('created_datetime', None)
                        submission_data.pop('updated_datetime', None)
                        submitter_data = submission_data.pop('submitter', None)

                        serializer_context = {'view': view, 'request': view.request}

# Path: src/sa_api_v2/serializers.py
# class SimplePlaceSerializer (BasePlaceSerializer):
#     class Meta (BasePlaceSerializer.Meta):
#         read_only_fields = ('dataset',)
# 
# class SimpleSubmissionSerializer (BaseSubmissionSerializer):
#     class Meta (BaseSubmissionSerializer.Meta):
#         read_only_fields = ('dataset', 'place')
# 
# class SimpleDataSetSerializer (BaseDataSetSerializer, serializers.ModelSerializer):
#     keys = ApiKeySerializer(many=True, read_only=False)
#     origins = OriginSerializer(many=True, read_only=False)
#     groups = SimpleGroupSerializer(many=True, read_only=False)
#     permissions = DataSetPermissionSerializer(many=True, read_only=False)
# 
#     class Meta (BaseDataSetSerializer.Meta):
#         pass
# 
# Path: src/sa_api_v2/renderers.py
# class JSONPRenderer (JSONRenderer):
# class PaginatedCSVRenderer (CSVRenderer):
# class GeoJSONRenderer(JSONRenderer):
# class GeoJSONPRenderer(JSONPRenderer, GeoJSONRenderer):
# class NullJSONRenderer(JSONRenderer):
# class NullJSONPRenderer(JSONPRenderer, NullJSONRenderer):
#     def get_callback(self, renderer_context):
#     def render(self, data, accepted_media_type=None, renderer_context=None):
#     def render(self, data, media_type=None, renderer_context=None):
#     def render(self, data, media_type=None, renderer_context=None):
#     def get_feature(self, data):
#     def render(self, data, media_type=None, renderer_context=None):


# Path: src/sa_api_v2/tasks.py
import requests
import ujson as json
import logging
from celery import shared_task
from celery.result import AsyncResult
from django.db import transaction
from django.test.client import RequestFactory
from django.utils.timezone import now
from itertools import chain
from .models import DataSnapshotRequest, DataSnapshot, DataSet, User, Place, Submission
from .serializers import SimplePlaceSerializer, SimpleSubmissionSerializer, SimpleDataSetSerializer
from .renderers import CSVRenderer, JSONRenderer, GeoJSONRenderer


                place_data.pop('id', None)
                place_data.pop('dataset', None)
                place_data.pop('created_datetime', None)
                place_data.pop('updated_datetime', None)
                submission_sets_data = place_data.pop('submission_sets', {})
                submitter_data = place_data.pop('submitter', None)

                serializer_context = {'view': view, 'request': view.request}
                serializer = SimplePlaceSerializer(data=place_data, context=serializer_context)
                assert serializer.is_valid(), list_errors(serializer.errors)

                place = Place()
                for attr, value in serializer.validated_data.items():
                    setattr(place, attr, value)
                place.dataset = dataset
                place.submitter = get_or_create_user(submitter_data, users_map)
                place.save(silent=True, reindex=False)

                for set_name, submissions_data in submission_sets_data.items():
                    for submission_data in submissions_data:
                        submission_data.pop('id', None)
                        submission_data.pop('place', None)
                        submission_data.pop('dataset', None)
                        submission_data.pop('attachments', None)
                        submission_data.pop('created_datetime', None)
                        submission_data.pop('updated_datetime', None)
                        submitter_data = submission_data.pop('submitter', None)

                        serializer_context = {'view': view, 'request': view.request}

                        serializer = SimpleSubmissionSerializer(data=submission_data, context=serializer_context)