update user views
This commit is contained in:
parent
26e11bbae0
commit
4eb648f47a
6 changed files with 47 additions and 21 deletions
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/base.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,10 +1,12 @@
|
||||||
<%inherit file="/users/base.mako" />
|
|
||||||
<%inherit file="/crud.mako" />
|
<%inherit file="/crud.mako" />
|
||||||
|
|
||||||
<%def name="crud_name()">User</%def>
|
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
<li>${h.link_to("Back to Users", url('users.list'))}</li>
|
<li>${h.link_to("Back to Users", url('users'))}</li>
|
||||||
|
% if form.readonly:
|
||||||
|
<li>${h.link_to("Edit this User", url('user.update', uuid=form.fieldset.model.uuid))}</li>
|
||||||
|
% elif form.updating:
|
||||||
|
<li>${h.link_to("View this User", url('user.read', uuid=form.fieldset.model.uuid))}</li>
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/users/crud.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,10 +1,11 @@
|
||||||
<%inherit file="/users/base.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
<%inherit file="/index.mako" />
|
|
||||||
|
|
||||||
<%def name="title()">Users</%def>
|
<%def name="title()">Users</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
<li>${h.link_to("Create a new User", url('user.new'))}</li>
|
% if request.has_perm('users.create'):
|
||||||
|
<li>${h.link_to("Create a new User", url('user.create'))}</li>
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/users/crud.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -34,15 +34,13 @@ from formalchemy.fields import SelectFieldRenderer
|
||||||
import edbob
|
import edbob
|
||||||
from edbob.db.auth import set_user_password
|
from edbob.db.auth import set_user_password
|
||||||
from edbob.pyramid import Session
|
from edbob.pyramid import Session
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView
|
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
|
||||||
from edbob.pyramid.views.crud import Crud
|
|
||||||
|
|
||||||
|
|
||||||
class UsersGrid(SearchableAlchemyGridView):
|
class UsersGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = edbob.User
|
mapped_class = edbob.User
|
||||||
route_name = 'users'
|
config_prefix = 'users'
|
||||||
route_url = '/users'
|
|
||||||
sort = 'username'
|
sort = 'username'
|
||||||
|
|
||||||
def join_map(self):
|
def join_map(self):
|
||||||
|
@ -76,6 +74,15 @@ class UsersGrid(SearchableAlchemyGridView):
|
||||||
g.person,
|
g.person,
|
||||||
],
|
],
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
if self.request.has_perm('users.read'):
|
||||||
|
g.clickable = True
|
||||||
|
g.click_route_name = 'user.read'
|
||||||
|
if self.request.has_perm('users.update'):
|
||||||
|
g.editable = True
|
||||||
|
g.edit_route_name = 'user.update'
|
||||||
|
if self.request.has_perm('users.delete'):
|
||||||
|
g.deletable = True
|
||||||
|
g.delete_route_name = 'user.delete'
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,10 +183,10 @@ class PasswordField(formalchemy.Field):
|
||||||
set_user_password(self.model, password)
|
set_user_password(self.model, password)
|
||||||
|
|
||||||
|
|
||||||
class UserCrud(Crud):
|
class UserCrud(CrudView):
|
||||||
|
|
||||||
mapped_class = edbob.User
|
mapped_class = edbob.User
|
||||||
home_route = 'users.list'
|
home_route = 'users'
|
||||||
|
|
||||||
def fieldset(self, user):
|
def fieldset(self, user):
|
||||||
fs = self.make_fieldset(user)
|
fs = self.make_fieldset(user)
|
||||||
|
@ -213,5 +220,27 @@ class UserCrud(Crud):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
UsersGrid.add_route(config)
|
|
||||||
UserCrud.add_routes(config)
|
config.add_route('users', '/users')
|
||||||
|
config.add_view(UsersGrid, route_name='users',
|
||||||
|
renderer='/users/index.mako',
|
||||||
|
permission='users.list')
|
||||||
|
|
||||||
|
config.add_route('user.create', '/users/new')
|
||||||
|
config.add_view(UserCrud, attr='create', route_name='user.create',
|
||||||
|
renderer='/users/crud.mako',
|
||||||
|
permission='users.create')
|
||||||
|
|
||||||
|
config.add_route('user.read', '/users/{uuid}')
|
||||||
|
config.add_view(UserCrud, attr='read', route_name='user.read',
|
||||||
|
renderer='/users/crud.mako',
|
||||||
|
permission='users.read')
|
||||||
|
|
||||||
|
config.add_route('user.update', '/users/{uuid}/edit')
|
||||||
|
config.add_view(UserCrud, attr='update', route_name='user.update',
|
||||||
|
renderer='/users/crud.mako',
|
||||||
|
permission='users.update')
|
||||||
|
|
||||||
|
config.add_route('user.delete', '/users/{uuid}/delete')
|
||||||
|
config.add_view(UserCrud, attr='delete', route_name='user.delete',
|
||||||
|
permission='users.delete')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue