Metadata-Version: 1.1
Name: django-field-guard
Version: 0.1
Summary: Add per field permissions
Home-page: https://github.com/MrKesn/django-field-guard
Author: Alexandr Goncharov
Author-email: kesn@yandex.ru
License: MIT
Description: 
        Django field guard
        ==============================
        
        This app allows to add permissions for models' fields. The users who don't have permission to edit specified field will have this field read-only in django admin.
        
        Installation
        ------------
        
        Add ``fieldguard`` to ``INSTALLED_APPS``::
        
            # settings.py
            INSTALLED_APPS = (
                ...
                'django.contrib.admin',
                'fieldguard',
            )
        
        Set ``@fieldguard.guard(field1, field2, ...)`` or ``@fieldguard.guard()`` decorator for desired model. Those fields ``field1``, ``field2`` etc. will be protected by the newly created rule::
        
            # shop/models.py
            ...
            import fieldguard
            
            ...
            @fieldguard.guard('name')
            class Product(models.Model):
                name = models.CharField(max_length=255)
                description = models.TextField(blank=True)
                quantity = models.PositiveIntegerField()
                price = models.PositiveIntegerField()
        
        Set ``@fieldguard.enforce`` decorator for model's admin class. DO NOT FORGET TO ADD ``model`` which must specify the model class corresponding to current admin class. Set it even if the admin class is not InlineAdmin::
            
            # shop/admin.py
            ...
            import fieldguard
            from shop.models import Product
            
            ...
            @fieldguard.enforce()
            class ProductAdmin(admin.ModelAdmin)
                model = Product
                ...
            
            admin.site.register(Product, ProductAdmin)
        
        Update django permissions db table::
        
            ./manage.py fgsync
            
        Now go to the django admin page and edit any user's permissions. You will see there something like ``Can edit <model_name>[<field>]``.
        From the example above, the rule will be ``Can edit Product[name]``.
        
        Now any user who doesn't have the permission ``Can edit Product[name]`` sees field ``name`` as readonly.
        
        
        
Keywords: django model permission field
Platform: any
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
