{ "info": { "author": "Daniel Czuba", "author_email": "dc@danielczuba.pl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "yaACL\n=====\n\nYet another access control list (ACL) per view for Django\n\n\n## Installation\n* Clone this repo to your PC\n* Run ``pip install yaACL``\n* Put ``yaacl`` in INSTALLED_APPS, after auth and admin apps\n* Put ``import yaacl`` at the end of your current settings file\n* Run ``./manage.py syncdb`` or ``./manage.py migrate``\n\n\n## Configuration\n* This app get information about your auth user model form settings\n (``AUTH_USER_MODEL``)\n* If you also have custom group model, then define it in\n ``settings.ACL_GROUP_USER_MODEL`` (ie: ``cms_user.group``)\n\n\n## Usage\nIn views, import ``acl_register_view`` or ``acl_register_class``, then\ndecorate views you want under control access. After all views are decorated,\nrun command ``./manage.py sync_acl``, so all views will be registered in\ndatabase.\n\n```python\nfrom yaacl.decorators import acl_register_view\nfrom django.contrib.auth.decorators import login_required\n\n\n@login_required\n@acl_register_view('Short description about this view', 'resource_name')\ndef index(request):\n pass\n```\n\nFirst parameter is ``name`` the short name for this view (resource). Second\nparameter is ``resource``, and isn't required. If ``name=None``,\n``resource`` not supplied, the name for resource will be generated by joining\nmodule name and function/class name\n\nIt's up to you how you name those resources, but I recommend (and use in\nproject I made this app) to name them as ``.``, so\nlater in templates you can check if user has access to all resources\nin ``.``\n\nLet's say, you have a typical CRUD view in you news application, so code\nwould be like this:\n\n```python\nfrom yaacl.decorators import acl_register_view\nfrom django.contrib.auth.decorators import login_required\n\n\n#decorationg standard function based views\n@login_required\n@acl_register_view('News list', 'news.create)\ndef index(request):\n ...\n\n@login_required\n@acl_register_view('Update news entry')\ndef update(request):\n ...\n\n@login_required\n@acl_register_view('Delete news entry')\ndef delete(request):\n ...\n\n#decoration class-based views\n@acl_register_class(u\"Create news\")\nclass Create(FormView):\n ...\n\n\n```\n\nSo, your resources list will be like this:\n\n\n* ``news.views.index`` News list\n* ``news.create`` Create new news\n* ``news.views.update`` Update news entry\n* ``news.views.delete`` Delete news entry\n\nNow if you want to check if current user has access to news.index, then in\ntemplates you can check them by using code like:\n\n```html\n{% load acl %}\n\n...\n\n{% if request.user|has_access:'news.index' %}\nYes it has access to news.index view.\n{% else %}\nNo, it has not.\n{% endif %}\n\n```\n\nBut if you want to check if user has access to\n\n\n```html\n{% if request.user|have_access:'news.' %}\nYes it has access to all resources in news.\n{% else %}\nNo, it has not.\n{% endif %}\n\n```\n\n## Signals\nActually there is only one signal, ``yaacl.signals.register_resource``, which\nis called before resource is registered in ``ACL.acl_list``. It's purpose is to\ntransform ``name`` and/or ``resource``. The function should return dict with\nkeys ``name`` and ``resource``.\n\nExample usage is below, where I use it to remove the ``module`` and ``views``\nfrom resource name\n\n```python\nfrom yaacl.signals import register_resource\nfrom django.dispatch import receiver\n\n\n@receiver(register_resource)\ndef transform_resource(sender, resource, name, **kwargs):\n resource_parts = resource.split('.')\n\n if resource_parts and resource_parts[0] == 'module':\n resource_parts.pop(0)\n\n if len(resource_parts) >= 2 and resource_parts[-2] == 'views':\n resource_parts.pop(-2)\n\n resource = '.'.join(resource_parts)\n\n return {'resource': resource, 'name': name}\n```\n\n## Information\n* If flag ``is_superuser`` is ``True``, then always access is granted\n* No-access page template is located in ``yaacl/no_access.html`` file\n* Test in ``has_access`` template tag just check if resource name starts with\n given name\n\n\n## Todo\n* ``.travis.yml``\n* A flag, to indicates a resources that staff members has full access", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Alkemic/yaACL", "keywords": "django,acl,admin", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "yaacl", "package_url": "https://pypi.org/project/yaacl/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/yaacl/", "project_urls": { "Homepage": "https://github.com/Alkemic/yaACL" }, "release_url": "https://pypi.org/project/yaacl/0.8.2/", "requires_dist": null, "requires_python": "", "summary": "Yet another access control list (ACL) per view for Django", "version": "0.8.2" }, "last_serial": 2618728, "releases": { "0.8.1": [ { "comment_text": "", "digests": { "md5": "4c37f4fa9f8d8da023f43e10d40f7c2a", "sha256": "1c013e1d07aafebe7b6bbca6683d22355c74a7890fbf6f4addb64c1d6b5ecbe7" }, "downloads": -1, "filename": "yaacl-0.8.1.tar.gz", "has_sig": false, "md5_digest": "4c37f4fa9f8d8da023f43e10d40f7c2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7835, "upload_time": "2017-02-04T09:39:54", "url": "https://files.pythonhosted.org/packages/19/da/4e62d584aea5498846f9089406e63bdc828b24b3e03978179e890d0924e4/yaacl-0.8.1.tar.gz" } ], "0.8.2": [ { "comment_text": "", "digests": { "md5": "40614b47977484e42a7e7a73c3a9e2de", "sha256": "64a2c42e96985eba4df3a37b384a7e58935c925e5976e31b41415c196c40b9ce" }, "downloads": -1, "filename": "yaacl-0.8.2.tar.gz", "has_sig": false, "md5_digest": "40614b47977484e42a7e7a73c3a9e2de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9453, "upload_time": "2017-02-04T10:07:15", "url": "https://files.pythonhosted.org/packages/c9/5c/e438dd8f7993675a4caf1290c93a81034b24094b01c697343ec5bb100270/yaacl-0.8.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "40614b47977484e42a7e7a73c3a9e2de", "sha256": "64a2c42e96985eba4df3a37b384a7e58935c925e5976e31b41415c196c40b9ce" }, "downloads": -1, "filename": "yaacl-0.8.2.tar.gz", "has_sig": false, "md5_digest": "40614b47977484e42a7e7a73c3a9e2de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9453, "upload_time": "2017-02-04T10:07:15", "url": "https://files.pythonhosted.org/packages/c9/5c/e438dd8f7993675a4caf1290c93a81034b24094b01c697343ec5bb100270/yaacl-0.8.2.tar.gz" } ] }