{ "info": { "author": "Grigoriy Kramarenko", "author_email": "root@rosix.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Natural Language :: Russian", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "DirectApps\n==========\n\nThis is a little application for direct access to all the models and their\ndata in a project. By default, the application has access for users with\n`is_staff` mark. But this and much more can be changed.\n\nIt might interest you if you use Django as the backend to some kind of\nexternal client application. There are no templates for formatting and\ndisplaying of data on the client. Only JSON. Only direct data. All quickly and\nsharply.\n\n.. important::\n The client application must support cookies, parse \"csrftoken\" and send\n it as `X-CSRFToken` header in `POST`, `PUT`, `PATCH` and `DELETE` requests.\n\nInstallation\n------------\n\n.. code-block:: shell\n\n pip install django-directapps\n\nChange your next project files.\n\n.. code-block:: python\n\n # settins.py\n INSTALLED_APPS = (\n ...\n 'directapps',\n ...\n )\n\n # urls.py\n urlpatterns = [\n ...\n url(r'^apps/', include('directapps.urls', namespace=\"directapps\")),\n ...\n ]\n\nStart the development server Django, if it is not running.\n\nNow you can open a browser to this address to see a list of available\napplications and links to data schematics for each.\n\n\nEnjoy!\n\n\nUsing the REST API\n------------------\n\nGeneral information\n~~~~~~~~~~~~~~~~~~~\n\nThe REST API endpoints are built as follows:\n\n.. code-block::\n\n ///[.]//[.]//\n\nYou can perform actions on endpoints by specifying them with an underscore:\n\n.. code-block::\n\n .../[.]/_/\n .../[.]//_/\n\n.. code-block::\n\n .../[.]/_/\n .../[.]//_/\n\nParameters **** and **** is define a database\nconnection by its ID.\n\n.. note::\n The parameter **** is useless when you work with relations,\n but you can it remain for convenience.\n\nFor data sets (**** and ****) apply the following GET-parameters::\n\n 1. 'o' - ordering key (by default is from models definition)\n 2. 'c' - columns key (by default is all from allowed)\n 3. 'l' - limit key (by default is 10)\n 4. 'p' - page key (by default is 1)\n 5. 'q' - search key\n 6. 'f' - foreign key (used in conjunction with the search key, see bellow)\n\nAll these keys can be overridden either together or separately in controller.\nYou can check their names in the full scheme of model.\n\n.. note::\n Unlike many of the application with REST, a description of the data for\n client applications is not transmitted with every call, and exists as a\n separate resource, allowing you to do everything faster. This is a\n characteristic feature of this app and it means that:\n\n 1. The client gets the list of available applications.\n 2. Gets application schema which describes what data can be provided\n and on what resource they are.\n 3. And only then begin to work with the data.\n 4. The client application is responsible for the maintenance of relations\n between data models for fields with external links have the attribute\n \"relation\" that contains the full name of the relation.\n\nLet's analyze it on the example of `django.contrib.auth` application.\n\n\nGetting the scheme of available applications and models\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nShort scheme as list applications with version and checksum:\n\n.. code-block::\n\n GET /apps/\n\nFull scheme as list models in application:\n\n.. code-block::\n\n GET /apps/auth/\n\n.. note::\n In the response the permissions for the superuser are marked with just\n the text \"all\", and for other users there will be a list.\n\n\nCreating the data\n~~~~~~~~~~~~~~~~~\n\nMake groups:\n\n.. code-block::\n\n POST /apps/auth/group/ {'name': 'Administrators'}\n POST /apps/auth/group/_create/ {'name': 'Managers'}\n POST /apps/auth/group/_add/ {'name': 'Operators'}\n\n\nGetting the data\n~~~~~~~~~~~~~~~~\n\nWhen you use several databases, you should use the indication of the database\nfrom which you want to get the object. To do this, use **** and\n**** parameters.\n\nGet the list users:\n\n.. code-block::\n\n GET /apps/auth/user/\n GET /apps/auth/user/?o=-id,username\n GET /apps/auth/user/?o=-id&l=1\n GET /apps/auth/user/?q=blabla\n\n.. code-block::\n\n GET /apps/auth/group/1/user/\n GET /apps/auth/group/1/user/?o=-id,username\n GET /apps/auth/group/1/user/?o=-id&l=1\n GET /apps/auth/group/1/user/?q=blabla\n\nGet the user by ID=1:\n\n.. code-block::\n\n GET /apps/auth/user/1/\n\n.. code-block::\n\n GET /apps/auth/group/1/user/1/\n\nUse *foreign key* for search available groups in ManyToManyField:\n\n.. code-block::\n\n GET /apps/auth/user/_fkey/?f=groups\n GET /apps/auth/user/_fkey/?f=groups&q=rator\n GET /apps/auth/user/_fkey/?f=groups&q=rator&o=-id&l=1\n\nOf course, the *foreign key* you can use with ForeignKey or OneToOneField too:\n\n.. code-block::\n\n GET /apps/auth/permission/_fkey/?f=content_type\n\nModify data:\n\n.. code-block::\n\n PATCH /apps/auth/user/1/ { first_name: 'Johnny' }\n PUT /apps/auth/user/1/ { first_name: 'John' }\n POST /apps/auth/user/1/_patch/ { first_name: 'John Bo' }\n POST /apps/auth/user/1/_put/ { first_name: 'John Bon' }\n POST /apps/auth/user/1/_update/ { last_name: 'Jovi' }\n\nDelete data:\n\n.. code-block::\n\n DELETE /apps/auth/user/1/\n POST /apps/auth/user/1/_delete/\n\n\nUsing in browser\n----------------\n\nYou can look at the example works in the JavaScript console and use it as a test.\n\n.. code-block:: javascript\n\n function getCookie(cname) {\n var name = cname + '=';\n var ca = document.cookie.split(';');\n for (var i = 0; i < ca.length; i++) {\n var c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1);\n if (c.indexOf(name) === 0) return c.substring(name.length, c.length);\n }\n return '';\n }\n\n function makeRequest(method, url, data, content_type) {\n var xhr = new XMLHttpRequest(),\n content_type = content_type || 'application/x-www-form-urlencoded';\n xhr.open(method, url, false);\n if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(method.toUpperCase()))) {\n xhr.setRequestHeader('Content-Type', content_type);\n xhr.setRequestHeader('X-CSRFToken', getCookie('csrftoken'));\n }\n xhr.send(data);\n if (xhr.status === 200) return JSON.parse(xhr.responseText);\n console.error(xhr.responseText);\n }\n\n var group1 = makeRequest('post', '/apps/auth/group/', 'name=Operators 1'),\n group2 = makeRequest('post', '/apps/auth/group/',\n JSON.stringify({ name: 'Operators 2' }),\n 'application/json');\n\n makeRequest('get', '/apps/auth/group/?o=name,-id&q=operators&p=1&l=3&id__gte=1');\n makeRequest('put', '/apps/auth/group/' + group1.pk + '/', 'name=Operators 11');\n makeRequest('patch', '/apps/auth/group/' + group2.pk + '/', 'name=Operators 22');\n makeRequest('get', '/apps/auth/group/?o=name,-id&q=operators&p=1&l=3&id__gte=1');\n makeRequest('delete', '/apps/auth/group/', 'id=' + group1.pk + ',' + group2.pk);\n makeRequest('delete', '/apps/auth/group/',\n JSON.stringify({ id: [ group1.pk, group2.pk ] }),\n 'application/json');\n\n\nSettings\n--------\n\nAll next settings must be within the dictionary `DIRECTAPPS`, when you\ndefine them in the file settings.py\n\nACCESS_FUNCTION\n~~~~~~~~~~~~~~~\nFunction that checks access to resources. You may want to use:\n\n1. `directapps.access.authenticated` - for authenticated users.\n2. `directapps.access.staff` - for employers and superusers.\n3. `directapps.access.superuser` - for superusers only.\n4. `directapps.access.view_users` - for users with view permission for User\n model.\n5. any custom function.\n\nThe default is the internal function `directapps.access.staff`.\n\nATTRIBUTE_NAME\n~~~~~~~~~~~~~~\nThe name of the attribute in the model that is bound to the controller.\nBy default is `directapps_controller`.\n\nCHECKSUM_VERSION\n~~~~~~~~~~~~~~~~\nThe options for the checksum compilation of the scheme.\nBy default is `\"1\"`.\n\nCONTROLLERS\n~~~~~~~~~~~\nDictionary own controllers for models of third-party applications.\nBy default is blank.\n\nEXCLUDE_APPS\n~~~~~~~~~~~~\nThe list of excluded applications.\nBy default is blank.\n\nEXCLUDE_MODELS\n~~~~~~~~~~~~~~\nThe list of excluded models.\nBy default is blank.\n\nJSON_DUMPS_PARAMS\n~~~~~~~~~~~~~~~~~\nThe options for creating JSON.\nBy default is ``{'indent': 2, 'ensure_ascii': False}``.\n\nMASK_PASSWORD_FIELDS\n~~~~~~~~~~~~~~~~~~~~\nThe options for masking all the fields with the name \"password\".\nBy default is `True`.\n\nMASTER_CONTROLLER\n~~~~~~~~~~~~~~~~~\nClass (as string for import) of the master controller, which is used by default.\nBy default is `None` and uses internal class.\n\nUSE_TIME_ISOFORMAT\n~~~~~~~~~~~~~~~~~~\nThe options for the using ISO time with microseconds into `JSONEncoder`.\nBy default is `False` and `JSONEncoder` used ECMA-262 format.\n\nSEARCH_KEY\n~~~~~~~~~~\nThe key by which data is received for search.\nBy default is 'q'.\n\nFOREIGN_KEY\n~~~~~~~~~~~\nThe key by which the name of the field or column with a relation\n(for the \"_fkey\" action) is received from the client.\nBy default is 'f'.\n\nCOLUMNS_KEY\n~~~~~~~~~~~\nThe key by which the list of fields for rendering is received.\nBy default is 'c'.\n\nORDERING_KEY\n~~~~~~~~~~~~\nThe key by which sorting is accepted from the client.\nBy default is 'o'.\n\nLIMIT_KEY\n~~~~~~~~~\nThe key by which the limit of records is accepted from the client.\nBy default is 'l'.\n\nPAGE_KEY\n~~~~~~~~\nThe key by which the client receives the page number.\nBy default is 'p'.\n\nLIMIT\n~~~~~\nThe global working limit of returned records.\nBy default is 10.\n\nMAX_LIMIT\n~~~~~~~~~\nThe global maximum limit of returned records, which does not allow to kill the\nserver with huge data sets.\nBy default is 50.\n\n\nCustomizing of controllers\n--------------------------\n\nTo change the behavior globally for all your controllers, make your main\ncontroller based on the built-in and connect it:\n\n.. code-block:: python\n\n # myapp/controllers.py\n\n import logging\n from directapps import controllers\n\n logger = logging.getLogger(__name__)\n\n\n class CustomModelController(controllers.ModelController):\n # of course, your may be do it in the settings, but just for example :)\n search_key = 'search'\n limit = 50\n max_limit = 1000\n\n\n class CustomObjectController(controllers.ObjectController):\n\n def action_get(self, request, object, *args, **kwargs):\n logger.info(\n '%s open %s with ID=%s', request.user, self, object,\n )\n return super().action_get(request, object, *args, **kwargs)\n\n\n class CustomMasterController(controllers.MasterController):\n\n model_ctrl_class = CustomModelController\n object_ctrl_class = CustomObjectController\n\n\n.. code-block:: python\n\n # settings.py\n\n DIRECTAPPS = {\n 'MASTER_CONTROLLER': 'myapp.controllers.CustomMasterController'\n }\n\n\nTo change the behavior of only one controller, make your own based on the\nbuilt-in and connect it like this:\n\n.. code-block:: python\n\n # myapp/controllers.py\n\n from django.db.models import Count\n from directapps import controllers\n\n\n class UserModelController(controllers.ModelController):\n annotations = (\n # Method or property on instance of model.\n 'get_full_name',\n 'get_short_name',\n # QuerySet annotation.\n 'groups__count',\n )\n\n def get_queryset(self, *args, **kwargs):\n \"\"\"Returns modified QuerySet.\"\"\"\n qs = super().get_queryset(*args, **kwargs)\n qs = qs.annotate(Count('groups'))\n return qs\n\n def info(self, request, qs):\n \"\"\"Returns information about the set. Redefined method.\"\"\"\n all_users = self.get_queryset(request, using=qs.using)\n return {\n 'total': all_users.count()\n }\n\n\n class UserController(controllers.MasterController):\n\n model_ctrl_class = UserModelController\n\n\n.. code-block:: python\n\n # settins.py\n\n DIRECTAPPS = {\n 'CONTROLLERS': {\n 'auth.user': 'myapp.controllers.UserController',\n }\n }\n\n\nContributing\n------------\nIf you want to translate the app into your language or to offer a more\ncompetent application code, you can do so using the \"Pull Requests\" on `gitlab`_.\n\n.. _gitlab: https://gitlab.com/djbaldey/django-directapps/\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/djbaldey/django-directapps/", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "django-directapps", "package_url": "https://pypi.org/project/django-directapps/", "platform": "any", "project_url": "https://pypi.org/project/django-directapps/", "project_urls": { "Homepage": "https://gitlab.com/djbaldey/django-directapps/" }, "release_url": "https://pypi.org/project/django-directapps/0.7/", "requires_dist": null, "requires_python": "", "summary": "Django app for direct client access to all models.", "version": "0.7" }, "last_serial": 5191063, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "94641bbe40c297bc73595d4e0c03b558", "sha256": "55935036c338bd7b18a79383f5e7c775eb3099984a1a61ffdae41b452a174517" }, "downloads": -1, "filename": "django-directapps-0.1.tar.gz", "has_sig": false, "md5_digest": "94641bbe40c297bc73595d4e0c03b558", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30217, "upload_time": "2016-03-20T07:34:58", "url": "https://files.pythonhosted.org/packages/61/24/b01c0798d8f8975e1cf3d5e5e4676e1e85caca0c0214bd8b8ab144c80ece/django-directapps-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a94a9aacda50f0c1580fb7d9c70500f7", "sha256": "f38016b864f8af42f3768bad7336b6a023b9f6d88d5abf4bcd963f29b3f365b6" }, "downloads": -1, "filename": "django-directapps-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a94a9aacda50f0c1580fb7d9c70500f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32105, "upload_time": "2016-03-20T15:35:18", "url": "https://files.pythonhosted.org/packages/cc/6a/70493282274efc13939b4248d5e08270045bae6667037a6cd18ac1a41b03/django-directapps-0.1.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "a5d51a1be2892631312f4de592381d05", "sha256": "5c719f58926f09f367bc5386ba4e3babb86612b9453359a5214763ab34a230b5" }, "downloads": -1, "filename": "django-directapps-0.2.tar.gz", "has_sig": false, "md5_digest": "a5d51a1be2892631312f4de592381d05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33389, "upload_time": "2016-05-27T04:43:25", "url": "https://files.pythonhosted.org/packages/e9/b6/7cbae9d185db32d30f92818a6d23d80f20200ba01f698ce2b579ea65b14d/django-directapps-0.2.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "e417db62b5cb6ae684a39a4f16fd0c47", "sha256": "703d2c40ff1a45fa9b3bcfdc7311867304167dd71c141f2c508cd10eb45babd1" }, "downloads": -1, "filename": "django-directapps-0.5.tar.gz", "has_sig": false, "md5_digest": "e417db62b5cb6ae684a39a4f16fd0c47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37514, "upload_time": "2016-12-17T03:15:26", "url": "https://files.pythonhosted.org/packages/45/de/aee15ac06d198e14e27cf2f1be91d8155dfa6e639e544ea4a602480cffc8/django-directapps-0.5.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "fa417b935d0aa4eb9b9214c8ed4e5ead", "sha256": "f6ef6d6d581b3f4b766e8515f5d4d3a9bd56dbb4fbcb81ac2ca7e7c97da42777" }, "downloads": -1, "filename": "django-directapps-0.5.2.tar.gz", "has_sig": false, "md5_digest": "fa417b935d0aa4eb9b9214c8ed4e5ead", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33947, "upload_time": "2018-01-09T13:33:16", "url": "https://files.pythonhosted.org/packages/df/19/0110de9e57f873d0bd55708e54ff4e646b4a841ce69c65e26693954ee034/django-directapps-0.5.2.tar.gz" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "b9db70598fc63bae89c1409707875401", "sha256": "dd21f22ef290e3cc395934273490924cf344a20d5dc4e19ddb28ae95a1389dc2" }, "downloads": -1, "filename": "django-directapps-0.5.3.tar.gz", "has_sig": false, "md5_digest": "b9db70598fc63bae89c1409707875401", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34519, "upload_time": "2018-05-17T12:44:34", "url": "https://files.pythonhosted.org/packages/ac/a6/2a6f86d490020cf7a55a644687d1078d3c2affebe6985afd59307b7b1dbb/django-directapps-0.5.3.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "e15e217dd51f4c9e3749c995feaf4426", "sha256": "7ce1a7e640d4d0e3ea032c860e5c754476afd95d3b583353688f63c29449a596" }, "downloads": -1, "filename": "django-directapps-0.6.1.tar.gz", "has_sig": false, "md5_digest": "e15e217dd51f4c9e3749c995feaf4426", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34886, "upload_time": "2019-04-08T08:12:39", "url": "https://files.pythonhosted.org/packages/40/f8/cf8c3f0bfa282b545692103214c0ec6b6282fbc0d235116c7b64631fa6f1/django-directapps-0.6.1.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "1316d0fdda53e824649584d9b95cfbd0", "sha256": "6dc61e633cc90c75e17f6e93ef5021a0d9b454c79ac303ceb0cabed82ece1e50" }, "downloads": -1, "filename": "django-directapps-0.7.tar.gz", "has_sig": false, "md5_digest": "1316d0fdda53e824649584d9b95cfbd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24507, "upload_time": "2019-04-26T05:23:08", "url": "https://files.pythonhosted.org/packages/5b/43/b9f24eaaa87938aa1ee9b2396886587612fd5398a0d96c1d869330e00c05/django-directapps-0.7.tar.gz" } ], "0.7b0": [ { "comment_text": "", "digests": { "md5": "d82dd5493e0c7d94288ca26589d6dd2c", "sha256": "1d0eb6acabea9d58b30aca21605c7e238ac30281376dd9dbacb4975a059c8ceb" }, "downloads": -1, "filename": "django-directapps-0.7b0.tar.gz", "has_sig": false, "md5_digest": "d82dd5493e0c7d94288ca26589d6dd2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23626, "upload_time": "2019-04-08T08:18:33", "url": "https://files.pythonhosted.org/packages/93/d0/0368db9e1ab8cefe116bfae08a9123a126c121fcf6488ee0e72d369d19da/django-directapps-0.7b0.tar.gz" } ], "0.7rc1": [ { "comment_text": "", "digests": { "md5": "da8abc32d6fb5d40a31bc54f15774650", "sha256": "3eb140dfb4fb73353535b26c780471d569f4d45a009ac78a4a07ce37bd4ae478" }, "downloads": -1, "filename": "django_directapps-0.7rc1-py3-none-any.whl", "has_sig": false, "md5_digest": "da8abc32d6fb5d40a31bc54f15774650", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 32181, "upload_time": "2019-04-21T06:36:24", "url": "https://files.pythonhosted.org/packages/f0/04/8df4fb18ae44b2b7578dbf61c436cc67f5311f09adc654bde11d4a6df947/django_directapps-0.7rc1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1316d0fdda53e824649584d9b95cfbd0", "sha256": "6dc61e633cc90c75e17f6e93ef5021a0d9b454c79ac303ceb0cabed82ece1e50" }, "downloads": -1, "filename": "django-directapps-0.7.tar.gz", "has_sig": false, "md5_digest": "1316d0fdda53e824649584d9b95cfbd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24507, "upload_time": "2019-04-26T05:23:08", "url": "https://files.pythonhosted.org/packages/5b/43/b9f24eaaa87938aa1ee9b2396886587612fd5398a0d96c1d869330e00c05/django-directapps-0.7.tar.gz" } ] }