-
-
Save rhoerbe/eb27d7ef86572a0fe8c326f441b293f6 to your computer and use it in GitHub Desktop.
"I think we need to create cron management command (say, once per hour) or sync in a background task while login as you suggested to import data from git to django db. Also, we need to check for git conflicts while MDstatement is saving (pre_save signal) (return an error to a user if local git repo is outdated)." | |
>>So we need effectively an idempotent sync, that will be triggered by cron, login, and after save conflicts. Correct? | |
"'that we will need an API to add/modify/delete a MDstatement.' | |
Also, we need API for checkout status in this way." | |
>>Please explain. I thought, that an API-transaction (add/replace/delete) will be stateless, not requiring a checkout, only throwing an error if a lock exists. | |
ChangeView signal / API checkout method (create a new CheckOut status) | |
1.2. if MDstatement has CheckOut status and datetime < 15 min we will block Django admin change view / API - return error "can't create checkout" | |
>>The checkout date should be set to now() every time the user posts a form. | |
1.3. if MDstatement has CheckOut status and datetime > 15 min we will delete old CheckOut status and Create a new one / API return "success" | |
1.4. if MDstatement has no CheckOut we will create Create a new one / API return "success" | |
MDstatement pre save signal | |
2.1 If we do not find CheckOut status for current MDstatement and user - block saving (shown error API django admin both) | |
MDstatement post save signal | |
3.1. remove CheckOut status for current user if exists | |
So far OK. |
The checkout date should be set to now() every time the user posts a form.
Do you mean requests a form?
Please explain. I thought, that an API-transaction (add/replace/delete) will be stateless, not requiring a checkout, only throwing an error if a lock exists.
As you wish, but a user (do you plan to use API in a custom application?) can be want to know that MDstatement is locked before he starts to edit a record.
No, an error message will be good enough. Anyway, manual and API access should not overlap in theory.
The checkout date should be set to now() every time the user posts a form.
Do you mean requests a form?
Each time a user klicks "Save" on the MDstatement form, the checkout timer should start again.
The checkout date should be set to now() every time the user posts a form.
Do you mean requests a form?
Each time a user klicks "Save" on the MDstatement form, the checkout timer should start again.
I disagree, when the user clicks save we can redirect him to a records list for example.
My suggestion:
- ChangeView signal
1.1. MDstatement has CheckOut status (with checkout_by==request.user) then CheckOut.created_at==datetime.now()
1.2. if MDstatement has CheckOut status (with checkout_by!=request.user) and datetime < 15 min we will block Django admin change view / API - return error "can't create checkout"
1.3. if MDstatement has CheckOut status (with checkout_by!=request.user) and datetime > 15 min we will delete old CheckOut status and Create a new one / API return "success"
1.4. if MDstatement has no CheckOut we will create Create a new one / API return "success"
I disagree, when the user clicks save we can redirect him to a records list for example.
OK for the happy path, but I found that users will upload invalid data for the first few attempts. So save -> reload form with error messages should reset the timer. O
I disagree, when the user clicks save we can redirect him to a records list for example.
OK for the happy path, but I found that users will upload invalid data for the first few attempts. So save -> reload form with error messages should reset the timer. O
Form errors in Django = request form + providing errors information. Ok, I got it.
Yes, I think we need to create a function or class for this and use it in any place we want.