<commit_before>from django.db import models
from LabtrackerCore.models import Item,InventoryType,Group
from django.contrib.auth.models import User
from django.test import TestCase

class ResolveState(models.Model):
    """
    Issues are resolved into a resolve state such as this
    """

    rs_id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=60)
    description = models.CharField(max_length=400)

    def __unicode__(self):
        return self.name

class ProblemType(models.Model):
    """
    Issues have mulitple probme types associated to them
    """

    pb_id = models.AutoField(primary_key=True)
    inv = models.ManyToManyField(InventoryType, blank=True, null=True)
    name = models.CharField(max_length=60, unique=True)
    description = models.CharField(max_length=400)

    def __unicode__(self):
        return self.name

class Issue(models.Model):
    """
    Issues can be related to specific items or the whole InventoryType.
    Therefore, item_id is null=True
    """

    issue_id = models.AutoField(primary_key=True, editable=False)

    it = models.ForeignKey(InventoryType, verbose_name="Inventory Type", blank=True,
            null=True)
    group = models.ForeignKey(Group, null=True, blank=True)
    item = models.ForeignKey(Item, null=True, blank=True)
    reporter = models.ForeignKey(User, related_name='reporter')

    assignee = models.ForeignKey(User, related_name='assignee', null=True, 
            blank=True)
    cc = models.ManyToManyField(User, related_name="cc_user", null=True, 
            blank=True, verbose_name="CC", db_table="IssueTracker_email_cc")
    problem_type = models.ManyToManyField(ProblemType, null=True, blank=True)
    post_time = models.DateTimeField(auto_now_add=True)
    last_modified = models.DateTimeField(auto_now=True, null=True)
    resolve_time = models.DateTimeField(null=True, blank=True)
    resolved_state = models.ForeignKey(ResolveState, null=True, blank=True)
    title = models.CharField(max_length=200)
    description = models.TextField()

    def __unicode__(self):
        return "%d - %s" % (self.issue_id, self.title)

    @models.permalink
    def get_absolute_url(self):
        return ('IssueTracker.views.viewIssue', [str(self.issue_id)])


    class Meta:
        permissions = (("can_modify_other", "Can modify anybody's posts"),
                    ("can_delete_other", "Can delete anybody's posts"),
                    ("can_view", "Can view issues"),)

class IssueHistory(models.Model):
    """
    Basically, keeps track of some of the changes made to a model outside of 
    the IssueComment area
    """

    ih_id = models.AutoField(primary_key=True)
    user = models.ForeignKey(User)
    issue = models.ForeignKey(Issue)
    time = models.DateTimeField(auto_now=True)
    message = models.CharField(max_length=300)

class IssueComment(models.Model):
    """
    This is for the comments people add to each issues<commit_msg>save method overriden, will now update resolve time if the resolved_state changes<commit_after>from datetime import datetime
from django.db import models
from LabtrackerCore.models import Item,InventoryType,Group
from django.contrib.auth.models import User
from django.test import TestCase

class ResolveState(models.Model):
    """
    Issues are resolved into a resolve state such as this
    """

    rs_id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=60)
    description = models.CharField(max_length=400)

    def __unicode__(self):
        return self.name

class ProblemType(models.Model):
    """
    Issues have mulitple probme types associated to them
    """

    pb_id = models.AutoField(primary_key=True)
    inv = models.ManyToManyField(InventoryType, blank=True, null=True)
    name = models.CharField(max_length=60, unique=True)
    description = models.CharField(max_length=400)

    def __unicode__(self):
        return self.name

class Issue(models.Model):
    """
    Issues can be related to specific items or the whole InventoryType.
    Therefore, item_id is null=True
    """

    issue_id = models.AutoField(primary_key=True, editable=False)

    it = models.ForeignKey(InventoryType, verbose_name="Inventory Type", blank=True,
            null=True)
    group = models.ForeignKey(Group, null=True, blank=True)
    item = models.ForeignKey(Item, null=True, blank=True)
    reporter = models.ForeignKey(User, related_name='reporter')

    assignee = models.ForeignKey(User, related_name='assignee', null=True, 
            blank=True)
    cc = models.ManyToManyField(User, related_name="cc_user", null=True, 
            blank=True, verbose_name="CC", db_table="IssueTracker_email_cc")
    problem_type = models.ManyToManyField(ProblemType, null=True, blank=True)
    post_time = models.DateTimeField(auto_now_add=True)
    last_modified = models.DateTimeField(auto_now=True, null=True)
    resolve_time = models.DateTimeField(null=True, blank=True)
    resolved_state = models.ForeignKey(ResolveState, null=True, blank=True)
    title = models.CharField(max_length=200)
    description = models.TextField()

    def save(self, *args, **kwargs):
        # check to see if the resolved_state has changed, if so, then change 
        # resolve_time
        old = Issue.objects.get(pk=self.pk)

        if old.resolved_state != self.resolved_state:
            self.resolve_time = datetime.now()

        super(Issue, self).save(*args, **kwargs)


    def __unicode__(self):
        return "%d - %s" % (self.issue_id, self.title)

    @models.permalink
    def get_absolute_url(self):
        return ('IssueTracker.views.viewIssue', [str(self.issue_id)])


    class Meta:
        permissions = (("can_modify_other", "Can modify anybody's posts"),
                    ("can_delete_other", "Can delete anybody's posts"),
                    ("can_view", "Can view issues"),)

class IssueHistory(models.Model):
    """
    Basically, keeps track of some of the changes made to a model outside of 
    the IssueComment area
    """

    ih_id = models.AutoField(primary_key=True)
    user = models.ForeignKey(User)
    issue = models.ForeignKey(Issue)
    time = models.DateTimeField(auto_now=True)
    message = models.CharField(max_length=300)

class IssueComment(models.Model):
    """
    This is for the comments people add to each issues
{'fraction_non_alphanumeric': 0.10484886649874055, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 3.716406829992576, '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': '773128', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1865, 'n_words': 447}