urls.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. __author__ = 'marcos.medeiros'
  3. from django.conf.urls import include, url
  4. from django.contrib.auth.models import User
  5. from rapid.registry import Action
  6. from rapid.models import Application, Profile
  7. from rapid.forms import ManageUsers
  8. from rapid import views
  9. from rapid import permissions
  10. def _can_manage_users(request):
  11. if not request.user.is_authenticated:
  12. return []
  13. return request.user.application.managed_applications.profile_set
  14. _manage_users_permistion = permissions.Permission(
  15. lambda r: False,
  16. _can_manage_users
  17. )
  18. urlpatterns = views.register_model(Application, 'aplicacao',
  19. write_set=permissions.to_superusers(), read_set=permissions.to_all()) +\
  20. views.register_model(Profile, write_set=permissions.to_superusers(), read_set=permissions.to_staff()) +\
  21. views.register_instance_form(Profile, 'manage_users', u'Gerenciar Usuários',
  22. ManageUsers, _manage_users_permistion, "fa-users",
  23. Action.Visibility.list) +\
  24. views.register_simple_select(User, ['username'], permissions.to_staff(), 'usuario')