Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes I wanted to discuss.. but failed ;) #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chromakey-io
Copy link

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...

K. Noah added 2 commits January 11, 2011 02:16
… access with the public api. objects.locked(), objects.unlocked(), objects.locked_for(user) ... which could be useful in a number of cases
@debrouwere
Copy link
Owner

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
Copy link
Owner

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?

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

Successfully merging this pull request may close these issues.

2 participants