django-reinhardt Documentation

Similar documents
Python Project Example Documentation

Roman Numeral Converter Documentation

Python wrapper for Viscosity.app Documentation

sainsmart Documentation

I2C LCD Documentation

Release Nicholas A. Del Grosso

TPS Documentation. Release Thomas Roten

Aircrack-ng python bindings Documentation

chatterbot-weather Documentation

PyCRC Documentation. Release 1.0

django-cas Documentation

google-search Documentation

Python simple arp table reader Documentation

django-idioticon Documentation

Redis Timeseries Documentation

Simple libtorrent streaming module Documentation

Poulpe Documentation. Release Edouard Klein

Django Wordpress API Documentation

Google Domain Shared Contacts Client Documentation

Python State Machine Documentation

DNS Zone Test Documentation

Python Schema Generator Documentation

Release Fulfil.IO Inc.

Game Server Manager Documentation

Simple Binary Search Tree Documentation

Python State Machine Documentation

Pykemon Documentation

Python AutoTask Web Services Documentation

open-helpdesk Documentation

django-users2 Documentation

django CMS Export Objects Documentation

OpenUpgrade Library Documentation

dj-libcloud Documentation

smartfilesorter Documentation

Mantis STIX Importer Documentation

django-telegram-bot Documentation

Frontier Documentation

gunny Documentation Release David Blewett

Poetaster. Release 0.1.1

withenv Documentation

django-responsive2 Documentation

PyCon APAC 2014 Documentation

Aldryn Installer Documentation

pydrill Documentation

eventbrite-sdk-python Documentation

Python data pipelines similar to R Documentation

django-private-chat Documentation

doconv Documentation Release Jacob Mourelos

Python AMT Tools Documentation

gpib-ctypes Documentation

yardstick Documentation

pyldavis Documentation

AnyDo API Python Documentation

smsghussd Documentation

Job Submitter Documentation

PyZillow Documentation

django-stored-messages Documentation

e24paymentpipe Documentation

Release Ralph Offinger

API Wrapper Documentation

django-composite-foreignkey Documentation

Python Finite State Machine. Release 0.1.5

nacelle Documentation

dicompyler-core Documentation

ejpiaj Documentation Release Marek Wywiał

CID Documentation. Release Francis Reyes

django-composite-foreignkey Documentation

lazy-object-proxy Release 1.3.1

dublincore Documentation

xmljson Documentation

syslog-ng Apache Kafka destination

ProxySQL Tools Documentation

Connexion Sqlalchemy Utils Documentation

cwmon-mysql Release 0.5.0

pytest-benchmark Release 2.5.0

pvl Documentation Release William Trevor Olson

invenio-groups Documentation

Airoscript-ng Documentation

django-bootstrap3 Documentation

xmodels Documentation

Dragon Mapper Documentation

Release Manu Phatak

Gearthonic Documentation

invenio-formatter Documentation

Archan. Release 2.0.1

Microlab Instruments Documentation

OTX to MISP. Release 1.4.2

Infoblox Client Documentation

Durga Documentation. Release dev2. transcode

Face Recognition Documentation

django mail admin Documentation

redis-lock Release 3.2.0

otree Virtual Machine Manager Documentation

MT940 Documentation. Release Rick van Hattem (wolph)

timegate Documentation

Regressors Documentation

mozilla-django-oidc Documentation

Lazarus Documentation

nxviz Documentation Release 0.3 Eric J. Ma

django-dynamic-db-router Documentation

Transcription:

django-reinhardt Documentation Release 0.1.0 Hyuntak Joo December 02, 2016

Contents 1 django-reinhardt 3 1.1 Installation................................................ 3 1.2 Usage................................................... 3 1.3 Credits.................................................. 4 2 Contributing 5 2.1 Types of Contributions.......................................... 5 2.2 Get Started!................................................ 6 2.3 Pull Request Guidelines......................................... 6 2.4 Tips.................................................... 7 3 Indices and tables 9 i

ii

django-reinhardt Documentation, Release 0.1.0 Contents: Contents 1

django-reinhardt Documentation, Release 0.1.0 2 Contents

CHAPTER 1 django-reinhardt There are many object permission backends like django-guardian or django-permission. But some time, it is needed to define permissions as not just object-user relationship. django-reinhardt make you handle object permissions by defining methods in your django model Free software: MIT license Documentation: https://django-reinhardt.readthedocs.io. 1.1 Installation Use pip like: $ pip install django-reinhardt 1.2 Usage Add extra authorization backends in your settings.py: AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.modelbackend', # default 'reinhardt.backends.permissionbackend', ) It s done. you don t need to add any app or migrate anything. Assume that Inquiry model needs to have two permission: change_inqury, view_inquiry class Inquiry(models.Model): writer = models.foreignkey(settings.auth_user_model) text = models.textfield() pub_date = models.datetimefield(auto_now_add=true) @object_permission(codename='change_inquiry') def is_changeable_by(self, user): return self.writer == user or user.is_staff @object_permission(codename='view_inquiry') 3

django-reinhardt Documentation, Release 0.1.0 def is_viewable_by(self, user): return self.writer == user Then you can just define methods having user parameter, decorated by object_permission. Now the following codes will work as expected: user1 = get_user_model().objects.create( username='nanase' ) user2 = get_user_model().objects.create( username='maiyan' ) user3 = get_user_model().objects.create( username='ikuta' ) inquiry = Inquiry.objects.create( writer=self.user1, text='how can I delete my account?' ) assert user1.has_perm('yourapp.change_inquiry', obj=inquiry) == True assert user2.has_perm('yourapp.view_inquiry', obj=inquiry) == False assert user3.has_perm('yourapp.change_inquiry', obj=inquiry) == False assert user3.has_perm('yourapp.view_inquiry', obj=inquiry) == True 1.3 Credits This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template. 4 Chapter 1. django-reinhardt

CHAPTER 2 Contributing Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: 2.1 Types of Contributions 2.1.1 Report Bugs Report bugs at https://github.com/momamene/reinhardt/issues. If you are reporting a bug, please include: Your operating system name and version. Any details about your local setup that might be helpful in troubleshooting. Detailed steps to reproduce the bug. 2.1.2 Fix Bugs Look through the GitHub issues for bugs. Anything tagged with bug and help wanted is open to whoever wants to implement it. 2.1.3 Implement Features Look through the GitHub issues for features. Anything tagged with enhancement and help wanted is open to whoever wants to implement it. 2.1.4 Write Documentation django-django-reinhardt could always use more documentation, whether as part of the official django-django-reinhardt docs, in docstrings, or even on the web in blog posts, articles, and such. 5

django-reinhardt Documentation, Release 0.1.0 2.1.5 Submit Feedback The best way to send feedback is to file an issue at https://github.com/momamene/django-reinhardt/issues. If you are proposing a feature: Explain in detail how it would work. Keep the scope as narrow as possible, to make it easier to implement. Remember that this is a volunteer-driven project, and that contributions are welcome :) 2.2 Get Started! Ready to contribute? Here s how to set up django-reinhardt for local development. 1. Fork the django-reinhardt repo on GitHub. 2. Clone your fork locally: $ git clone git@github.com:your_name_here/django-reinhardt.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development: $ mkvirtualenv django-reinhardt $ cd django-reinhardt/ $ python setup.py develop 4. Create a branch for local development: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox: $ flake8 django-reinhardt tests $ python setup.py test or py.test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub: $ git add. $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. 2.3 Pull Request Guidelines Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 6 Chapter 2. Contributing

django-reinhardt Documentation, Release 0.1.0 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 3.3, 3.4 and 3.5. Check https://travis-ci.org/momamene/djangoreinhardt/pull_requests and make sure that the tests pass for all supported Python versions. 2.4 Tips To run a subset of tests: $ py.test 2.4. Tips 7

django-reinhardt Documentation, Release 0.1.0 8 Chapter 2. Contributing

CHAPTER 3 Indices and tables genindex modindex search 9