convenience commit

This commit is contained in:
Lance Edgar 2012-12-26 10:07:04 -08:00
parent 8e82e7440a
commit 3edef77e81
4 changed files with 69 additions and 1 deletions

View file

@ -0,0 +1,29 @@
<%def name="autocomplete(field_name, service_url, field_value=None, field_display=None, width='300px', callback=None)">
<div id="${field_name}-container" class="autocomplete-container">
${h.hidden(field_name, id=field_name, value=field_value)}
${h.text(field_name+'-textbox', id=field_name+'-textbox', value=field_display,
class_='autocomplete-textbox', style='display: none;' if field_value else '')}
<div id="${field_name}-display" class="autocomplete-display"${'' if field_value else ' style="display: none;"'|n}>
<span>${field_display or ''}</span>
<button type="button" id="${field_name}-change" class="autocomplete-change">Change</button>
</div>
</div>
<script language="javascript" type="text/javascript">
$(function() {
var autocompleter_${field_name.replace('-', '_')} = $('#${field_name}-textbox').autocomplete({
serviceUrl: '${service_url}',
width: '${width}',
onSelect: function(value, data) {
$('#${field_name}').val(data);
$('#${field_name}-display span').text(value);
$('#${field_name}-textbox').hide();
$('#${field_name}-display').show();
$('#${field_name}-change').focus();
% if callback:
${callback}(data, value);
% endif
},
});
});
</script>
</%def>

View file

@ -0,0 +1,28 @@
<%inherit file="/crud.mako" />
## <%def name="crud_name()">Person</%def>
<%def name="context_menu_items()">
<li>${h.link_to("Back to People", url('people'))}</li>
</%def>
${parent.body()}
## % if fieldset.edit:
## <h2>User Info</h2>
## % if user:
## ${user.render()|n}
## <div class="buttons">
## <button type="button" onclick="location.href = '${url('user.edit', uuid=user.model.uuid)}';">Edit User</button>
## </div>
## % else:
## <p>This person does not have a user account.</p>
## ${h.form(url('user.new'))}
## ${h.hidden('User--person_uuid', value=fieldset.model.uuid)}
## ${h.hidden('User--username')}
## <div class="buttons">
## ${h.submit('submit', "Create User")}
## </div>
## ${h.end_form()}
## % endif
## % endif

View file

@ -0,0 +1,11 @@
<%inherit file="/grid.mako" />
<%def name="title()">People</%def>
## <%def name="context_menu_items()">
## % if request.has_perm('people.create'):
## <li>${h.link_to("Create a new Person", url('person.new'))}</li>
## % endif
## </%def>
${parent.body()}

View file

@ -29,7 +29,7 @@
from sqlalchemy import and_
from rattail.pyramid.views import SearchableAlchemyGridView
from rattail.db.model import Employee, Person
from rattail.db.model import Employee, Person, EmployeePhoneNumber
from rattail.pyramid.forms import AssociationProxyField
from rattail.enum import EMPLOYEE_STATUS_CURRENT