Holger Frey
7 years ago
6 changed files with 266 additions and 17 deletions
@ -0,0 +1,190 @@
@@ -0,0 +1,190 @@
|
||||
{% extends "ordr2:templates/layout.jinja2" %} |
||||
{% import 'ordr2:templates/macros.jinja2' as macros with context %} |
||||
|
||||
{% block subtitle %} Orders {% endblock subtitle %} |
||||
|
||||
{% block content %} |
||||
<div class="content controls"> |
||||
<div class="container-fluid controls"> |
||||
|
||||
<div class="row-fluid"> |
||||
<div class="span2"> |
||||
<div class="page-controls"> |
||||
<h1> |
||||
Users |
||||
</h1> |
||||
</div> |
||||
{{ macros.filter_box('All Orders', 'status', stati, {'user': None} ) }} |
||||
{{ macros.filter_box('My Orders', 'status', stati, {'user': request.user.user_name} ) }} |
||||
</div> |
||||
|
||||
<div class="span10"> |
||||
<form action="{{ request.resource_url(context, 'actions') }}" method="POST"> |
||||
<input type="hidden" name="csrf_token" value="{{get_csrf_token()}}"> |
||||
<div class="page-controls"> |
||||
<div class="input-append search"> |
||||
<input type="search" name="search" size="30" placeholder="Search"> |
||||
<label class="add-on"> |
||||
<button type="submit" class="search" name="action" value="search">Search</button> |
||||
</label> |
||||
</div> |
||||
<div class="actions"> |
||||
{% if request.has_permission('create', context) %} |
||||
<a href="{{ request.resource_url(context, 'splash') }}" rel="tooltip" data-original-title="New" class="btn-flat single"><i class="add"></i></a> |
||||
{% endif %} |
||||
{% if request.has_permission('edit', context) or request.has_permission('delete', context) %} |
||||
<div class="btn-group marking-needed"> |
||||
{% if request.has_permission('edit', context) %} |
||||
<button rel="tooltip" data-original-title="Change Status" value="status" type="submit" name="action" class="btn-flat"><i class="clip"></i></button> |
||||
{% endif %} |
||||
{% if request.has_permission('delete', context) %} |
||||
<button rel="tooltip" data-original-title="Delete" value="delete" type="submit" name="action" class="btn-flat"><i class="trash"></i></button> |
||||
{% endif %} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
<a href="#modal-display" rel="tooltip" data-original-title="Display Options" class="btn-flat single" data-toggle="modal"><i class="eye"></i></a> |
||||
|
||||
<button rel="tooltip" data-original-title="Download View" value="export" type="submit" name="action" class="btn-flat"><i class="download"></i></button> |
||||
</div> |
||||
</div> |
||||
|
||||
{{ macros.flash_messages() }} |
||||
|
||||
{% if orders %} |
||||
{{ macros.show_or_hide_columns('orders') }} |
||||
|
||||
<table class="table"> |
||||
<thead> |
||||
<th class="center"> |
||||
<input type="checkbox" value="all" name="mark_all" id="mark_all"> |
||||
</th> |
||||
{{ macros.sortable_table_header('Date Created', 'created') }} |
||||
{{ macros.sortable_table_header('CAS / Description', 'cas') }} |
||||
{{ macros.sortable_table_header('Vendor', 'vendor') }} |
||||
{{ macros.sortable_table_header('Catalog Nr.', 'catalog') }} |
||||
{{ macros.sortable_table_header('Unit Price', 'price') }} |
||||
{{ macros.sortable_table_header('Quantity', 'amount') }} |
||||
{{ macros.sortable_table_header('Total Price', 'total') }} |
||||
{{ macros.sortable_table_header('Account', 'account') }} |
||||
{{ macros.sortable_table_header('Category', 'category') }} |
||||
{{ macros.sortable_table_header('Status', 'status') }} |
||||
{{ macros.sortable_table_header('Ordered By', 'user') }} |
||||
<th>Actions</th> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
{% for order in orders %} |
||||
<tr> |
||||
<td class="center"> |
||||
<input type="checkbox" name="marked" value="{{ order.model.id }}"> |
||||
</td> |
||||
<td class="column-created">{{ order.model.created_date }}</td> |
||||
<td class="column-cas">{{ order.model.cas_description }}</td> |
||||
<td class="column-vendor">{{ order.model.vendor }}</td> |
||||
<td class="column-catalog">{{ order.model.catalog_nr }}</td> |
||||
<td class="column-price">{{ '%.2f'|format(order.model.unit_price) }} {{ order.model.currency }}</td> |
||||
<td class="column-amount">{{ order.model.amount }}</td> |
||||
<td class="column-total">{{ '%.2f'|format(order.model.total_price) }} {{ order.model.currency }}</td> |
||||
<td class="column-account">{{ order.model.account }}</td> |
||||
<td class="column-category">{{ order.model.category.value|capitalize }}</td> |
||||
<td class="column-status">{{ order.model.status.value|capitalize }}</td> |
||||
<td class="column-user"> |
||||
<a href="{{ request.resource_url(context, query={'user': order.model.created_by}) }}" title="click to view all orders from user">{{ order.model.created_by }}</a> |
||||
</td> |
||||
<td> |
||||
{% if request.has_permission('edit', order) %} |
||||
<a href="{{ request.resource_url(order, 'edit') }}" class="action edit" title="Edit Order">edit</a> |
||||
{% else %} |
||||
<a href="{{ request.resource_url(order) }}" class="action edit" title="Edit Order">edit</a> |
||||
{% endif %} |
||||
{% if request.has_permission('delete', order) %} |
||||
<a href="{{ request.resource_url(order, 'delete') }}" class="action delete" title="Delete Order">delete</a> |
||||
{% endif %} |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
{{ macros.pagination() }} |
||||
{% else %} |
||||
<div class="alert alert-block alert-error"> |
||||
<h4 class="alert-heading">Oh snap! Nothing to display!</h4> |
||||
<p>Your query didn't return any data.</p> |
||||
</div> |
||||
{% endif %} |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div id="modal-display" class="modal hide fade"> |
||||
<form action="{{ request.resource_url(context, 'changeview', query=context.query_params()) }}" method="POST" class="checkslist"> |
||||
<input type="hidden" name="csrf_token" value="{{get_csrf_token()}}"> |
||||
{% set display = request.session.get('display', dict()) %} |
||||
{% set settings = display.get('orders', dict()) %} |
||||
<div class="modal-header"> |
||||
<a href="#" class="close" data-dismiss="modal">×</a> |
||||
<h3>Display Options</h3> |
||||
</div> |
||||
<div class="modal-body"> |
||||
<p class="help-block"><span class="label notice">Notice</span> If the displayed information is too cluttered, deselect some fields below. This will temporaly remove them from your view and should help you stay on top of things.</p> |
||||
<div class="checklist"> |
||||
<fieldset class="left"> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="created" name="display" checked="checked" disabled="disabled"> |
||||
Date Created |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="cas" name="display" {{ 'checked="checked"' if settings.get('cas') }}> |
||||
CAS / Description |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="vendor" name="display" {{ 'checked="checked"' if settings.get('vendor') }}> |
||||
Vendor |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="catalog" name="display" {{ 'checked="checked"' if settings.get('catalog') }}> |
||||
Catalog Number |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="price" name="display" {{ 'checked="checked"' if settings.get('price') }}> |
||||
Unit Price |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="amount" name="display" {{ 'checked="checked"' if settings.get('amount') }}> |
||||
Quantity |
||||
</label> |
||||
</fieldset> |
||||
<fieldset class="right"> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="total" name="display" {{ 'checked="checked"' if settings.get('total') }}> |
||||
Total Price |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="account" name="display" {{ 'checked="checked"' if settings.get('account') }}> |
||||
Account |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="category" name="display" checked="checked" disabled="disabled"> |
||||
Category |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="status" name="display" checked="checked" disabled="disabled"> |
||||
Work Status |
||||
</label> |
||||
<label class="checkbox"> |
||||
<input type="checkbox" value="user" name="display" checked="checked" disabled="disabled"> |
||||
Ordered by |
||||
</label> |
||||
</fieldset> |
||||
</div> |
||||
</div> |
||||
<div class="modal-footer"> |
||||
<button class="btn btn-primary" type="submit">Apply Changes</button> |
||||
<a data-dismiss="modal" class="btn" href="#">Close</a> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
import deform |
||||
|
||||
from pyramid.httpexceptions import HTTPFound |
||||
from pyramid.renderers import render |
||||
from pyramid.view import view_config |
||||
|
||||
from ordr2.events import AccountActivation, PasswordReset |
||||
from ordr2.models import Category, Order, OrderStatus |
||||
from ordr2.schemas.orders import ConsumableSchema |
||||
|
||||
from . import update_column_display |
||||
|
||||
# oder list and multiple editing |
||||
|
||||
@view_config( |
||||
context='ordr2:resources.OrderList', |
||||
permission='view', |
||||
renderer='ordr2:templates/orders/order_list.jinja2' |
||||
) |
||||
def order_list(context, request): |
||||
''' display the order list ''' |
||||
orders = context.items() |
||||
stati = [(s.value.lower(), s.value.capitalize()) for s in OrderStatus] |
||||
return {'orders':orders, 'stati':stati} |
||||
|
||||
|
||||
@view_config( |
||||
context='ordr2:resources.OrderList', |
||||
name = 'changeview', |
||||
permission='view', |
||||
request_method='POST' |
||||
) |
||||
def change_column_view(context, request): |
||||
''' changes the columns to display ''' |
||||
update_column_display(request, 'orders') |
||||
return HTTPFound(context.url()) |
||||
|
Reference in new issue