django-nonrel / django-permission-backend-nonrel Goto Github PK
View Code? Open in Web Editor NEWA Django authentication backend that supports Django's user and group permissions on Django-Nonrel.
License: Other
A Django authentication backend that supports Django's user and group permissions on Django-Nonrel.
License: Other
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. All documentation is in the "docs" directory and online at http://docs.djangoproject.com/en/dev/. If you're just getting started, here's how we recommend you read the docs: * First, read docs/intro/install.txt for instructions on installing Django. * Next, work through the tutorials in order (docs/intro/tutorial01.txt, docs/intro/tutorial02.txt, etc.). * If you want to set up an actual deployment server, read docs/howto/deployment/index.txt for instructions. * You'll probably want to read through the topical guides (in docs/topics) next; from there you can jump to the HOWTOs (in docs/howto) for specific problems, and check out the reference (docs/ref) for gory details. * See docs/README for instructions on building an HTML version of the docs. Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to fill out a ticket here: http://code.djangoproject.com/newticket To get more help: * Join the #django channel on irc.freenode.net. Lots of helpful people hang out there. Read the archives at http://django-irc-logs.com/. * Join the django-users mailing list, or read the archives, at http://groups.google.com/group/django-users. To contribute to Django: * Check out http://www.djangoproject.com/community/ for information about getting involved. To run Django's test suite: * Follow the instructions in the "Unit tests" section of docs/internals/contributing.txt, published online at https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests
When opening "change password form" from admin page, I got error AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'4fa8d63ef8...' instead)
Line 24 is always returning an empty set for me.
group_perm_lists = GroupPermissionList.objects.filter(group__id__in=user_perm_obj.group_fk_list)
It seems to be related to this bug django-nonrel/djangotoolbox#8 where subqueries (ie __in) will fail silently.
There are two failing unit tests that may be related to this:
FAIL: test_custom_perms (permission_backend_nonrel.tests.BackendTest)
Traceback (most recent call last):
File "/Users/johnie/Projects/gitrepos/demo/venv_demo/src/django-permission-backend-nonrel/permission_backend_nonrel/tests.py", line 213, in test_custom_perms
self.assertEqual(user.get_all_permissions(), exp)
AssertionError: Items in the second set but not the first:
u'auth.test_group'
FAIL: test_update_permissions_group (permission_backend_nonrel.tests.BackendTest)
Traceback (most recent call last):
File "/Users/johnie/Projects/gitrepos/demo/venv_demo/src/django-permission-backend-nonrel/permission_backend_nonrel/tests.py", line 108, in test_update_permissions_group
self.assertEqual(user.has_perm('auth.test'), True)
AssertionError: False != True
I was trying to get the django admin working end to end. When I setup the app, I placed djangotoolbox before permission_backend_nonrel, as advised in the instructions.
In the admin however, I noticed that the groups were still listed, and clicking auth.users would give 'query not supported'. If I move toolbox to go after permission_backend_nonrel, it all works and behaves as expected. Which leads me to believe django_permission_backend_nonrel is doing something odd with the admin.
Is this a known issue? What are the concerns with placing it before djangotoolbox?
Django Nonrel branch version 1.4 of Django is being used.
Groups from: https://github.com/django-nonrel/django-permission-backend-nonrel
The admin section works fine. I am able to create groups, assign them to users.
Now adding them to the template throws an error.
{% for group in user.groups.all %}
{{group.name}}
{% endfor %}
The error I am getting is:
This query is not supported by the database.
/home/nimoy/Documents/nimoy/nimoy-chat
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7ffb908f71e0>
Traceback (most recent call last):
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 673, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/nimoy/Documents/nimoy/nimoy-chat/django-permission-backend-nonrel/permission_backend_nonrel/models.py", line 7, in <module>
**User = get_user_model()**
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/contrib/auth/__init__.py", line 150, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/apps/registry.py", line 194, in get_model
self.check_models_ready()
File "/home/nimoy/Documents/nimoy/venv/lib/python3.5/site-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
The groups work fine when adding with some permissions assigned. But when I try to view a group i get the usual error:
Request Method: GET
Request URL: http://localhost:8000/admin/auth/group/52c86d12e3fbd04f9a2527d0/
Django Version: 1.6.1
Exception Type: DatabaseError
Exception Value:
This query is not supported by the database.
Exception Location: /Projects/example.com/web/env/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py in check_query, line 456
Python Executable: /Projects/example.com/web/env/bin/python
Python Version: 2.7.5
The query django wants is this:
SELECT auth_permission.id FROM auth_permission INNER JOIN auth_group_permissions ON ( auth_permission.id = auth_group_permissions.permission_id ) WHERE auth_group_permissions.group_id = 52c86d12e3fbd04f9a2527d0 ORDER BY auth_permission.codename ASC LIMIT 21
Need to add this at line 10 of until.py:
obj_list.permission_fk_list.append(obj.id)
Without this, setting up data using calls to add_permission_to_group() don't update the fk list so the permissions don't show in the admin page for Groups and has_perm() calls fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.