# Path: dplace_app/serializers.py
# SEARCH_LANGUAGE = 'l'
# SEARCH_ENVIRONMENTAL = 'e'
# SEARCH_VARIABLES = 'v'
# SEARCH_GEOGRAPHIC = 'g'
# class SourceSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CodeDescriptionSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class VariableSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CategorySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class VariableDetailSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CategoryDetailSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class ValueSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageFamilySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageSerializerWithSocieties(serializers.ModelSerializer):
#     class Meta(object):
# class SocietySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class GeographicRegionSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class SocietyWithRegionSerializer(SocietySerializer):
# class TreeSocietySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageTreeLabelsSequenceSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class LanguageTreeLabelsSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageTreeSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class SocietyResult(object):
# class VariableCode(object):
# class SocietyResultSet(object):
# class VariableCodeSerializer(serializers.Serializer):
# class SocietyResultSerializer(serializers.Serializer):
# class SocietyResultSetSerializer(serializers.Serializer):
# class Legend(object):
# class LegendSerializer(serializers.Serializer):
#     def __init__(self):
#     def __init__(self, society):
#     def __eq__(self, other):
#     def __init__(self, codes, variable):
#     def __eq__(self, other):
#     def __init__(self):
#     def __init__(self, name, svg):
# 
# Path: dplace_app/models.py
# class Society(models.Model):
#     class Meta(object):
# class SocietyRelation(models.Model):
# class Category(models.Model):
#     class Meta(object):
# class Variable(models.Model):
#     class Meta(object):
# class CodeDescription(models.Model):
#     class Meta(object):
# class Value(models.Model):
#     class Meta(object):
# class Source(models.Model):
#     class Meta(object):
# class LanguageFamily(models.Model):
#     class Meta(object):
# class Language(models.Model):
#     class Meta(object):
# class GeographicRegion(models.Model):
#     class Meta(object):
# class LanguageTree(models.Model):
#     class Meta(object):
# class LanguageTreeLabels(models.Model):
#     class Meta:
# class LanguageTreeLabelsSequence(models.Model):
#     class Meta:
#     def related(self):
#     def location(self):
#     def original_location(self):
#     def get_environmental_data(self):
#     def get_cultural_trait_data(self):
#     def get_data_references(self):
#     def __unicode__(self):
#     def get_absolute_url(self):
#     def __unicode__(self):
#     def coded_societies(self):
#     def __unicode__(self):
#     def save(self, *args, **kwargs):
#     def read_code_number(self):
#     def coded_societies(self):
#     def __unicode__(self):
#     def get_description(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def get_absolute_url(self):
#     def __unicode__(self):


import json
import re
import datetime
import logging
from itertools import groupby
from django.db import connection
from django.db.models import Prefetch, Q, Count
from django.shortcuts import get_object_or_404
from django.http import Http404
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination
from rest_framework.decorators import api_view, permission_classes, renderer_classes
from rest_framework.permissions import AllowAny
from rest_framework.views import Response
from rest_framework.renderers import JSONRenderer
from dplace_app.renderers import DPLACECSVRenderer
from dplace_app import serializers
from dplace_app import models
from dplace_app.tree import update_newick
    from time import time
    from time import time
    from django.db import connection
            xd_id=society.xd_id).exclude(ext_id=society_id)
        if society.hraf_link and '(' in society.hraf_link:
            hraf_link = society.hraf_link.split('(')[len(society.hraf_link.split('('))-1]
        else:
            hraf_link = ''
        environmentals = society.get_environmental_data()
        cultural_traits = society.get_cultural_trait_data()
        references = society.get_data_references()
        language_classification = None
        
        if society.language:
            # just glottolog at the moment
            language_classification = models.LanguageFamily.objects\
                .filter(name=society.language.family.name)

        return Response(
            {
                'society': society,
                'hraf_link': hraf_link[0:len(hraf_link)-1],
                'xd_id': xd_id,
                'location': location,
                'language_classification': language_classification,
                'environmentals': dict(environmentals),
                'cultural_traits': dict(cultural_traits),
                'references': references
            },
            template_name='society.html'
        )



# Path: dplace_app/serializers.py
# SEARCH_LANGUAGE = 'l'
# SEARCH_ENVIRONMENTAL = 'e'
# SEARCH_VARIABLES = 'v'
# SEARCH_GEOGRAPHIC = 'g'
# class SourceSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CodeDescriptionSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class VariableSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CategorySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class VariableDetailSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class CategoryDetailSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class ValueSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageFamilySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageSerializerWithSocieties(serializers.ModelSerializer):
#     class Meta(object):
# class SocietySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class GeographicRegionSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class SocietyWithRegionSerializer(SocietySerializer):
# class TreeSocietySerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageTreeLabelsSequenceSerializer(serializers.HyperlinkedModelSerializer):
#     class Meta:
# class LanguageTreeLabelsSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class LanguageTreeSerializer(serializers.ModelSerializer):
#     class Meta(object):
# class SocietyResult(object):
# class VariableCode(object):
# class SocietyResultSet(object):
# class VariableCodeSerializer(serializers.Serializer):
# class SocietyResultSerializer(serializers.Serializer):
# class SocietyResultSetSerializer(serializers.Serializer):
# class Legend(object):
# class LegendSerializer(serializers.Serializer):
#     def __init__(self):
#     def __init__(self, society):
#     def __eq__(self, other):
#     def __init__(self, codes, variable):
#     def __eq__(self, other):
#     def __init__(self):
#     def __init__(self, name, svg):
# 
# Path: dplace_app/models.py
# class Society(models.Model):
#     class Meta(object):
# class SocietyRelation(models.Model):
# class Category(models.Model):
#     class Meta(object):
# class Variable(models.Model):
#     class Meta(object):
# class CodeDescription(models.Model):
#     class Meta(object):
# class Value(models.Model):
#     class Meta(object):
# class Source(models.Model):
#     class Meta(object):
# class LanguageFamily(models.Model):
#     class Meta(object):
# class Language(models.Model):
#     class Meta(object):
# class GeographicRegion(models.Model):
#     class Meta(object):
# class LanguageTree(models.Model):
#     class Meta(object):
# class LanguageTreeLabels(models.Model):
#     class Meta:
# class LanguageTreeLabelsSequence(models.Model):
#     class Meta:
#     def related(self):
#     def location(self):
#     def original_location(self):
#     def get_environmental_data(self):
#     def get_cultural_trait_data(self):
#     def get_data_references(self):
#     def __unicode__(self):
#     def get_absolute_url(self):
#     def __unicode__(self):
#     def coded_societies(self):
#     def __unicode__(self):
#     def save(self, *args, **kwargs):
#     def read_code_number(self):
#     def coded_societies(self):
#     def __unicode__(self):
#     def get_description(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):
#     def get_absolute_url(self):
#     def __unicode__(self):


# Path: dplace_app/api_views.py
import json
import re
import datetime
import logging
from itertools import groupby
from django.db import connection
from django.db.models import Prefetch, Q, Count
from django.shortcuts import get_object_or_404
from django.http import Http404
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination
from rest_framework.decorators import api_view, permission_classes, renderer_classes
from rest_framework.permissions import AllowAny
from rest_framework.views import Response
from rest_framework.renderers import JSONRenderer
from dplace_app.renderers import DPLACECSVRenderer
from dplace_app import serializers
from dplace_app import models
from dplace_app.tree import update_newick
    from time import time
    from time import time
    from django.db import connection

            xd_id=society.xd_id).exclude(ext_id=society_id)
        if society.hraf_link and '(' in society.hraf_link:
            hraf_link = society.hraf_link.split('(')[len(society.hraf_link.split('('))-1]
        else:
            hraf_link = ''
        environmentals = society.get_environmental_data()
        cultural_traits = society.get_cultural_trait_data()
        references = society.get_data_references()
        language_classification = None
        
        if society.language:
            # just glottolog at the moment
            language_classification = models.LanguageFamily.objects\
                .filter(name=society.language.family.name)

        return Response(
            {
                'society': society,
                'hraf_link': hraf_link[0:len(hraf_link)-1],
                'xd_id': xd_id,
                'location': location,
                'language_classification': language_classification,
                'environmentals': dict(environmentals),
                'cultural_traits': dict(cultural_traits),
                'references': references
            },
            template_name='society.html'
        )



class LargeResultsSetPagination(PageNumberPagination):