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
- kfet_config gives "reduction_cof" as editable instead of
"subvention_cof"
- this last one can still be accessed via kfet_config (computed from
new "reduction_cof"
- add units to numeric values of kfet_config form
- PermConsumerMixin allows checking permissions on connection to a
consumer.
- KPsul consumer uses this mixin to check if connecting user has the
permission `kfet.is_team`.
Fixes#67.
- Use last official releases of channels, asgiref, daphne and
asgi-redis packages.
- Customization of JsonWebsocketConsumer is now in kfet app through a
custom class (and so, doesn't require anymore a forked version of channels).
- Clean kfet consumers code.
- Fewer requests on choicesreventes and tabular inlines (of
attributions)
- User and tirage cannot be updated if updating a participant instance.
- Tabular inlines are fixed:
- the one which is used for spectacles with listing only propose
choices in spectacle with listing
- same with the other (spectacles without listing)
- Still does too much request (because of tabularinlines)
- New attribution form issue less queries
- Spectacle and Participant are readonly if updating an attribution.
ReadOnlyMixin allows to set readonly fields only while updating an
object.
bda.algorithm
- use iterator to find max_groups, instead of a db request
bda.views.do_tirage
- select_related() are now focused on some relationships (they were
taking useless relationships)
- bda-revente filling takes 1 request (each save and add was issuing
1 request)
bda.views.etat_places
- Use select_related on spectacles_set, avoid query issue for each spectacle.
- `slots__sum` is computed in view, instead of a query.
- Cleaner code (and avoid useless computations).
bda.views.places
- Add select_related on places, avoid query issue for each spectacle.
bda.views.inscription
- 1 query for spectacle field choices, instead of (#forms in formset *
#spectacles)
- Delete BaseBdaFormSet. The validation was redundant with
`unique_together` of ChoixSpectacle model.
- 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.
createopes script:
- more than 6x faster
- only bulk_create is used instead of create or save
- correctly create editions (~5% of created operations)
- ratio of withdrawals go from ~10% to ~5%