Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Simple library with flow in choices values for Django

Project Description

Meta Choice with simple flow and rules

Usage

from django.db import models
from django_choices_flow import Choices
from django_choices_flow.models import FlowIntegerField


class MyChoices(Choices):
    NEW = 1, 'New content' # 'New content' is the display text
    WAIT = 2, 'Wait'
    CANCELED = -1, 'Canceled'
    ERROR = -2, 'Error'
    INVOICED = 3, 'Invoiced'

    # set transaction rules
    NEW_RULES = [NEW, INVOICED, CANCELED, ERROR]
    WAIT_RULES = [CANCELED, ERROR, INVOICED]
    INVOICED_RULES = [CANCELED]


class Invoces(models.Model):
    """
    To use only choices
    """
    number = models.IntegerField()
    status = models.IntegerField(choices=MyChoices, default=MyChoices.NEW)

    def __unicode__(self):
        return self.number


class FlowInvoice(models.Model):
    """
    To validate flow in choices
    """
    number = models.IntegerField()
    status = FlowIntegerField(choices=MyChoices, default=MyChoices.NEW)

    def __unicode__(self):
        return self.number

Shell

>>> flow = FlowInvoice.objects.create(number=1234)
>>> flow.status
1
>>> flow.status = MyChoices.INVOICED
>>> flow.full_clean()
>>> flow.save()
>>> flow.status
3
>>> flow.status = MyChoices.WAIT
>>> flow.full_clean()
ValidationError: {'status': [u'Invalid choice: Wait']}

Developer

# download code
git clone git@github.com:valdergallo/django-choices-flow.git

# install developer packages
make

# check coverage
make coverage

# test project
make test

#clean extra content
make clean

#send package
make send_package

#test py2 and py3
tox

License type: FREEBSD
South: Support migrations
Python: python 2.7 and python 3.3
Version: 0.9.2
Tested in Django: 1.2.x; 1.3.x; 1.4.x; 1.5.x; 1.6.x; 1.7.x
Release History

Release History

This version
History Node

0.9.3

History Node

0.9.2

History Node

0.9.0

History Node

0.8.5

History Node

0.8.0

History Node

0.6.5

History Node

0.6.2

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_choices_flow-0.9.3.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Nov 1, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting