| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: django-organizations |
| 3 |
Version: 2.3.1 |
| 4 |
Summary: Group accounts for Django |
| 5 |
Home-page: https://github.com/bennylope/django-organizations/ |
| 6 |
Author: Ben Lopatin |
| 7 |
Author-email: [email protected] |
| 8 |
License: BSD License |
| 9 |
Platform: OS Independent |
| 10 |
Classifier: Framework :: Django |
| 11 |
Classifier: Environment :: Web Environment |
| 12 |
Classifier: Intended Audience :: Developers |
| 13 |
Classifier: License :: OSI Approved :: BSD License |
| 14 |
Classifier: Operating System :: OS Independent |
| 15 |
Classifier: Programming Language :: Python |
| 16 |
Classifier: Programming Language :: Python :: 3.8 |
| 17 |
Classifier: Programming Language :: Python :: 3.9 |
| 18 |
Classifier: Programming Language :: Python :: 3.10 |
| 19 |
Classifier: Programming Language :: Python :: 3.11 |
| 20 |
Classifier: Programming Language :: Python :: Implementation :: CPython |
| 21 |
Classifier: Development Status :: 5 - Production/Stable |
| 22 |
Requires-Python: >=3.8 |
| 23 |
License-File: LICENSE |
| 24 |
License-File: AUTHORS.rst |
| 25 |
Requires-Dist: Django>=3.2.0 |
| 26 |
Requires-Dist: django-extensions>=2.0.8 |
| 27 |
|
| 28 |
==================== |
| 29 |
django-organizations |
| 30 |
==================== |
| 31 |
|
| 32 |
.. start-table |
| 33 |
|
| 34 |
.. list-table:: |
| 35 |
:stub-columns: 1 |
| 36 |
|
| 37 |
* - Summary |
| 38 |
- Groups and multi-user account management |
| 39 |
* - Author |
| 40 |
- Ben Lopatin (http://benlopatin.com) |
| 41 |
* - Status |
| 42 |
- |docs| |version| |wheel| |supported-versions| |supported-implementations| |
| 43 |
|
| 44 |
.. |docs| image:: https://readthedocs.org/projects/django-organizations/badge/?style=flat |
| 45 |
:target: https://readthedocs.org/projects/django-organizations |
| 46 |
:alt: Documentation Status |
| 47 |
|
| 48 |
.. |version| image:: https://img.shields.io/pypi/v/django-organizations.svg?style=flat |
| 49 |
:alt: PyPI Package latest release |
| 50 |
:target: https://pypi.python.org/pypi/django-organizations |
| 51 |
|
| 52 |
.. |wheel| image:: https://img.shields.io/pypi/wheel/django-organizations.svg?style=flat |
| 53 |
:alt: PyPI Wheel |
| 54 |
:target: https://pypi.python.org/pypi/django-organizations |
| 55 |
|
| 56 |
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/django-organizations.svg?style=flat |
| 57 |
:alt: Supported versions |
| 58 |
:target: https://pypi.python.org/pypi/django-organizations |
| 59 |
|
| 60 |
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/django-organizations.svg?style=flat |
| 61 |
:alt: Supported implementations |
| 62 |
:target: https://pypi.python.org/pypi/django-organizations |
| 63 |
|
| 64 |
|
| 65 |
.. end-table |
| 66 |
|
| 67 |
|
| 68 |
Separate individual user identity from accounts and subscriptions. Django |
| 69 |
Organizations adds user-managed, multi-user groups to your Django project. Use |
| 70 |
Django Organizations whether your site needs organizations that function like |
| 71 |
social groups or multi-user account objects to provide account and subscription |
| 72 |
functionality beyond the individual user. |
| 73 |
|
| 74 |
* Works with your existing user model, whether |
| 75 |
`django.contrib.auth` or a custom model. No additional user |
| 76 |
or authentication functionality required. |
| 77 |
* Users can be belong to and own more than one organization (account, group) |
| 78 |
* Invitation and registration functionality works out of the box for many |
| 79 |
situations and can be extended as need to fit specific requirements. |
| 80 |
* Start with the base models or use your own for greater customization. |
| 81 |
|
| 82 |
Documentation is on `Read the Docs |
| 83 |
<http://django-organizations.readthedocs.org/en/latest/index.html>`_ |
| 84 |
|
| 85 |
|
| 86 |
Development & Contributing |
| 87 |
========================== |
| 88 |
|
| 89 |
**The master branch represents version 2 development. For updates related to 1.x |
| 90 |
versions of django-organizations pull requests should be made against the |
| 91 |
[`version-1.x` branch](tree/version-1.x).** |
| 92 |
|
| 93 |
Development is on-going. To-do items have been moved to the wiki for the time |
| 94 |
being. |
| 95 |
|
| 96 |
The basic functionality should not need much extending. Current dev priorities |
| 97 |
for me and contributors should include: |
| 98 |
|
| 99 |
* Improving the tests and test coverage (ideally moving them back out of the |
| 100 |
main module and executable using the setup.py file) |
| 101 |
* Improving the backends and backends concept so that additional invitation and |
| 102 |
registration backends can be used |
| 103 |
* Documentation |
| 104 |
* Ensuring all application text is translatable |
| 105 |
|
| 106 |
Please use the project's issues tracker to report bugs, doc updates, or other |
| 107 |
requests/suggestions. |
| 108 |
|
| 109 |
Targets & testing |
| 110 |
----------------- |
| 111 |
|
| 112 |
The codebase is targeted and tested against: |
| 113 |
|
| 114 |
* Django 3.2.x against Python 3.8, 3.9, 3.10 |
| 115 |
* Django 4.1.x against Python 3.8, 3.9, 3.10, 3.11 |
| 116 |
* Django 4.2.x against Python 3.8, 3.9, 3.10, 3.11 |
| 117 |
|
| 118 |
To run the tests against all target environments, install `tox |
| 119 |
<https://testrun.org/tox/latest/>`_ and then execute the command:: |
| 120 |
|
| 121 |
tox |
| 122 |
|
| 123 |
Fast testing |
| 124 |
------------ |
| 125 |
|
| 126 |
Testing each change on all the environments takes some time, you may |
| 127 |
want to test faster and avoid slowing down development by using pytest |
| 128 |
against your current environment:: |
| 129 |
|
| 130 |
pip install -r requirements-test.txt |
| 131 |
py.test |
| 132 |
|
| 133 |
Supply the ``-x`` option for **failfast** mode:: |
| 134 |
|
| 135 |
py.test -x |
| 136 |
|
| 137 |
Submitting |
| 138 |
---------- |
| 139 |
|
| 140 |
These submission guidelines will make it more likely your submissions will be |
| 141 |
reviewed and make it into the project: |
| 142 |
|
| 143 |
* Ensure they match the project goals and are sufficiently generalized |
| 144 |
* Please try to follow `Django coding style |
| 145 |
<https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/>`_. |
| 146 |
The code base style isn't all up to par, but I'd like it to move in that |
| 147 |
direction |
| 148 |
* Also please try to include `good commit log messages |
| 149 |
<http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_. |
| 150 |
* Pull requests should include an amount of code and commits that are |
| 151 |
reasonable to review, are **logically grouped**, and based off clean feature |
| 152 |
branches. |
| 153 |
|
| 154 |
Code contributions are expected to pass in all target environments, and |
| 155 |
pull requests should be made from branches with passing builds on `GitHub Actions <https://github.com/bennylope/django-organizations/actions/workflows/test.yml>`_. |
| 156 |
|
| 157 |
Project goals |
| 158 |
------------- |
| 159 |
|
| 160 |
django-organizations should be backend agnostic: |
| 161 |
|
| 162 |
1. Authentication agnostic |
| 163 |
2. Registration agnostic |
| 164 |
3. Invitation agnostic |
| 165 |
4. User messaging agnostic |
| 166 |
|
| 167 |
Etc. |
| 168 |
|
| 169 |
Installing |
| 170 |
========== |
| 171 |
|
| 172 |
First add the application to your Python path. The easiest way is to use |
| 173 |
`pip`:: |
| 174 |
|
| 175 |
pip install django-organizations |
| 176 |
|
| 177 |
Check the `Release History tab <https://pypi.org/project/django-organizations/#history>`_ on |
| 178 |
the PyPI package page for pre-release versions. These can be downloaded by specifying the version. |
| 179 |
|
| 180 |
You can also install by downloading the source and running:: |
| 181 |
|
| 182 |
$ python setup.py install |
| 183 |
|
| 184 |
By default you will need to install `django-extensions` or comparable libraries |
| 185 |
if you plan on adding Django Organizations as an installed app to your Django |
| 186 |
project. See below on configuring. |
| 187 |
|
| 188 |
Configuring |
| 189 |
----------- |
| 190 |
|
| 191 |
Make sure you have `django.contrib.auth` installed, and add the `organizations` |
| 192 |
application to your `INSTALLED_APPS` list: |
| 193 |
|
| 194 |
.. code-block:: python |
| 195 |
|
| 196 |
INSTALLED_APPS = ( |
| 197 |
... |
| 198 |
'django.contrib.auth', |
| 199 |
'organizations', |
| 200 |
) |
| 201 |
|
| 202 |
Then ensure that your project URL conf is updated. You should hook in the |
| 203 |
main application URL conf as well as your chosen invitation backend URLs: |
| 204 |
|
| 205 |
.. code-block:: python |
| 206 |
|
| 207 |
from organizations.backends import invitation_backend |
| 208 |
|
| 209 |
urlpatterns = [ |
| 210 |
... |
| 211 |
url(r'^accounts/', include('organizations.urls')), |
| 212 |
url(r'^invitations/', include(invitation_backend().get_urls())), |
| 213 |
] |
| 214 |
|
| 215 |
Auto slug field |
| 216 |
~~~~~~~~~~~~~~~ |
| 217 |
|
| 218 |
The standard way of using Django Organizations is to use it as an installed app |
| 219 |
in your Django project. Django Organizations will need to use an auto slug |
| 220 |
field which are not included. By default it will try to import these from |
| 221 |
django-extensions, but you can configure your own in settings. The default: |
| 222 |
|
| 223 |
.. code-block:: python |
| 224 |
|
| 225 |
ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField' |
| 226 |
|
| 227 |
Alternative: |
| 228 |
|
| 229 |
.. code-block:: python |
| 230 |
|
| 231 |
ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField' |
| 232 |
|
| 233 |
Previous versions allowed you to specify an `ORGS_TIMESTAMPED_MODEL` path. This |
| 234 |
is now ignored and the functionality satisfied by a vendored solution. A |
| 235 |
warning will be given but this *should not* have any effect on your code. |
| 236 |
|
| 237 |
- `django-extensions <http://django-extensions.readthedocs.org/en/latest/>`_ |
| 238 |
- `Django AutoSlug <https://github.com/justinmayer/django-autoslug/>`_ |
| 239 |
- `django-slugger <https://gitlab.com/dspechnikov/django-slugger/>`_ |
| 240 |
|
| 241 |
Registration & invitation backends |
| 242 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 243 |
|
| 244 |
You can specify a different invitation backend in your project settings, and |
| 245 |
the `invitation_backend` function will provide the URLs defined by that |
| 246 |
backend: |
| 247 |
|
| 248 |
.. code-block:: python |
| 249 |
|
| 250 |
INVITATION_BACKEND = 'myapp.backends.MyInvitationBackend' |
| 251 |
|
| 252 |
|
| 253 |
Usage Overview |
| 254 |
============== |
| 255 |
|
| 256 |
For most use cases it should be sufficient to include the app views directly |
| 257 |
using the default URL conf file. You can customize their functionality or |
| 258 |
access controls by extending the base views. |
| 259 |
|
| 260 |
There are three models: |
| 261 |
|
| 262 |
* **Organization** The group object. This is what you would associate your own |
| 263 |
app's functionality with, e.g. subscriptions, repositories, projects, etc. |
| 264 |
* **OrganizationUser** A custom `through` model for the ManyToMany relationship |
| 265 |
between the `Organization` model and the `User` model. It stores additional |
| 266 |
information about the user specific to the organization and provides a |
| 267 |
convenient link for organization ownership. |
| 268 |
* **OrganizationOwner** The user with rights over the life and death of the |
| 269 |
organization. This is a one to one relationship with the `OrganizationUser` |
| 270 |
model. This allows `User` objects to own multiple organizations and makes it |
| 271 |
easy to enforce ownership from within the organization's membership. |
| 272 |
|
| 273 |
The underlying organizations API is simple: |
| 274 |
|
| 275 |
.. code-block:: python |
| 276 |
|
| 277 |
>>> from organizations.utils import create_organization |
| 278 |
>>> chris = User.objects.get(username="chris") |
| 279 |
>>> soundgarden = create_organization(chris, "Soundgarden", org_user_defaults={'is_admin': True}) |
| 280 |
>>> soundgarden.is_member(chris) |
| 281 |
True |
| 282 |
>>> soundgarden.is_admin(chris) |
| 283 |
True |
| 284 |
>>> soundgarden.owner.organization_user |
| 285 |
<OrganizationUser: Chris Cornell> |
| 286 |
>>> soundgarden.owner.organization_user.user |
| 287 |
>>> <User: chris> |
| 288 |
>>> audioslave = create_organization(chris, "Audioslave") |
| 289 |
>>> tom = User.objects.get(username="tom") |
| 290 |
>>> audioslave.add_user(tom, is_admin=True) |
| 291 |
<OrganizationUser: Tom Morello> |
| 292 |
|
| 293 |
Custom models |
| 294 |
------------- |
| 295 |
|
| 296 |
Django-organizations can act as a base library (not installed in your project) |
| 297 |
and used to create unique organization model sets using custom tables. See the |
| 298 |
`Cooking with Django Organizations |
| 299 |
<http://django-organizations.readthedocs.org/en/latest/cookbook.html#advanced-customization>`_ |
| 300 |
section in the documentation for advice on proceeding. |
| 301 |
|
| 302 |
License |
| 303 |
======= |
| 304 |
|
| 305 |
Anyone is free to use or modify this software under the terms of the BSD |
| 306 |
license. |
| 307 |
|
| 308 |
Sponsors |
| 309 |
======== |
| 310 |
|
| 311 |
`Muster <https://www.muster.com/home?utm_source=github&campaign=opensource>`_ is building precision advocacy software to impact policy through grassroots action. |
| 312 |
|
| 313 |
.. image:: https://www.muster.com/hs-fs/hubfs/muster_logo-2.png?width=600&name=muster_logo-2.png |
| 314 |
:target: https://www.muster.com/home?utm_source=github&campaign=opensource |
| 315 |
:width: 400 |
| 316 |
:alt: Alternative text |
| 317 |
|