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
Metadata
Release files for django_choices_flow 0.9.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_choices_flow-0.9.3.tar.gz | 4.9 kB | Without provenance | Details |
Release files / django_choices_flow-0.9.3.tar.gz
| Download URL | django_choices_flow-0.9.3.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ced1c01d9f6935ae550dce22d528d4ea147306d8c3770a0d96fa8552eb9a42d
|
|
BLAKE2b-256 checksum How to use checksums |
e38e170d8a0f6f31620672c5b707202ad60fcded7d13befef2c7c3b61287ad77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django_choices_flow 0.9.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.