This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

dj_auth

The goal of dj_auth is to limit data access for certain user over your django project.

Requirements

Django 1.9

Quickstart

Install dj_auth:

pip install dj_auth

Put dj_auth into your INSTALLED_APPS at settings module:

INSTALLED_APPS = (
   ...
   'dj_auth',
)

Create dj_auth database tables by running:

python manage.py migrate

Extend the Queryset methods of your Models:

from django.db import models

from dj_auth.models import ObjectFilterQuerySetMixin

class YourModelQuerySet(ObjectFilterQuerySetMixin, models.QuerySet):

    def sichtbar(self, sichtbar=True):
        return self.filter(sichtbar=sichtbar)


class YourModel(models.Model):
    your_fielfs = models.SmallIntegerField()

    objects = YourModelQuerySet.as_manager()

Set DJ_AUTH constant in your settings.py:

DJ_AUTH = {'content_type_exclude': ('contenttypes.contenttype', 'sessions.session', 'sites.site',
                                    'auth.user', 'auth.group', 'auth.permission', 'admin.logentry',
                                    'dj_auth.objectfilter',),
           'content_type_include': (),
           'global_fields_exclude':  ('user', ),
           'related_filter_fields_exclude': {'auth.user': ('groups', ), },
           }

In “content_type_exclude” you put the models on which you don’t want create ObjectFilters

In “content_type_include” you put the models on which you want create ObjectFilters

In “global_fields_exclude” you put the fieldnames on which you don’t want apply the ObjectFilter globally

In “related_filter_fields_exclude” you put the fieldnames on which you don’t want apply the ObjectFilter for a specific Model

Features

ObjectFilterFormMixin

First of all you have to create an ObjectFilter record for a specific user. Therefore you can should use ObjectFilterFormMixin:

from django import forms

from dj_auth.forms import ObjectFilterFormMixin

class ObjectFilterForm(ObjectFilterFormMixin, forms.ModelForm):
    pass

ObjectFilterListMixin

To limit data in ListView use ObjectFilterListMixin:

from django.views.generic import ListView
from django.contrib.auth import get_user_model

from dj_auth.views import ObjectFilterListMixin

class UserListView(ObjectFilterListMixin, ListView):
    model = get_user_model()

ObjectFilterDetailMixin

To limit data in DetailView use ObjectFilterDetailMixin:

from django.views.generic import DetailView
from django.contrib.auth import get_user_model

from dj_auth.views import ObjectFilterDetailMixin

class UserDetailView(ObjectFilterDetailMixin, DetailView):
    model = get_user_model()

ObjectFilterUpdateMixin

To limit data in UpdateView use ObjectFilterUpdateMixin:

from django.views.generic import UpdateView
from django.contrib.auth import get_user_model

from dj_auth.views import ObjectFilterUpdateMixin

class UserDetailView(ObjectFilterUpdateMixin, UpdateView):
    model = get_user_model()

ObjectFilterDeleteMixin

To limit data in UpdateView use ObjectFilterDeleteMixin:

from django.views.generic import DeleteView
from django.contrib.auth import get_user_model

from dj_auth.views import ObjectFilterDeleteMixin

class UserDetailView(ObjectFilterDeleteMixin, DeleteView):
    model = get_user_model()

Todo

  • Python 3

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ coverage run --source=dj_auth runtests.py && coverage html

Credits

Tools used in rendering this package:

History

0.1.0 (2016-07-29)

  • First release on PyPI.
Release History

Release History

1.1.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dj_auth-1.1.5-py2.py3-none-any.whl (16.4 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Oct 27, 2016
dj_auth-1.1.5.tar.gz (11.8 kB) Copy SHA256 Checksum SHA256 Source Oct 27, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting