Example #1
0
    def test_manager_get_settings_known_value(self):
        '''
        FAIL: test_manager_get_settings_known_value (tests.configuration.tests.ModelTests)
        ----------------------------------------------------------------------
        Traceback (most recent call last):
        File "/home/travis/build/django-bmf/django-bmf/tests/configuration/tests.py", line 26, in test_manager_get_settings_known_value
        value = Configuration.get_setting('test', 'test1')
        File "/home/travis/build/django-bmf/django-bmf/.tox/py34-1.8/lib/python3.4/site-packages/django/test/testcases.py", line 110, in __exit__
        query['sql'] for query in self.captured_queries
        AssertionError: 0 != 1 : 0 queries executed, 1 expected
        Captured queries were:
        '''
        obj = Configuration(app_label='test', field_name='test1', value='"test1"')
        obj.save()
        site.register_settings("test", {
            'test1': forms.CharField(
                max_length=5,
            ),
        })
        with self.assertNumQueries(1):
            value = Configuration.get_setting('test', 'test1')
        self.assertEqual(value, "test1", "Load a known setting value from database")

        # test loading from cache
        with self.assertNumQueries(0):
            value = Configuration.get_setting('test', 'test1')

        self.assertEqual(value, "test1", "Load a known setting value from cache")
Example #2
0
 def test_manager_get_settings_new_none(self):
     site.register_settings("test", {
         'test3': forms.CharField(
             max_length=5,
         ),
     })
     value = Configuration.get_setting('test', 'test3')
     self.assertEqual(value, None, "Load a new setting value from database")
Example #3
0
 def test_manager_get_settings_new_initial(self):
     '''
     FAIL: test_manager_get_settings_new_initial (tests.configuration.tests.ModelTests)
     ----------------------------------------------------------------------
     Traceback (most recent call last):
     File "/home/travis/build/django-bmf/django-bmf/tests/configuration/tests.py", line 55, in test_manager_get_settings_new_initial
     self.assertEqual(value, 'test2', "Load a new setting value from database")
     AssertionError: None != 'test2' : Load a new setting value from database
     '''
     site.register_settings("test", {
         'test2': forms.CharField(
             max_length=5,
             initial='test2',
         ),
     })
     value = Configuration.get_setting('test', 'test2')
     self.assertEqual(value, 'test2', "Load a new setting value from database")
Example #4
0
    model = Product
    default = True
    create = ProductCreateView
    detail = ProductDetailView
    update = ProductUpdateView


@register(dashboard=Sales)
class ProductTaxModule(Module):
    model = ProductTax
    default = True


site.register_settings(
    'bmfcontrib_product', {
        'default':
        forms.ModelChoiceField(queryset=Product.objects.filter(
            type=PRODUCT_SERVICE)),
    })


@register(category=ProductCategory)
class SellableProducts(ViewMixin):
    model = Product
    name = _("Sellable products")
    slug = "sell"

    def filter_queryset(self, request, queryset, view):
        return queryset.filter(can_sold=True, )


@register(category=ProductCategory)
Example #5
0
from djangobmf.sites import site

from .apps import AccountingConfig

from .models import ACCOUNTING_INCOME
from .models import ACCOUNTING_EXPENSE
from .models import ACCOUNTING_ASSET
from .models import ACCOUNTING_LIABILITY

from .models import Account
site.register(Account)

from .models import Transaction
from .views import TransactionCreateView
from .views import TransactionDetailView
from .views import TransactionUpdateView

site.register(Transaction, **{
    'create': TransactionCreateView,
    'detail': TransactionDetailView,
    'update': TransactionUpdateView,
})

SETTINGS = {
    'income': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_INCOME)),
    'expense': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_EXPENSE)),
    'customer': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_ASSET)),
    'supplier': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_LIABILITY)),
}
site.register_settings(AccountingConfig.label, SETTINGS)
Example #6
0
    default = True
    create = TransactionCreateView
    update = TransactionUpdateView
    serializer = TransactionSerializer


@register(dashboard=Accounting)
class TransactionItemModule(Module):
    model = TransactionItem
    default = True
    serializer = TransactionItemSerializer


site.register_settings('bmfcontrib_accounting', {
    'income': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_INCOME)),
    'expense': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_EXPENSE)),
    'customer': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_ASSET)),
    'supplier': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_LIABILITY)),
})


@register(category=TransactionCategory)
class AllAccounts(ViewMixin):
    model = Account
    name = _("All Accounts")
    slug = "accounts"


@register(category=TransactionCategory)
class OpenTransactions(ViewMixin):
    model = Transaction
    name = _("Open transactions")
Example #7
0
    default = True
    create = TransactionCreateView
    update = TransactionUpdateView


@register(dashboard=Accounting)
class TransactionItemModule(Module):
    model = TransactionItem
    default = True


site.register_settings(
    "bmfcontrib_accounting",
    {
        "income": forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_INCOME)),
        "expense": forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_EXPENSE)),
        "customer": forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_ASSET)),
        "supplier": forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_LIABILITY)),
    },
)


@register(category=TransactionCategory)
class AllAccounts(ViewMixin):
    model = Account
    name = _("All Accounts")
    slug = "accounts"


@register(category=TransactionCategory)
class OpenTransactions(ViewMixin):
Example #8
0
class ProductModule(Module):
    model = Product
    default = True
    create = ProductCreateView
    update = ProductUpdateView
    detail = ProductDetailView


@register
class ProductTaxModule(Module):
    model = ProductTax
    default = True


site.register_settings('bmfcontrib_product', {
    'default': forms.ModelChoiceField(queryset=Product.objects.filter(type=PRODUCT_SERVICE)),
})


@register(category=ProductCategory)
class SellableProducts(ViewMixin):
    model = Product
    name = _("Sellable products")
    slug = "sell"

    def filter_queryset(self, request, queryset, view):
        return queryset.filter(
            can_sold=True,
        )

Example #9
0
class TransactionModule(Module):
    model = Transaction
    default = True
    create = TransactionCreateView
    update = TransactionUpdateView


@register(dashboard=Accounting)
class TransactionItemModule(Module):
    model = TransactionItem
    default = True


site.register_settings('bmfcontrib_accounting', {
    'income': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_INCOME)),
    'expense': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_EXPENSE)),
    'customer': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_ASSET)),
    'supplier': forms.ModelChoiceField(queryset=Account.objects.filter(type=ACCOUNTING_LIABILITY)),
})


@register(category=TransactionCategory)
class AllAccounts(ViewMixin):
    model = Account
    name = _("All Accounts")
    slug = "accounts"


@register(category=TransactionCategory)
class OpenTransactions(ViewMixin):
    model = Transaction
    name = _("Open transactions")
Example #10
0
#!/usr/bin/python
# ex:set fileencoding=utf-8:

from __future__ import unicode_literals

from django import forms

from djangobmf.sites import site

from .apps import ProductConfig

from .models import Product
from .models import PRODUCT_SERVICE
from .views import ProductCreateView
from .views import ProductDetailView
from .views import ProductUpdateView

site.register(Product, **{
    'create': ProductCreateView,
    'detail': ProductDetailView,
    'update': ProductUpdateView,
})

SETTINGS = {
    'default': forms.ModelChoiceField(queryset=Product.objects.filter(type=PRODUCT_SERVICE)),
}
site.register_settings(ProductConfig.label, SETTINGS)