<commit_before>from django.db import models
from django.db.models.signals import post_save
from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey, \
    GenericRelation
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.dispatch import receiver
from django.template import Template, Context

from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site

from future.utils import python_2_unicode_compatible

from . import appsettings


WORKFLOW_STATUS_CHOICES = (
    ('new', 'New'),
    ('ready_to_review', 'Ready to review'),
    ('approved', 'Approved'),
)

# First status choice is the default
WORKFLOW_STATUS_DEFAULT = WORKFLOW_STATUS_CHOICES[0][0]


@python_2_unicode_compatible
class WorkflowState(models.Model):
    # Generic Foreign Key fields to arbitrary object
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey(
        'content_type',
        'object_id',
        # Permit references to proxy models
        for_concrete_model=False,
    )

    status = models.CharField(
        max_length=254,
        choices=WORKFLOW_STATUS_CHOICES,
        default=WORKFLOW_STATUS_DEFAULT,
    )
    assigned_to = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        blank=True,
        null=True,
        help_text='User who is responsible for this content at this stage in the workflow',
        on_delete=models.SET_NULL,
    )

    class Meta:
        db_table = "icekit_workflow_workflowstate"

    def __str__(self):
        if self.assigned_to:
            return ' '.join([
                self.get_status_display(),
                ':',
                str(self.assigned_to),
            ])
        else:
            return self.get_status_display()


class WorkflowStateMixin(models.Model):
    workflow_states = GenericRelation(WorkflowState)

    class Meta:<commit_msg>Fix odd DB migration behaviour for workflow app's model, re #190<commit_after>from django.db import models
from django.db.models.signals import post_save
from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey, \
    GenericRelation
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.dispatch import receiver
from django.template import Template, Context

from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site

from future.utils import python_2_unicode_compatible

from . import appsettings


WORKFLOW_STATUS_CHOICES = (
    ('new', 'New'),
    ('ready_to_review', 'Ready to review'),
    ('approved', 'Approved'),
)

# First status choice is the default
WORKFLOW_STATUS_DEFAULT = WORKFLOW_STATUS_CHOICES[0][0]


@python_2_unicode_compatible
class WorkflowState(models.Model):
    # Generic Foreign Key fields to arbitrary object
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey(
        'content_type',
        'object_id',
        # Permit references to proxy models
        for_concrete_model=False,
    )

    status = models.CharField(
        max_length=254,
        choices=WORKFLOW_STATUS_CHOICES,
        default=WORKFLOW_STATUS_DEFAULT,
    )
    assigned_to = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        blank=True,
        null=True,
        help_text='User who is responsible for this content at this stage in the workflow',
        on_delete=models.SET_NULL,
    )

    class Meta:
        app_label = 'icekit_workflow'

    def __str__(self):
        if self.assigned_to:
            return ' '.join([
                self.get_status_display(),
                ':',
                str(self.assigned_to),
            ])
        else:
            return self.get_status_display()


class WorkflowStateMixin(models.Model):
    workflow_states = GenericRelation(WorkflowState)

    class Meta:
{'fraction_non_alphanumeric': 0.07675222112537018, 'fraction_numerical': 0.004195459032576505, 'mean_word_length': 3.1913133402275076, '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': '4300445', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1127, 'n_words': 279}