# Path: clipper/models.py
# class Article(models.Model):
#     """ A news article.  These will be the sources for answers. """
#     url = models.URLField(verify_exists=False, unique = True) 
#     news_organization = models.ForeignKey("NewsOrganization", related_name='articles_created') 
#     source = models.ForeignKey("NewsOrganization", related_name = 'articles_sourced')
#     authors = models.ManyToManyField(UserProfile) 
#     title = models.CharField(max_length=200)
#     date_published = models.DateTimeField(null=True)
#     # But we'll probably not be tagging articles initially, just aggregating tags from
#     # related clips
#     tags = models.ManyToManyField(Tag, null=True) 
# 
#     def __unicode__(self):
#         return self.title
# 
# Path: clipper/models.py
# class Clip(models.Model):
#     """ Relevent text from an article.  """
#     tags = models.ManyToManyField(Tag, null=True) 
#     article = models.ForeignKey(Article) 
#     user = models.ForeignKey(UserProfile)
#     text = models.TextField()
#     date_created = models.DateTimeField(auto_now_add=True)
#     user_comments = models.TextField()
# 
#     def __unicode__(self):
#         return self.text[:80]
# 
# Path: tagger/models.py
# class Tag(models.Model):
#     """ Generic class to implement tagging. """
#     name = models.CharField(max_length=80, db_index=True, unique = True)
# 
#     def __unicode__(self):
#         return self.name
# 
# Path: users/models.py
# class UserProfile(models.Model):
#     """Extra user data.
#     
#     Fields:
# 
#     user: Django user for the profile.
#     facebook_user_id: User ID from the Facebook API.  This is populated if 
#                       the user chooses to register/login with Facebook.
#     is_verified: User has claimed account, filled in some optional fields.
#     reporter_verified: A reporter has contacted the user, probably for a story.
#     interest: Interest in seeking a user account.  This is populated by the 
#               signup form.
# 
#     """
# 
#     USER_TYPE_CHOICES = (
#     (u'R', u'reporter'),
#     (u'S', u'source'),
#     (u'A', u'author'))
# 
#     INTEREST_CHOICES = (
#         (u'', u'Neither or unanswered'),
#         (u'publisher', u'publisher'),
#         (u'consumer', u'consumer'),
#     )
# 
#     user = models.ForeignKey(User)
#     facebook_user_id = models.TextField(blank=True)
#     street_address = models.TextField(blank=True)
#     city = models.TextField(blank=True)
#     state = models.CharField(blank=True, max_length=2)
#     zip = models.CharField(blank=True, max_length=10)
#     phone_number = models.CharField(blank=True, max_length=12)
#     dob = models.DateField(blank=True, null = True)
#     user_type = models.CharField(max_length=15, choices = USER_TYPE_CHOICES)
#     is_verified = models.BooleanField(default = False)
#     reporter_verified = models.ForeignKey("UserProfile", blank=True, null=True)
#     interest = models.CharField(max_length=15, choices=INTEREST_CHOICES, 
#                                 default='', blank=True)
# 
#     def is_reporter(self):
#         return self.user_type == u'R'
# 
#     def __unicode__(self):
#         return self.user.username


from django.db import models
from django.contrib.sites.models import Site
from utils import comment_cmp, CountIfConcur, get_logger
from clipper.models import Article
from clipper.models import Clip
from tagger.models import Tag
from users.models import UserProfile
    def user_voted_comment_ids(self, user_profile):
        """ 
        Returns a queryset containing all comment ids for this topic on which a
        user has voted.
        
        """
        return self.user_responded_comment_ids(user_profile=user_profile, \
            response_type='concur')

class Comment(models.Model):
    """User-generated feedback to the system.  These will implement questions,
       answers, concerns and replies.

       Fields:

       related: Comments that are related to this comment, e.g. an answer to
                a question, a re-phrasing of a comment, a question about
                a comment, or something that is just conceptually related.
       sites: Sites which this content can appear on.  This is anticipating
              sharing content between multiple sites, e.g. a Chicago
              election site and an Evanston local news site.
       comment_type: Question, concern, respsonse ...
       topics: Topics to which this comment relates.
       sources: different from a comment you own; these are comments you're associated with
       where that user may not even be an active user in the database. We'll set to is_active=False, to 
       reflect, e.g., MOS interviews. Will set up claiming process so these users can BECOME active by entering contact
       info, etc.
       is_parent: after several comments are merged, one becomes the parent. By default, this is the only one shown. Defaults
       to true, since comment is assumed to be its own parent when it's independent/visible."""
    text = models.TextField()

# Path: clipper/models.py
# class Article(models.Model):
#     """ A news article.  These will be the sources for answers. """
#     url = models.URLField(verify_exists=False, unique = True) 
#     news_organization = models.ForeignKey("NewsOrganization", related_name='articles_created') 
#     source = models.ForeignKey("NewsOrganization", related_name = 'articles_sourced')
#     authors = models.ManyToManyField(UserProfile) 
#     title = models.CharField(max_length=200)
#     date_published = models.DateTimeField(null=True)
#     # But we'll probably not be tagging articles initially, just aggregating tags from
#     # related clips
#     tags = models.ManyToManyField(Tag, null=True) 
# 
#     def __unicode__(self):
#         return self.title
# 
# Path: clipper/models.py
# class Clip(models.Model):
#     """ Relevent text from an article.  """
#     tags = models.ManyToManyField(Tag, null=True) 
#     article = models.ForeignKey(Article) 
#     user = models.ForeignKey(UserProfile)
#     text = models.TextField()
#     date_created = models.DateTimeField(auto_now_add=True)
#     user_comments = models.TextField()
# 
#     def __unicode__(self):
#         return self.text[:80]
# 
# Path: tagger/models.py
# class Tag(models.Model):
#     """ Generic class to implement tagging. """
#     name = models.CharField(max_length=80, db_index=True, unique = True)
# 
#     def __unicode__(self):
#         return self.name
# 
# Path: users/models.py
# class UserProfile(models.Model):
#     """Extra user data.
#     
#     Fields:
# 
#     user: Django user for the profile.
#     facebook_user_id: User ID from the Facebook API.  This is populated if 
#                       the user chooses to register/login with Facebook.
#     is_verified: User has claimed account, filled in some optional fields.
#     reporter_verified: A reporter has contacted the user, probably for a story.
#     interest: Interest in seeking a user account.  This is populated by the 
#               signup form.
# 
#     """
# 
#     USER_TYPE_CHOICES = (
#     (u'R', u'reporter'),
#     (u'S', u'source'),
#     (u'A', u'author'))
# 
#     INTEREST_CHOICES = (
#         (u'', u'Neither or unanswered'),
#         (u'publisher', u'publisher'),
#         (u'consumer', u'consumer'),
#     )
# 
#     user = models.ForeignKey(User)
#     facebook_user_id = models.TextField(blank=True)
#     street_address = models.TextField(blank=True)
#     city = models.TextField(blank=True)
#     state = models.CharField(blank=True, max_length=2)
#     zip = models.CharField(blank=True, max_length=10)
#     phone_number = models.CharField(blank=True, max_length=12)
#     dob = models.DateField(blank=True, null = True)
#     user_type = models.CharField(max_length=15, choices = USER_TYPE_CHOICES)
#     is_verified = models.BooleanField(default = False)
#     reporter_verified = models.ForeignKey("UserProfile", blank=True, null=True)
#     interest = models.CharField(max_length=15, choices=INTEREST_CHOICES, 
#                                 default='', blank=True)
# 
#     def is_reporter(self):
#         return self.user_type == u'R'
# 
#     def __unicode__(self):
#         return self.user.username


# Path: core/models.py
from django.db import models
from django.contrib.sites.models import Site
from utils import comment_cmp, CountIfConcur, get_logger
from clipper.models import Article
from clipper.models import Clip
from tagger.models import Tag
from users.models import UserProfile

    def user_voted_comment_ids(self, user_profile):
        """ 
        Returns a queryset containing all comment ids for this topic on which a
        user has voted.
        
        """
        return self.user_responded_comment_ids(user_profile=user_profile, \
            response_type='concur')

class Comment(models.Model):
    """User-generated feedback to the system.  These will implement questions,
       answers, concerns and replies.

       Fields:

       related: Comments that are related to this comment, e.g. an answer to
                a question, a re-phrasing of a comment, a question about
                a comment, or something that is just conceptually related.
       sites: Sites which this content can appear on.  This is anticipating
              sharing content between multiple sites, e.g. a Chicago
              election site and an Evanston local news site.
       comment_type: Question, concern, respsonse ...
       topics: Topics to which this comment relates.
       sources: different from a comment you own; these are comments you're associated with
       where that user may not even be an active user in the database. We'll set to is_active=False, to 
       reflect, e.g., MOS interviews. Will set up claiming process so these users can BECOME active by entering contact
       info, etc.
       is_parent: after several comments are merged, one becomes the parent. By default, this is the only one shown. Defaults
       to true, since comment is assumed to be its own parent when it's independent/visible."""
    text = models.TextField()

    user = models.ForeignKey(UserProfile, related_name="comments")