<commit_before>"""
This module contains Mixins.

"""
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django_fsm import transition


class WorkflowMixin:
    """This mixin contains the transition methods used to switch states for
    Content; i.e. Categories, Goals, Behaviors, Actions.

    Once created, a piece of content can be in one of the following states:

    - Draft: Content is being created.
    - Pending Review: Content has been submitted for review and publish
    - Declined: Content is not suitbable for publishing and/or needs adjustment.
    - Published: Content is Available to the public via our api

    """
    # hack: needs to be defined here for transitions. Will get replaced by the
    # model's `state` field.
    state = None

    @transition(field=state, source="*", target='draft')
    def draft(self):
        pass

    @transition(field=state, source="draft", target='pending-review')
    def review(self):
        pass

    @transition(field=state, source="review", target='declined')
    def decline(self):
        pass

    @transition(field=state, source="review", target='published')
    def publish(self):
        pass


class URLMixin:
    """Contains methods for reversing Model URLs. This Mixin DRYs up the various
    get_XXXX_url methods that I use on models, particularly for Read, Update,
    and Delete actions.

    Models using this mixin can customize its behavior by specifying the
    following:

    * (required) urls_app_namespace: The url namespace used for the app
    * (required) urls_model_name: The model name used for the url
    * urls_slug_field: The unique slug used for the model. Default is `title_slug`
    * urls_icon_field: An icon field for the model. Defaut is None.
    * urls_image_field: An image field for the model. Defaut is None.

    And we make the assumption that we have the following URLs defined, e.g.
    for the Category model:

    * Read: category-detail
    * Update: category-update
    * Delete: category-delete

    """
    urls_app_namespace = None  # e.g. 'goals'
    urls_model_name = None  # e.g. 'category'
    urls_slug_field = "title_slug"  # e.g. 'name_slug', if different.
    urls_icon_field = None<commit_msg>fix state transition names<commit_after>"""
This module contains Mixins.

"""
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django_fsm import transition


class WorkflowMixin:
    """This mixin contains the transition methods used to switch states for
    Content; i.e. Categories, Goals, Behaviors, Actions.

    Once created, a piece of content can be in one of the following states:

    - Draft: Content is being created.
    - Pending Review: Content has been submitted for review and publish
    - Declined: Content is not suitbable for publishing and/or needs adjustment.
    - Published: Content is Available to the public via our api

    """
    # hack: needs to be defined here for transitions. Will get replaced by the
    # model's `state` field.
    state = None

    @transition(field=state, source="*", target='draft')
    def draft(self):
        pass

    @transition(field=state, source="draft", target='pending-review')
    def review(self):
        pass

    @transition(field=state, source="pending-review", target='declined')
    def decline(self):
        pass

    @transition(field=state, source=["draft", "pending-review"], target='published')
    def publish(self):
        pass


class URLMixin:
    """Contains methods for reversing Model URLs. This Mixin DRYs up the various
    get_XXXX_url methods that I use on models, particularly for Read, Update,
    and Delete actions.

    Models using this mixin can customize its behavior by specifying the
    following:

    * (required) urls_app_namespace: The url namespace used for the app
    * (required) urls_model_name: The model name used for the url
    * urls_slug_field: The unique slug used for the model. Default is `title_slug`
    * urls_icon_field: An icon field for the model. Defaut is None.
    * urls_image_field: An image field for the model. Defaut is None.

    And we make the assumption that we have the following URLs defined, e.g.
    for the Category model:

    * Read: category-detail
    * Update: category-update
    * Delete: category-delete

    """
    urls_app_namespace = None  # e.g. 'goals'
    urls_model_name = None  # e.g. 'category'
    urls_slug_field = "title_slug"  # e.g. 'name_slug', if different.
    urls_icon_field = None
{'fraction_non_alphanumeric': 0.08103975535168195, 'fraction_numerical': 0.0, 'mean_word_length': 3.3402843601895733, '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': '5807390', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1279, 'n_words': 513}