<commit_before>from datetime import date
from django.core.urlresolvers import reverse
from django.db import models

# Create your models here.

class Family(models.Model):
    class Meta:
        verbose_name_plural = 'Families'
    created_at = models.DateTimeField(auto_now_add=True)
    family_name = models.CharField(max_length=50)
    address1 = models.CharField(blank=True, max_length=255)
    address2 = models.CharField(blank=True, max_length=255)
    city = models.CharField(blank=True, max_length=50)
    postal_code = models.CharField(blank=True, max_length=10)
    state = models.CharField(blank=True, max_length=50)
    country = models.CharField(blank=True, max_length=70)
    notes = models.TextField(blank=True)
    def __str__(self):
        return self.family_name

class Member(models.Model):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female')
    )
    class Meta:
        abstract = True
    family = models.ForeignKey(Family)
    title = models.CharField(blank=True, max_length=15)
    first_name = models.CharField(max_length=50)
    middle_name = models.CharField(blank=True, max_length=255)
    last_name = models.CharField(default=Family.family_name, max_length=50)
    suffix = models.CharField(blank=True, max_length=15)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='M')
    birth_date = models.DateField(blank=True, null=True)
    date_joined = models.DateField(blank=True, null=True)
    notes = models.TextField(blank=True)
    def __str__(self):
        return '%s, %s' % (self.last_name, self.first_name)

class Adult(Member):
    occupation = models.CharField(blank=True, max_length=255)
    workplace = models.CharField(blank=True, max_length=255)
    work_address = models.CharField(blank=True, max_length=255)
    marital_status = models.CharField(blank=True, max_length=20)

    class Meta:
        ordering = ['id',]

    def get_absolute_url(self):
        return reverse('families:member', kwargs={
            'family_pk': self.family_id,
            'member_type': 'a',
            'member_pk': self.id,
            })

class Dependent(Member):
    school = models.CharField(blank=True, max_length=255)

    def get_absolute_url(self):
        return reverse('families:member', kwargs={
            'family_pk': self.family_id,
            'member_type': 'd',
            'member_pk': self.id,
            })
<commit_msg>Add user to Family table<commit_after>from datetime import date
from django.core.urlresolvers import reverse
from django.db import models

from django.contrib.auth.models import User
# Create your models here.

class Family(models.Model):
    class Meta:
        verbose_name_plural = 'Families'
    created_at = models.DateTimeField(auto_now_add=True)
    user = models.ForeignKey(User, blank=True, null=True, on_delete=models.SET_NULL)
    family_name = models.CharField(max_length=50)
    address1 = models.CharField(blank=True, max_length=255)
    address2 = models.CharField(blank=True, max_length=255)
    city = models.CharField(blank=True, max_length=50)
    postal_code = models.CharField(blank=True, max_length=10)
    state = models.CharField(blank=True, max_length=50)
    country = models.CharField(blank=True, max_length=70)
    notes = models.TextField(blank=True)
    def __str__(self):
        return self.family_name

class Member(models.Model):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female')
    )
    class Meta:
        abstract = True
    family = models.ForeignKey(Family)
    title = models.CharField(blank=True, max_length=15)
    first_name = models.CharField(max_length=50)
    middle_name = models.CharField(blank=True, max_length=255)
    last_name = models.CharField(max_length=50)
    suffix = models.CharField(blank=True, max_length=15)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='M')
    birth_date = models.DateField(blank=True, null=True)
    date_joined = models.DateField(blank=True, null=True)
    notes = models.TextField(blank=True)
    def __str__(self):
        return '%s, %s' % (self.last_name, self.first_name)

    def save(self, *args, **kwargs):
        self.last_name = self.family.family_name
        super(Member, self).save(*args, **kwargs)

class Adult(Member):
    occupation = models.CharField(blank=True, max_length=255)
    workplace = models.CharField(blank=True, max_length=255)
    work_address = models.CharField(blank=True, max_length=255)
    marital_status = models.CharField(blank=True, max_length=20)

    class Meta:
        ordering = ['id',]

    def get_absolute_url(self):
        return reverse('families:member', kwargs={
            'family_pk': self.family_id,
            'member_type': 'a',
            'member_pk': self.id,
            })

class Dependent(Member):
    school = models.CharField(blank=True, max_length=255)

    def get_absolute_url(self):
        return reverse('families:member', kwargs={
            'family_pk': self.family_id,
            'member_type': 'd',
            'member_pk': self.id,
            })

{'fraction_non_alphanumeric': 0.11955879456371873, 'fraction_numerical': 0.017333070711049833, 'mean_word_length': 3.6205641492265697, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6514831', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1619, 'n_words': 303}