specialunderwear / django-easymode

Quickly build backends for flash/flex websites with Django.
GNU General Public License v3.0
33 stars 20 forks source link

Check standard permissions for add/edit/remove features #1

Closed nnseva closed 12 years ago

nnseva commented 12 years ago

Let we have two classes, f.e.:

class Top(models.Model):
        pass
class Bottom(models.Model):
        top = models.ForeignKey(Top)

and tree admin view where the Top is a root object class, while Bottom is a leaf object class.

User having no permissions to add a new Bottom object should not see the "Add ..." button in a tree view User having no permissions to add a new Bottom object should not see the empty Bottom object in a tree view User having no permissions to edit the Bottom object should not see the "Edit ..." button/link in a tree view User having no permissions to edit the Bottom object should not see editable fields in a tree view User having no permissions to delete the Bottom object should not see the "Delete ..." checkbox in a tree view

specialunderwear commented 12 years ago

Can you please verify, that in django if ChildModel is inlined in ParentModel, and the user has permission to add ParentModel but not ChildModel, that the add button is gone? If I remember correctly, this doesn't work correctly in django and is the cause for the problem you observe.

class ParentModel(models.Model):
    title = models.CharField(max_length=5)

class ChildModel(models.Model):
    parent = models.ForeignKey(ParentModel)

class ChildModelInline(admin.StackedInline):
    model = ChildModel

class ParentModelAdmin(admin.ModelAdmin):
    inlines = [ChildModelInline]

admin.site.register(ParentModel, ParentModelAdmin)

Please test in a new project.

nnseva commented 12 years ago

Yes you right, it doesn't work in an original django admin ... let me send an issue there ...

nnseva commented 12 years ago

Just to inform you that this issue has been closed 4 weeks ago in django trunk, hope to see it in the next django release: https://code.djangoproject.com/ticket/8060

specialunderwear commented 12 years ago

Good to know. Be aware that easy mode is not yet compatible with the trunk. Someone reported to me the i18n features are not working. I will fix it and make sure all the unit tests pass as soon as a release candidate is available.