Giter Club home page Giter Club logo

django-pieguard's Introduction

django-pieguard

django-pieguard is a simple authorization class for tastypie that uses django-guardian to handle object permissions.

This was inspired by gist https://gist.github.com/7wonders/6557760.

Requirements

Not tested in other versions yet.

Quickstart

Install django-pieguard:

pip install django-pieguard

Then use it in a tastypie project:

from pieguard.authorization import GuardianAuthorization
from tastypie.resources import Resource
from django.db import models

class MyModel(models.Model):
    class Meta:
        permissions = (
            ('view_mymodel', 'View my model'),
        )

class MyResource(ModelResource):
    class Meta:
        authorization = GuardianAuthorization
        # ... your other options

Notes on permissions

django-pieguard uses a special view_modelname permission to control if user can view that resource or not. As Django only creates add, change and delete permissions by default, you need to add the relevant permission on your model Meta class.

TODO

  • Tests
  • Docs
  • Python 3 official support

License

This work is licensed under MIT license.

django-pieguard's People

Contributors

josecoelho avatar rcmachado avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

josecoelho

django-pieguard's Issues

Create a decent documentation

We need a little more than a readme, specially to explain that user needs to assign an view_modelname permission to models.

Should check global permissions firstly

I'm implementing the tests for your project.

The problem occur when I'm trying to add a new object checking for this permissions. I have to assing a global permission when that's not a dependent model, but that permission is never checked.

E.g: (This should be true, but is not working today)

def test_post_list_with_permission(self):
        assign_perm('test_app.add_project', self.user)

        # [fixme] - should check firstly global permissions!

        resp = self.api_client.post(
            self.api_url,
            format='json',
            authentication=self.get_credentials(),
            data=self.build_data_to_post()
            )

        self.assertHttpCreated(resp)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.