Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

django_choices_flow

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django_choices_flow

Simple library with flow in choices values for Django

  • 0.9.3
  • PyPI
  • Socket score

Maintainers
1

django-choices-flow

Meta Choice with simple flow and rules

|Build Status| |Coverage Status|

Usage

.. code:: python

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


.. code:: python

    >>> 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
---------

.. code:: bash

    # 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

.. |Build Status| image:: https://travis-ci.org/valdergallo/django-choices-flow.png?branch=master
   :target: https://travis-ci.org/valdergallo/django-choices-flow
.. |Coverage Status| image:: https://coveralls.io/repos/valdergallo/django-choices-flow/badge.png
   :target: https://coveralls.io/r/valdergallo/django-choices-flow

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc