{ "info": { "author": "David Wolever", "author_email": "david@wolever.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "django-switchuser\n=================\n\n``django-switchuser`` makes it easy for an administrator to switch to\ntemporarily switch to another account by visiting ``/su``.\n\n\nAssumptions\n-----------\n\nBecause ``django-switchuser`` was a quick project, it does make one assumption:\n\n* If a user is not allowed to su, then they will get an HTTP 404 if they try\n to visit ``/su/`` or do anything su-related.\n\n* Any superuser is allowed to switch to any other user. *If this assumption does\n not hold*: you'll need to submit a pull request (hint: take a look at\n ``django_switchuser/state.py``)... Sorry :(\n\nCompatibility\n-------------\n\nTested with Django 1.8 through 1.10, should work with earlier Django versions too.\n\nInstallation\n------------\n\n1. ``pip install django-switchuser``\n2. Add a few things to ``settings.py`` (note: the ``SuStateMiddleware`` should\n be the *very first* class in the list; this guarantees that\n ``request.su_state`` will always be available)::\n\n INSTALLED_APPS = (\n ...\n \"django_switchuser\",\n ...\n )\n\n MIDDLEWARE_CLASSES = (\n \"django_switchuser.middleware.SuStateMiddleware\",\n ...\n )\n\n TEMPLATE_CONTEXT_PROCESSORS = (\n ...\n \"django_switchuser.context_processors.su_state\",\n ...\n )\n\n3. Add an entry to ``urls.py`` (note: you can use whatever URL you'd like;\n ``su/`` is simply convenient)::\n\n urlpatterns += patterns(\"\",\n ...\n url(r\"^su/\", include(\"django_switchuser.urls\")),\n ...\n )\n\n4. Start the server and check that everything is working by visiting\n http://localhost:8000/su/ *Note*: an HTTP 404 will be returned if the\n currently logged in user isn't allowed to su (by default, only\n administrators are allowed to su).\n\n5. (Optional) Add an entry to your ``base.html`` template which will show a\n convenient logout button::\n\n \n ...\n \n ...\n {% include \"su/statusbar.html\" %}\n \n \n\n6. (Optional) Override ``SuState`` so it better suits your application. For\n example, to include fields from a user's profile, you subclass ``SuState``\n like this (see below for more detailed documentation)::\n\n from django.contrib.auth.models import User\n from django_switchuser.state import SuState as DefaultSuState\n\n class SuState(DefaultSuState):\n def available_users(self):\n return User.objects.all()\\\n .select_related(\"profile\")\\\n .order_by(\"profile__client_id\")\n\n def user_long_label(self, user):\n return \"%s (%s)\" %(user.get_profile().client_id, user.username)\n\n def user_short_label(self, user):\n return \"%s\" %(user.get_profile().client_id, )\n\n And then add to your ``settings.py`` file::\n\n SU_STATE_CLASS = 'myapp.su.SuState'\n\n\nDoing Your Own Thing\n====================\n\nDoing your own thing is easy. The ``SuStateMiddleware`` and ``su_state``\ncontext processors add a ``su_state`` attribute to the ``request`` and a\n``su_state`` variable to the template rendering context. ``su_state`` is an\ninstance of ``django_switchuser.state.SuState``, and has the following\nattributes:\n\n ``SuState.is_active()``:\n Returns ``True`` if the current user has been switched.\n\n ``SuState.auth_user``:\n The original user associated with the request. For example, if the user\n ``admin`` has switched to ``jane``, then ``su_state.auth_user`` will be\n ``admin``.\n\n ``SuState.active_user``:\n The user which has been switched to, or ``None`` if no user has been\n switched. For example, if the user ``admin`` has switched to ``jane``,\n then ``su_state.active_user`` will be ``admin``.\n\n ``SuState.can_su()``:\n Returns ``True`` if the current user is allowed to switch.\n\n ``SuState.available_users()``:\n Returns a ``QuerySet`` of ``User`` of the users which the current user\n is allowed to switch to. It may be useful to override this method to\n ``select_related()`` on the user's profile::\n \n def available_users(self):\n return User.objects.all()\\\n .select_related(\"profile\")\\\n .order_by(\"profile__client_id\")\n\n ``SuState.user_long_label(user)``:\n Returns the \"long\" label for the user, used in the list of users. It\n may be useful to override this method so that it includes information\n specific to your application::\n\n def user_long_label(self, user):\n return \"%s (%s)\" %(user.get_profile().client_id, user.username)\n\n ``SuState.user_short_label(user)``:\n Returns the \"short\" label for the user, used in the status bar and\n other places. It may be useful to override this method so that it\n includes information specific to your application::\n\n def user_short_label(self, user):\n return \"%s\" %(user.get_profile().client_id, )\n\n ``SuState.set_su_user_id(su_user_id)``:\n Switches to the user with id ``su_user_id`` if they are included in\n ``SuState.available_users()``.\n\n ``SuState.set_su_user(su_user)``:\n Switches to User ``su_user``. No permissions checks are performed.\n\n ``SuState.clear_su()``:\n Reverts back to the original user.\n\nFor example, if you don't like the default switch user bar, you could add your\nown to your ``base.html``::\n\n {% load switchuser %}\n {% load url from future %}\n\n {% if su_state.is_active %}\n deactive {% su_user_short_label su.active_user %}\n {% elif su_state.can_su %}\n switch user\n {% endif %}\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/wolever/django-switchuser", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-switchuser", "package_url": "https://pypi.org/project/django-switchuser/", "platform": "", "project_url": "https://pypi.org/project/django-switchuser/", "project_urls": { "Homepage": "https://github.com/wolever/django-switchuser" }, "release_url": "https://pypi.org/project/django-switchuser/0.6.1/", "requires_dist": null, "requires_python": "", "summary": "", "version": "0.6.1" }, "last_serial": 3129365, "releases": { "0.0.1-alpha": [ { "comment_text": "", "digests": { "md5": "366b806f23108e7850f5bb38c1206e49", "sha256": "43e0da64ec11c7f5485cc5171071c182994f07108667be3e7958e6422f04fa75" }, "downloads": -1, "filename": "django-switchuser-0.0.1-alpha.tar.gz", "has_sig": false, "md5_digest": "366b806f23108e7850f5bb38c1206e49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2142, "upload_time": "2013-01-09T22:07:34", "url": "https://files.pythonhosted.org/packages/27/8b/81dbc3c0501acee321e8425733ad5ff5a2c1804c99346fa627fea4ab2c58/django-switchuser-0.0.1-alpha.tar.gz" } ], "0.0.2-alpha": [ { "comment_text": "", "digests": { "md5": "89913a60f8aa4d185eb28f0084ee85ee", "sha256": "fe306aa132779b8e51e2baee26d7e21784ab7578419c9f08375ad2197ff89f20" }, "downloads": -1, "filename": "django-switchuser-0.0.2-alpha.tar.gz", "has_sig": false, "md5_digest": "89913a60f8aa4d185eb28f0084ee85ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5286, "upload_time": "2013-01-09T22:16:59", "url": "https://files.pythonhosted.org/packages/41/ea/541d91f67de9ea75122e3cfb7eb2581776d0c9dc5c3194885136e1ae29c2/django-switchuser-0.0.2-alpha.tar.gz" } ], "0.0.4-alpha": [ { "comment_text": "", "digests": { "md5": "bdd86d24b30bfe7348778a0007ea42b5", "sha256": "a342314982272de7899891f8a1f92ba01f1afd90d65ca7f4f157d07f2215aea4" }, "downloads": -1, "filename": "django-switchuser-0.0.4-alpha.tar.gz", "has_sig": false, "md5_digest": "bdd86d24b30bfe7348778a0007ea42b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5417, "upload_time": "2013-01-10T17:33:05", "url": "https://files.pythonhosted.org/packages/3a/1b/12e806cd9d3da30b83dbe64d45638619f9b825dc5733d428ff8bff36b5cf/django-switchuser-0.0.4-alpha.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "f6daf679aa7c135c37614b0a34fdd378", "sha256": "416965223e1db9d3b6bbc2fa6a8680cb30418bc3ca32b865f9962c6d49d663fc" }, "downloads": -1, "filename": "django-switchuser-0.0.5.tar.gz", "has_sig": false, "md5_digest": "f6daf679aa7c135c37614b0a34fdd378", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5643, "upload_time": "2013-06-23T16:11:55", "url": "https://files.pythonhosted.org/packages/8e/6d/a55eeaeb289dab58bffbff4a55327fe2bdc84f581c5e0872a3d981119b08/django-switchuser-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "39a887073f21216e09db1c7c78f3afa2", "sha256": "04e0f5aeedc45f150292ffd75c040c644b07f4901ae2438d8a2cf054734afbce" }, "downloads": -1, "filename": "django-switchuser-0.0.6.tar.gz", "has_sig": false, "md5_digest": "39a887073f21216e09db1c7c78f3afa2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5658, "upload_time": "2013-06-23T17:45:22", "url": "https://files.pythonhosted.org/packages/26/6d/4fd4143f49f24bf39b58515e044355c8c051614a44960d10fa9ded63e93f/django-switchuser-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "05b06e3d49fd5e6464c92a83ea2a65ad", "sha256": "b996dbac8ef931f48a2ba822a70ccb978fe12de8e56647c69ad46497c98fd9e0" }, "downloads": -1, "filename": "django-switchuser-0.0.7.tar.gz", "has_sig": false, "md5_digest": "05b06e3d49fd5e6464c92a83ea2a65ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5891, "upload_time": "2013-06-23T20:03:50", "url": "https://files.pythonhosted.org/packages/6c/ce/550356f3e8c507869e1d96c71eb6ba30f02b6f1014e22b6a63227731f927/django-switchuser-0.0.7.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "17ae806138846a9cbc6facfd4be9cd22", "sha256": "48088c3c6619602a84412daf38caad626a86d90a5cfef257e56130c4d6f17db2" }, "downloads": -1, "filename": "django-switchuser-0.1.0.tar.gz", "has_sig": false, "md5_digest": "17ae806138846a9cbc6facfd4be9cd22", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6698, "upload_time": "2013-09-13T23:56:28", "url": "https://files.pythonhosted.org/packages/57/27/9b63db125b40a686b82e1e2f4462afe08072e7c9b999ba4ec40790d06e82/django-switchuser-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "90e2efee3bac274c6679d390f8989ffa", "sha256": "a3d14f458b5beebc3d1c32bebd85ec4af63a2c40e75b82b58e168c2967e08cbe" }, "downloads": -1, "filename": "django-switchuser-0.1.1.tar.gz", "has_sig": false, "md5_digest": "90e2efee3bac274c6679d390f8989ffa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7308, "upload_time": "2013-10-09T21:57:48", "url": "https://files.pythonhosted.org/packages/03/4e/2b425329a4864e48b9bc32f779522bf2676ca9860c65705e81d45299ac88/django-switchuser-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "aafda0758555f6115fedf7ad1706cb76", "sha256": "bc0340a665165b0c60913a9d825bbb38396a1f5935ece391b6ac0143323ac814" }, "downloads": -1, "filename": "django-switchuser-0.2.0.tar.gz", "has_sig": false, "md5_digest": "aafda0758555f6115fedf7ad1706cb76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7329, "upload_time": "2013-12-07T23:31:54", "url": "https://files.pythonhosted.org/packages/e4/44/e8b9f921d3a40854c76a7db6f7989528d89959f91b0e6ecf5c4b5a0e9296/django-switchuser-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "6a8e03cf0776bfcb1c7f0043f64f6ff5", "sha256": "d5275ac9dc5ba14e9497dfc2870a1fee6818adde4fdf4a3980dc23f39e895e99" }, "downloads": -1, "filename": "django-switchuser-0.3.0.tar.gz", "has_sig": false, "md5_digest": "6a8e03cf0776bfcb1c7f0043f64f6ff5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7514, "upload_time": "2014-03-26T19:40:10", "url": "https://files.pythonhosted.org/packages/a6/b8/a8eaa77e5a34c6c269693d0d41ccc8aa4fab8f64b43efc263970d8c5eb53/django-switchuser-0.3.0.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "28cd08f432623ee78380d6e101e0c18a", "sha256": "e3f790e0e8eb5ffcfe8f5752414fb31145eb555573000c489a0c638783d77915" }, "downloads": -1, "filename": "django_switchuser-0.3.2-py2-none-any.whl", "has_sig": false, "md5_digest": "28cd08f432623ee78380d6e101e0c18a", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12227, "upload_time": "2015-02-20T19:19:14", "url": "https://files.pythonhosted.org/packages/f8/aa/0927f2f845236104e01d852dbf76e25f185a04cfda0eab3c5597b9f4ce24/django_switchuser-0.3.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6fc30652dedcead1295a2f5d8115ce4", "sha256": "9b165be517271b3ebcf856183a75f100c3b81ef10c2767646a50a2bf46dad7ff" }, "downloads": -1, "filename": "django-switchuser-0.3.2.tar.gz", "has_sig": false, "md5_digest": "b6fc30652dedcead1295a2f5d8115ce4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7645, "upload_time": "2015-02-20T19:19:12", "url": "https://files.pythonhosted.org/packages/2f/29/3d36db75a3856400f7b2a5d19d1dba88c2c23205e3eb3b158c2701635fa9/django-switchuser-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "b8ddbe0b9f01f31a4d23389d7e73a0af", "sha256": "73a55c6a93b6e09b9cb99dfbdeeabd9bfb926d44df5be5589b65aa293dbccec1" }, "downloads": -1, "filename": "django_switchuser-0.3.3-py2-none-any.whl", "has_sig": false, "md5_digest": "b8ddbe0b9f01f31a4d23389d7e73a0af", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12230, "upload_time": "2015-02-20T19:35:46", "url": "https://files.pythonhosted.org/packages/0b/e5/a6223c87797f41c050dff3d80e6f2feb0d02135ec3cd11f557863bf621c1/django_switchuser-0.3.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b85e94d66fa04195aa959a85669da12", "sha256": "9d6b267ef7fa74299e8ba89d7456b5e8a75617b125ff5adffb8a180e87d46cc7" }, "downloads": -1, "filename": "django-switchuser-0.3.3.tar.gz", "has_sig": false, "md5_digest": "1b85e94d66fa04195aa959a85669da12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7637, "upload_time": "2015-02-20T19:35:44", "url": "https://files.pythonhosted.org/packages/a8/4a/56eb314e60e2d397c10628808470984aa12fa7962e64e23f10fba227e4c6/django-switchuser-0.3.3.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "67cca3a7f060115bf791ef5c1ccbb9e6", "sha256": "13b29a4df249b0993a631f1e60bef8ac157d67e050ba593ed1ee2ba6e7e67b5f" }, "downloads": -1, "filename": "django_switchuser-0.4.0-py2-none-any.whl", "has_sig": false, "md5_digest": "67cca3a7f060115bf791ef5c1ccbb9e6", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12209, "upload_time": "2015-05-27T19:12:03", "url": "https://files.pythonhosted.org/packages/b3/4d/9adcac6dea970f387c982da5ef8dfd99ab3e61e80b0d03e2097945ae3fd6/django_switchuser-0.4.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "41ceb1bc0e2c14a3b34c6c1d5530cc29", "sha256": "ffb21969081709096957b7613dbb8bc6bbef55e60013f25349022e57d4d1edf7" }, "downloads": -1, "filename": "django-switchuser-0.4.0.tar.gz", "has_sig": false, "md5_digest": "41ceb1bc0e2c14a3b34c6c1d5530cc29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 745, "upload_time": "2015-05-27T19:04:14", "url": "https://files.pythonhosted.org/packages/8e/88/6689efd350d9e03beb6f08676d38e996a3f7d94686183208da194c52c55c/django-switchuser-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "8afc87683ab01d1b2501b9c09c1c7d4d", "sha256": "024279777a3a620e570959eefb0b93e7e3861fea14a766319a71350e9a9acff9" }, "downloads": -1, "filename": "django_switchuser-0.4.1-py2-none-any.whl", "has_sig": false, "md5_digest": "8afc87683ab01d1b2501b9c09c1c7d4d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12233, "upload_time": "2016-05-03T16:11:33", "url": "https://files.pythonhosted.org/packages/2f/75/fc0748e0bbfd7a9ea94ad373181b5f1448ce487453b3fbbd8619a6339864/django_switchuser-0.4.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7bc8dca1e7c08d3f37af905bfacc5b8", "sha256": "51ea7a4fdb0925d8beb3a2f8b273dfed7b0acc327c422e153a7696a99d4ef8b7" }, "downloads": -1, "filename": "django-switchuser-0.4.1.tar.gz", "has_sig": false, "md5_digest": "a7bc8dca1e7c08d3f37af905bfacc5b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7575, "upload_time": "2016-05-03T16:11:21", "url": "https://files.pythonhosted.org/packages/7e/2f/3708bc29d276bf7380e0c485eb96ed9a35d8e6b8674e4f559136dbe2d4ec/django-switchuser-0.4.1.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "ff0e4f859e5f038f46586c0f8bd5c2d2", "sha256": "acfc8446dde2c0810cbce916e65081dc53a07393dcc1e6978ace87a92ef6f386" }, "downloads": -1, "filename": "django_switchuser-0.6.0-py2-none-any.whl", "has_sig": false, "md5_digest": "ff0e4f859e5f038f46586c0f8bd5c2d2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12906, "upload_time": "2017-08-26T20:37:14", "url": "https://files.pythonhosted.org/packages/ac/cc/824ffaf75fb18874aab5faea3dcc4c19061bb84ec27b4e7cf5535a5a8dc0/django_switchuser-0.6.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "65072d23af4ec02f7bc0ab1887c7b0b0", "sha256": "5fd3010d9938db4d4358a9853029ae27ab6c3a3b539556245549336151639b84" }, "downloads": -1, "filename": "django-switchuser-0.6.0.tar.gz", "has_sig": false, "md5_digest": "65072d23af4ec02f7bc0ab1887c7b0b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7990, "upload_time": "2017-08-26T20:37:12", "url": "https://files.pythonhosted.org/packages/25/3b/f8ed72f0159b5a16b0fdbda3a3ca785d32eb8a6389b72c3e35e43a8afc71/django-switchuser-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "87f04d9f502c6d12943b3e238c56cae2", "sha256": "d327686e5ebf3211178e3a902735768c5f8bdcce8f5e5df170682342f43deb05" }, "downloads": -1, "filename": "django_switchuser-0.6.1-py2-none-any.whl", "has_sig": false, "md5_digest": "87f04d9f502c6d12943b3e238c56cae2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12915, "upload_time": "2017-08-28T15:50:25", "url": "https://files.pythonhosted.org/packages/9c/40/9170120f913d4f9bb2dc86cb4106ce9eb2f26655fae20b278e831f337134/django_switchuser-0.6.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a87d3ce0e588ed4718c44c3a0dd6c5ce", "sha256": "3094095e05ccf2a1d7944e5bf17e13b8ca40a929c098dd8278d0d5ffaa45b81e" }, "downloads": -1, "filename": "django-switchuser-0.6.1.tar.gz", "has_sig": false, "md5_digest": "a87d3ce0e588ed4718c44c3a0dd6c5ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8003, "upload_time": "2017-08-28T15:50:23", "url": "https://files.pythonhosted.org/packages/70/5e/6e1ff17f04e3fa962a818ae6ff0ab44e22bb4507be922363e683c9fa1194/django-switchuser-0.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87f04d9f502c6d12943b3e238c56cae2", "sha256": "d327686e5ebf3211178e3a902735768c5f8bdcce8f5e5df170682342f43deb05" }, "downloads": -1, "filename": "django_switchuser-0.6.1-py2-none-any.whl", "has_sig": false, "md5_digest": "87f04d9f502c6d12943b3e238c56cae2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12915, "upload_time": "2017-08-28T15:50:25", "url": "https://files.pythonhosted.org/packages/9c/40/9170120f913d4f9bb2dc86cb4106ce9eb2f26655fae20b278e831f337134/django_switchuser-0.6.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a87d3ce0e588ed4718c44c3a0dd6c5ce", "sha256": "3094095e05ccf2a1d7944e5bf17e13b8ca40a929c098dd8278d0d5ffaa45b81e" }, "downloads": -1, "filename": "django-switchuser-0.6.1.tar.gz", "has_sig": false, "md5_digest": "a87d3ce0e588ed4718c44c3a0dd6c5ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8003, "upload_time": "2017-08-28T15:50:23", "url": "https://files.pythonhosted.org/packages/70/5e/6e1ff17f04e3fa962a818ae6ff0ab44e22bb4507be922363e683c9fa1194/django-switchuser-0.6.1.tar.gz" } ] }