- Like perform operations, cancel_operations can add/remove an account
from negative accounts system.
- Balances checks are now performed against real_balance instead of
balance.
So if someone with a balance_offset go, for real, to positive land (ie even
without taking into account the balance offset), its account is removed from
the negative system.
- Fix bug on real_balance when negative exists but balance_offset is
not set.
Fixes#156.
Order create view use WeekScale. No query improvements, only shorter
code.
Scale/ScaleMixin:
- Two methods directly relative to the Scale class move to... the Scale
class.
- Fix order create on Chrome.
Scales:
- Fix #chunks when used with std_chunk=True (there was one too many at
the beginning)
- Scale.end gives the end of the last chunk (instead of its start)
So scale.begin -> scale.end gives the full range of the scale.
`kfet_day` now returns an aware datetime.
ScaleMixin:
- new method `get_by_chunks` which use only one query and ranks
elements according to the scale. Elements are returned by a generator
for each scale chunk (and all chunks are returned as a generator too).
ArticlesStatSales and AccountStatOperations use this new method to
avoid issuing #scale_chunks queries.
ArticleStat:
- fixed on Chrome
- AccountNegative use new AccountNegativeManager which select_related
account, cofprofile and user for instances accessed via
AccountNegative.objects.
- Compute sum of negatives with python instead of an SQL statement
(since we already got the data with a previous query).
- Fix bug on account property `real_balance` (happened if
an account has a relative AccountNegative instance but balance_offset
to NULL).
- More compliant to PEP8
- When Account model is queried with Account.objects, it always add
.select_related('cofprofile_user', 'negative').
- Eg benefits: history doesn't do anymore one request by account to
fill the account filter.
Important
Using this workaround (systemically append select_related) can be
dangerous normally, however a certain number of properties in
cofprofile and user are frequently used (as firstname or lastname), and
the benefits seems greater.
- clean buttons code on account and checkout
- merge CheckoutRead and kpsul_checkout_data views (the first won)
APIModelObject interface
- add url_create, url_update, url_update_for
- rename url_object_for and url_object to url_read_for and url_read
- KFetConfig `set` method now takes model instance instead of their pk
for this type of entries.
- Add tests for KFetConfig class: tests against types currently used by
kfet app (duration, modelinstance, decimal).
- These tests are located in `kfet/tests/test_config.py`. We should
separate tests suites by file like this, considering what they are about.
- KFetConfig method `set_many` renamed to `set` (because it also updates
only one).