# Path: event_store/models.py
# class Organization(models.Model):
#     title = models.CharField(max_length=765)
#     slug = models.SlugField(max_length=128, db_index=True)
#     url = models.URLField(blank=True)
# 
#     facebook = models.CharField(max_length=128, null=True, blank=True)
#     twitter = models.CharField(max_length=128,
#                                null=True, blank=True,
#                                help_text="do not include @")
# 
#     logo_thumb = models.URLField(blank=True)
#     logo_big = models.URLField(blank=True)
#     privacy_policy = models.URLField(blank=True)
#     terms_and_conditions = models.URLField(blank=True)
# 
#     #default source id
#     osdi_source_id = models.CharField(max_length=128)
# 
#     group = models.ForeignKey(Group, db_index=True)
#     # for getting other folks' data; auto/re-generatable
#     api_key = models.CharField(max_length=765, editable=False)
# 
#     def __str__(self):
#         return self.title


from collections import OrderedDict
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django_redis import get_redis_connection
from event_store.models import Organization
import datetime
            query = query[:max*2] # double because could have dupes
        db_pre = list(query)
        already = set()
        for r in db_pre:
            key = (r.content_type_id, r.object_id, r.key)
            if key not in already:
                db_res.append(r)
                already.add(key)
                if max and len(db_res) > max:
                    break
        if db_res:
            revs = OrderedDict()
            for rev in db_res:
                revs.setdefault(
                    (rev.content_type_id, rev.object_id),
                    {'type': rev.content_type_id,
                     'pk': rev.object_id}).update({rev.key: rev.decision})
            return revs

class ReviewLog(models.Model):
    content_type = models.ForeignKey(ContentType,
                                     editable=False,
                                     blank=True)
    object_id = models.IntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')

    # subject is a secondary object reference,
    # like the host id when the object is an event
    subject = models.IntegerField(null=True, blank=True)


# Path: event_store/models.py
# class Organization(models.Model):
#     title = models.CharField(max_length=765)
#     slug = models.SlugField(max_length=128, db_index=True)
#     url = models.URLField(blank=True)
# 
#     facebook = models.CharField(max_length=128, null=True, blank=True)
#     twitter = models.CharField(max_length=128,
#                                null=True, blank=True,
#                                help_text="do not include @")
# 
#     logo_thumb = models.URLField(blank=True)
#     logo_big = models.URLField(blank=True)
#     privacy_policy = models.URLField(blank=True)
#     terms_and_conditions = models.URLField(blank=True)
# 
#     #default source id
#     osdi_source_id = models.CharField(max_length=128)
# 
#     group = models.ForeignKey(Group, db_index=True)
#     # for getting other folks' data; auto/re-generatable
#     api_key = models.CharField(max_length=765, editable=False)
# 
#     def __str__(self):
#         return self.title


# Path: reviewer/models.py
from collections import OrderedDict
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django_redis import get_redis_connection
from event_store.models import Organization
import datetime

            query = query[:max*2] # double because could have dupes
        db_pre = list(query)
        already = set()
        for r in db_pre:
            key = (r.content_type_id, r.object_id, r.key)
            if key not in already:
                db_res.append(r)
                already.add(key)
                if max and len(db_res) > max:
                    break
        if db_res:
            revs = OrderedDict()
            for rev in db_res:
                revs.setdefault(
                    (rev.content_type_id, rev.object_id),
                    {'type': rev.content_type_id,
                     'pk': rev.object_id}).update({rev.key: rev.decision})
            return revs

class ReviewLog(models.Model):
    content_type = models.ForeignKey(ContentType,
                                     editable=False,
                                     blank=True)
    object_id = models.IntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')

    # subject is a secondary object reference,
    # like the host id when the object is an event
    subject = models.IntegerField(null=True, blank=True)


    organization = models.ForeignKey(Organization)