Tuesday, September 12, 2017

Re: Need advice on writing very specific custom user roles

It requires some work writing the permissions, but this is what
django-guardian [1] is good at. I would ditch Role as a user attribute
and use groups instead. If cities are limited in number, I would make
city groups as well and then it's just a matter of filtering groups
the right way taking article state into account.

[1] https://djangopackages.org/packages/p/django-guardian/


On Sat, Sep 9, 2017 at 3:30 PM, Ahmad Zoughbi <ahmadzoughbi@gmail.com> wrote:
> Hello,
>
>
> I need to build custom Django user roles, and i need an advice on the best
> approach (or library that i can use) to achieve that:
>
>
> There will be 3 different user levels:
>
> Author
>
> Editor
>
> Verification
>
> Every user must be limited to a city, based on custom field (New York,
> Berlin, Amsterdam, etc)
>
> Only 'Author' can add content, while 'Editor' and 'Verification' can edit
> the content.
>
> Author: Can only view/edit the content created by them.
>
> Editor: Can only view/edit the content created by 'Author's in their cities.
>
> Verification: Can only view/edit the content created by the 'Editor's in
> their cities.
>
> Author: When creates content, should have the options to:
>
> Save as draft
>
> Send to Editor
>
> Editor: When edits content, should have the options to:
>
> Send back to Author
>
> Send to Verification
>
> Verification: When edits content, should have the options to:
>
> Send back to the Editor
>
> Mark as Verified.
>
>
> Scenario:
>
> An admin creates the following users:
>
>
> Username | Role | City | Content titles written by the user
>
>
> John | Author | New York | Test1, Test2, Test3
>
> Sam | Author | New York | Test4, Test5, Test6
>
> Kim | Author | Berlin | Test7, Test8, Test9
>
> Adam | Editor | New York
>
> Alex | Editor | Berlin
>
> Stacey | Verification | New York
>
> Anthony | Verification | Berlin
>
>
> Based on the above scenario, the Authors below should be able to access only
> the titles they created; Additionally:
>
> Adam: Should be able to view/edit the titles: Test1 - Test6 (Since they were
> written by 2 Authors in his City.
>
> Alex: Should be able to view/edit the titles: Test7 - Test9 (Since they were
> written by Kim, which in his city)
>
>
> The same applies for the Verification.
>
>
> Finally, If Author sent the content to Editor, the Author should no longer
> be able to edit the content, until it's sent back to him by the Editor.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46db433a-a6c5-4e6b-92f0-e605b8e7b2f0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Melvyn Sopacua

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Bgw1GWfVb0D14asf%3DAMqJO6Kungucd%2Bf6EyTMvnv5CmSEi8ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment