Group accounts for Django
Project description
- Info:
Groups and multi-user account management
- Version:
- 0.5.1
Separate individual user identity from accounts and subscriptions. Django Organizations adds user-managed, multi-user groups to your Django project. Use Django Organizations whether your site needs organizations that function like social groups or multi-user account objects to provide account and subscription functionality beyond the individual user.
Works with your existing user model, whether django.contrib.auth or a custom model. No additional user or authentication functionality required.
Users can be belong to and own more than one organization (account, group)
Invitation and registration functionality works out of the box for many situations and can be extended as need to fit specific requirements.
Start with the base models or use your own for greater customization.
Documentation is on Read the Docs
Installing
First add the application to your Python path. The easiest way is to use pip:
pip install django-organizations
You can also install by downloading the source and running:
$ python setup.py install
By default you will need to install django-extensions or comparable libraries if you plan on adding Django Organizations as an installed app to your Django project. See below on configuring.
Configuring
Make sure you have django.contrib.auth installed, and add the organizations application to your INSTALLED_APPS list:
INSTALLED_APPS = ( ... 'django.contrib.auth', 'organizations', )
Then ensure that your project URL conf is updated. You should hook in the main application URL conf as well as your chosen invitation backend URLs:
from organizations.backends import invitation_backend urlpatterns = patterns('', ... url(r'^accounts/', include('organizations.urls')), url(r'^invitations/', include(invitation_backend().get_urls())), )
Timestamped models and auto slug fields
The standard way of using Django Organizations is to use it as an installed app in your Django project. Django Organizations will need to use a TimeStampedModel and an auto slug field which are not included. By default it will try to import these from django-extensions, but you can configure your own in settings. The defaults:
ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField' ORGS_TIMESTAMPED_MODEL = 'django_extensions.db.models.TimeStampedModel'
Alternatives:
ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField' ORGS_TIMESTAMPED_MODEL = 'model_utils.models.TimeStampedModels'
Registration & invitation backends
You can specify a different invitation backend in your project settings, and the invitation_backend function will provide the URLs defined by that backend:
ORGS_INVITATION_BACKEND = 'myapp.backends.MyInvitationBackend'
Usage Overview
For most use cases it should be sufficient to include the app views directly using the default URL conf file. You can customize their functionality or access controls by extending the base views.
There are three models:
Organization The group object. This is what you would associate your own app’s functionality with, e.g. subscriptions, repositories, projects, etc.
OrganizationUser A custom through model for the ManyToMany relationship between the Organization model and the User model. It stores additional information about the user specific to the organization and provides a convenient link for organization ownership.
OrganizationOwner The user with rights over the life and death of the organization. This is a one to one relationship with the OrganizationUser model. This allows User objects to own multiple organizations and makes it easy to enforce ownership from within the organization’s membership.
- The underlying organizations API is simple::
>>> from organizations.utils import create_organization >>> chris = User.objects.get(username="chris") >>> soundgarden = create_organization(chris, "Soundgarden", org_user_defaults={'is_admin': True}) >>> soundgarden.is_member(chris) True >>> soundgarden.is_admin(chris) True >>> soundgarden.owner.organization_user <OrganizationUser: Chris Cornell> >>> soundgarden.owner.organization_user.user >>> <User: chris> >>> audioslave = create_organization(chris, "Audioslave") >>> tom = User.objects.get(username="tom") >>> audioslave.add_user(tom, is_admin=True) <OrganizationUser: Tom Morello>
Custom models
Django-organizations can act as a base library (not installed in your project) and used to create unique organization model sets using custom tables. See the Cooking with Django Organizations section in the documentation for advice on proceeding.
Development & Contributing
Development is on-going. To-do items have been moved to the wiki for the time being.
The basic functionality should not need much extending. Current dev priorities for me and contributors should include:
Improving the tests and test coverage (ideally moving them back out of the main module and executable using the setup.py file)
Improving the backends and backends concept so that additional invitation and registration backends can be used
Documentation
Ensuring all application text is translatable
Python 3 readiness
Please use the project’s issues tracker to report bugs, doc updates, or other requests/suggestions.
Targets & testing
The codebase is targeted at tested against:
Django 1.4.x against Python 2.7
Django 1.7.x against Python 2.7, 3.3, 3.4
Django 1.8.x against Python 2.7, 3.3, 3.4
To run the tests against all target environments, install tox and then execute the command:
tox
Submitting
These submission guidelines will make it more likely your submissions will be reviewed and make it into the project:
Ensure they match the project goals and are sufficiently generalized
Please try to follow Django coding style. The code base style isn’t all up to par, but I’d like it to move in that direction
Also please try to include good commit log messages.
Pull requests should include an amount of code and commits that are reasonable to review, are logically grouped, and based off clean feature branches.
Code contributions are expected to pass in all target environments, and pull requests should be made from branches with passing builds on Travis CI.
Project goals
django-organizations should be backend agnostic:
Authentication agnostic
Registration agnostic
Invitation agnostic
User messaging agnostic
Etc.
License
Anyone is free to use or modify this software under the terms of the BSD license.
History
0.5.3
Fixes migrations problem in build
0.5.2
Fixes packaging bug
0.5.1
Cleaned up installation instructions
0.5.0
Drops testing support for Django 1.5 and Django 1.6
Adds native Django database migrations
Adds tested support for Django 1.7 and Django 1.8
0.4.3
Adds app specific signals
0.4.2
Various related name fixes in models, registration backends
0.4.1
Support for older Django versions with outdated versions of six
0.4.0
Allows for configurable TimeStampModel (base mixin for default Organization model) and AutoSlugField (field on default Organization model).
0.3.0
Initial Django 1.7 compatability release
0.2.3
Fix issue validating organziation ownership for custom organization models inheriting directly from the Organization class.
0.2.2
Packaging fix
0.2.1
Packaging fix
0.2.0
Abstract base models. These allow for custom organization models without relying on mulit-table inheritence, as well as custom organization user models, all on an app-by-app basis.
0.1.10
Packaging fix
0.1.9
Restructures tests to remove from installed module, should reduce installed package size
0.1.8
Fixes another bug in email invitations
0.1.7
Fixes bug in email invitation
0.1.6
Extends organizaton name length
Increase email field max length
Adds get_or_add_user method to Organization
Email character escaping
0.1.5
Use raw ID fields in admin
Fixes template variable names
Allow superusers access to all organization views
Activate related organizations when activating an owner user
0.1.4a
Bug fix for user model import
0.1.4
Bugfixes for deleting organization users
Removes additional auth.User references in app code
0.1.3b
Changes SlugField to an AutoSlugField from django-extensions
Base models on TimeStampedModel from django-extensions
ForeignKey to user model based on configurable user selection
0.1.3
Manage organization models with South
Added configurable context variable names to view mixins
Added a base backend class which the Invitation and Registration backends extend
Lengthed Organization name and slug fields
Makes mixin model classes configurable
Improved admin display
Removes initial passwords
0.1.2
Added registration backend
Various bug fixes
0.1.1
Add RequestContext to default invitation registration view
Fix invitations
0.1.0
Initial alpha application
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-organizations-0.5.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e9e0453e77d336696023b74812cbe934cb3ce401fb9bcffa29c8ef30b486b7f |
|
MD5 | 406681208bf081072eb05b0f8ef5f2f7 |
|
BLAKE2b-256 | aa55dbd4305977f35499d67ec9696c64387168ae37da1c81f99086c3a2aa00f9 |
Hashes for django_organizations-0.5.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe03e5a43895ef8a14c701f458d299128ad82690ae34868fb77a23094d9e0c44 |
|
MD5 | 7a57241be8ab899506387042e638d584 |
|
BLAKE2b-256 | 6ff2b7d8a6f9f89daeea1da596315706f26b38244f7bfe65f14deb45fc83701a |