Skip to content

Instantly share code, notes, and snippets.

@rhoerbe
Created October 10, 2018 16:26
Show Gist options
  • Save rhoerbe/eb27d7ef86572a0fe8c326f441b293f6 to your computer and use it in GitHub Desktop.
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.
@LennyLip
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment