# Path: wham/fields.py
# class WhamCharField(WhamFieldMixin, models.TextField):
# 
#     @property
#     def type_repr(self):
#         return 'char'
# 
# class WhamManyToManyField(models.ManyToManyField):
# 
#     def __init__(self, *args, **kwargs):
#         self.wham_result_path = kwargs.pop('wham_result_path', None)
#         self.wham_endpoint = kwargs.pop('wham_endpoint', None)
#         self.wham_results_path = kwargs.pop('wham_results_path', ())
#         self.wham_pk_param = kwargs.pop('wham_pk_param', None)
#         self.wham_params = kwargs.pop('wham_params', {})
#         return super(WhamManyToManyField, self).__init__(*args, **kwargs)
# 
# 
# 
# 
#     @property
#     def type_repr(self):
#         return 'many to many'
# 
# class WhamImageUrlField(WhamTextField):
#     pass
# 
# Path: wham/models.py
# class WhamModel(models.Model):
# 
#     objects = WhamManager()
# 
#     class Meta():
#         abstract = True


from django.db import models
from django.db import models
from wham.fields import WhamCharField, WhamManyToManyField, WhamImageUrlField
from wham.models import WhamModel
    api_key_settings_name = 'INSTAGRAM_CLIENT_ID'
    api_key_param = 'client_id'

class InstagramTag(WhamModel):

    name = WhamCharField(max_length=255, primary_key=True)

    posts = WhamManyToManyField(
        #  https://api.instagram.com/v1/tags/djangocon/media/recent
        'InstagramPost',
        related_name='tags',
        wham_endpoint='tags/{{id}}/media/recent',
        wham_results_path=('data',)
    )

    class Meta:
        db_table = 'instagram_tag'

    class WhamMeta(InstagramMeta):
        endpoint = 'tags'
        detail_base_result_path = ('data',) #can we make this less verbose??

    def __unicode__(self):
        return self.name

class InstagramPost(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)

    type = WhamCharField(max_length=10)

# Path: wham/fields.py
# class WhamCharField(WhamFieldMixin, models.TextField):
# 
#     @property
#     def type_repr(self):
#         return 'char'
# 
# class WhamManyToManyField(models.ManyToManyField):
# 
#     def __init__(self, *args, **kwargs):
#         self.wham_result_path = kwargs.pop('wham_result_path', None)
#         self.wham_endpoint = kwargs.pop('wham_endpoint', None)
#         self.wham_results_path = kwargs.pop('wham_results_path', ())
#         self.wham_pk_param = kwargs.pop('wham_pk_param', None)
#         self.wham_params = kwargs.pop('wham_params', {})
#         return super(WhamManyToManyField, self).__init__(*args, **kwargs)
# 
# 
# 
# 
#     @property
#     def type_repr(self):
#         return 'many to many'
# 
# class WhamImageUrlField(WhamTextField):
#     pass
# 
# Path: wham/models.py
# class WhamModel(models.Model):
# 
#     objects = WhamManager()
# 
#     class Meta():
#         abstract = True


# Path: wham/apis/instagram/models.py
from django.db import models
from django.db import models
from wham.fields import WhamCharField, WhamManyToManyField, WhamImageUrlField
from wham.models import WhamModel

    api_key_settings_name = 'INSTAGRAM_CLIENT_ID'
    api_key_param = 'client_id'

class InstagramTag(WhamModel):

    name = WhamCharField(max_length=255, primary_key=True)

    posts = WhamManyToManyField(
        #  https://api.instagram.com/v1/tags/djangocon/media/recent
        'InstagramPost',
        related_name='tags',
        wham_endpoint='tags/{{id}}/media/recent',
        wham_results_path=('data',)
    )

    class Meta:
        db_table = 'instagram_tag'

    class WhamMeta(InstagramMeta):
        endpoint = 'tags'
        detail_base_result_path = ('data',) #can we make this less verbose??

    def __unicode__(self):
        return self.name

class InstagramPost(WhamModel):

    id = WhamCharField(max_length=255, primary_key=True)

    type = WhamCharField(max_length=10)

    image_url = WhamImageUrlField(wham_result_path=('images', 'standard_resolution', 'url'))