# 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 tagger.models import Tag
from users.models import UserProfile

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

class Clip(models.Model):
    """ Relevent text from an article.  """
    tags = models.ManyToManyField(Tag, null=True) 
    article = models.ForeignKey(Article) 

# 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: clipper/models.py
from django.db import models
from tagger.models import Tag
from users.models import UserProfile


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

class Clip(models.Model):
    """ Relevent text from an article.  """
    tags = models.ManyToManyField(Tag, null=True) 
    article = models.ForeignKey(Article) 

    user = models.ForeignKey(UserProfile)