<commit_before>from __future__ import unicode_literals

import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
try:
    from django.utils.timezone import now
except ImportError:  # Django < 1.4
    now = datetime.datetime.now

from hvad.models import TranslatableModel
from hvad.models import TranslatedFields
from rapidsms.models import Contact


class Reporter(models.Model):
    contact = models.ForeignKey(Contact, related_name='reporters', unique=True)
    village = models.CharField(max_length=255, blank=True, default='')
    facility = models.CharField(max_length=255, blank=True, default='')
    role = models.CharField(max_length=255, blank=True, default='')

    def __unicode__(self):
        return self.contact.name


class Timeline(models.Model):
    "A series of milestones which users can subscribe for milestone events."

    name = models.CharField(max_length=255)
    slug = models.CharField(max_length=255,
                            help_text=_('The keyword(s) to match in messages '
                                        'from the user. Specify multiple '
                                        'keywords by separating them with '
                                        'vertical bars. e.g., '
                                        '"birth|bith|bilth"'))

    def __unicode__(self):
        return self.name

    @property
    def keywords(self):
        return map(lambda k: k.strip().lower(), self.slug.split('|'))


class TimelineSubscription(models.Model):
    "Subscribing a user to a timeline of events."
<commit_msg>add Reporters view<commit_after>from __future__ import unicode_literals

import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
try:
    from django.utils.timezone import now
except ImportError:  # Django < 1.4
    now = datetime.datetime.now

from hvad.models import TranslatableModel
from hvad.models import TranslatedFields
from rapidsms.models import Contact


class Reporter(models.Model):
    contact = models.ForeignKey(Contact, related_name='reporters', unique=True)
    village = models.CharField(max_length=255, blank=True, default='')
    facility = models.CharField(max_length=255, blank=True, default='')
    role = models.CharField(max_length=255, blank=True, default='')

    def __unicode__(self):
        return self.contact.name


class ReporterList(models.Model):
    """View for the reporters"""
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=100)
    identity = models.TextField(default='')
    facility = models.TextField(default='')
    village = models.TextField(default='')
    created_on = models.DateField(null=True)

    class Meta:
        managed = False
        db_table = 'reporters'

    def __unicode__(self):
        return self.name


class Timeline(models.Model):
    "A series of milestones which users can subscribe for milestone events."

    name = models.CharField(max_length=255)
    slug = models.CharField(max_length=255,
                            help_text=_('The keyword(s) to match in messages '
                                        'from the user. Specify multiple '
                                        'keywords by separating them with '
                                        'vertical bars. e.g., '
                                        '"birth|bith|bilth"'))

    def __unicode__(self):
        return self.name

    @property
    def keywords(self):
        return map(lambda k: k.strip().lower(), self.slug.split('|'))


class TimelineSubscription(models.Model):
    "Subscribing a user to a timeline of events."

{'fraction_non_alphanumeric': 0.09410801963993454, 'fraction_numerical': 0.010092744135297326, 'mean_word_length': 2.641509433962264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2806486', 'n_tokens_mistral': 1032, 'n_tokens_neox': 967, 'n_words': 268}