django-locking icon indicating copy to clipboard operation
django-locking copied to clipboard

changes I wanted to discuss.. but failed ;)

Open chromakey-io opened this issue 15 years ago • 2 comments

Hey,

Sorry I didn't get back to you on gchat. I wanted to discuss, however our waking hours don't line up very well I guess.

I just pushed in some additional stuff that is useful for the public api. I added some methods to the standard objects model manager.

MyModel.objects.locked() MyModel.objects.unlocked() MyModel.objects.locked_for(user)

This has been pretty useful in my current app, as I'm using django-forms and views rather than the admin to manipulate data.

I additionally have a locking-form that locks with the current user on load, then unlocks on save ... though the implementation is not very user friendly. When I have the time I will re-write it and make another pull request if you are interested. Though it too has proven to be very useful in my current application.

Here is a dpaste of my current form implementation. Though I think I can come up with something a bit more user friendly (the curry stuff is kind of hacky). Perhaps a method like locked_formset_factory() or some such to generate the formsets associated to the user in the view. Thoughts?

http://dpaste.com/305663/

Thanks...

chromakey-io avatar Jan 11 '11 07:01 chromakey-io

Hi Kevin. I just moved to London so I'm a tad bit busy right now, but I hope to be able to take a look at your stuff early next week. Thanks for your patience & cheers.

debrouwere avatar Jan 20 '11 19:01 debrouwere

So, I've just pushed a bunch of changes to django-locking, among which managers inspired on yours (thanks!). However, I'm a bit wary of adding in stuff using qs.extra, so I used your first approach, which you mention has a "logic failure". I believe the lapse in logic is that you do + timeout_delta for unlocked, but - timeout_delta for locked, whereas it should be minus for both. Aside from that your original approach seems to work fine, and my tests are passing.

Am I missing anything obvious?

debrouwere avatar Feb 04 '11 17:02 debrouwere