mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Better approach to generic list templates + other deduplication
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% block title %}Asset List{% endblock %}
|
||||
{% load paginator from filters %}
|
||||
{% load button from filters %}
|
||||
{% load widget_tweaks %}
|
||||
{% load static %}
|
||||
|
||||
@@ -15,34 +15,35 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Asset List</h1>
|
||||
<div class="row justify-content-end">
|
||||
<form id="asset-search-form" method="GET" class="form-inline">
|
||||
<div class="input-group px-1">
|
||||
{% render_field form.q|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' %}
|
||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
<span class="input-group-append"><button type="submit" class="btn btn-info" id="id_search" style="width: 6em">Search</button></span>
|
||||
</div>
|
||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="category" class="sr-only">Category</label>
|
||||
{% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
||||
</div>
|
||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="status" class="sr-only">Status</label>
|
||||
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||
</div>
|
||||
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||
</form>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form id="asset-search-form" method="GET" class="form-inline justify-content-end">
|
||||
<div class="input-group px-1 mb-2 mb-sm-0 flex-nowrap">
|
||||
{% render_field form.q|add_class:'form-control' placeholder='Enter Asset ID/Desc/Serial' %}
|
||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
<span class="input-group-append">{% button 'search' id="id_search" style="width: 6em" %}</span>
|
||||
</div>
|
||||
<div id="category-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="category" class="sr-only">Category</label>
|
||||
{% render_field form.category|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Categories" data-header="Categories" data-actions-box="true" %}
|
||||
</div>
|
||||
<div id="status-group" class="form-group px-1" style="margin-bottom: 0;">
|
||||
<label for="status" class="sr-only">Status</label>
|
||||
{% render_field form.status|attr:'multiple'|add_class:'form-control custom-select selectpicker col-sm' data-none-selected-text="Statuses" data-header="Statuses" data-actions-box="true" %}
|
||||
</div>
|
||||
<button id="filter-submit" type="submit" class="btn btn-secondary" style="width: 6em">Filter</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-end">
|
||||
<a href="{% url 'asset_create' %}" class="btn btn-primary my-2" style="width: 6em">New <span class="fas fa-plus"></span></a>
|
||||
<div class="row my-2">
|
||||
<div class="col text-right">
|
||||
{% button 'new' 'asset_create' style="width: 6em" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% include 'partials/asset_list_table.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% if is_paginated %}
|
||||
<div class="text-center">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% paginator %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block titleheader %}
|
||||
<a class="nav navbar-brand navbar-left" href="/"><span class="fas fa-arrow-circle-left align-middle"></span> RIGS</a>
|
||||
<a class="nav navbar-brand" href="{% url 'asset_index' %}">Assets</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block titleelements %}
|
||||
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Assets</a>
|
||||
<div class="dropdown-menu">
|
||||
@@ -19,7 +19,7 @@
|
||||
{% endif %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{% url 'cable_type_list' %}"><span class="fas fa-list"></span> List Cable Types</a>
|
||||
{% if perms.assets.add_cable_type %}
|
||||
{% if perms.assets.add_cabletype %}
|
||||
<a class="dropdown-item" href="{% url 'cable_type_create' %}"><span class="fas fa-plus"></span> Create Cable Type</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% load button from filters %}
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead class="thead-dark">
|
||||
@@ -21,10 +22,10 @@
|
||||
<a type="button" class="btn btn-info btn-sm modal-href" href="{% url 'asset_audit' item.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
||||
{% else %}
|
||||
<div class="btn-group" role="group">
|
||||
<a type="button" class="btn btn-primary btn-sm" href="{% url 'asset_detail' item.asset_id %}"><i class="fas fa-eye"></i><span class="d-none d-sm-inline"> View</span></a>
|
||||
{% button 'view' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
||||
{% if perms.assets.change_asset %}
|
||||
<a type="button" class="btn btn-warning btn-sm" href="{% url 'asset_update' item.asset_id %}"><i class="fas fa-edit"></i><span class="d-none d-sm-inline"> Edit</span></a>
|
||||
<a type="button" class="btn btn-info btn-sm" href="{% url 'asset_duplicate' item.asset_id %}"><i class="fas fa-clone"></i><span class="d-none d-sm-inline"> Duplicate</span></a>
|
||||
{% button 'edit' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
||||
{% button 'duplicate' url='asset_detail' pk=item.asset_id clazz="btn-sm" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% block title %}Supplier List{% endblock %}
|
||||
{% load paginator from filters %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<h3>Suppliers</h3>
|
||||
</div>
|
||||
{% include 'partials/generic_list.html' with edit="supplier_update" detail="supplier_detail" create="supplier_create" %}
|
||||
{% endblock %}
|
||||
@@ -64,10 +64,9 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AssetList, self).get_context_data(**kwargs)
|
||||
context["form"] = self.form
|
||||
|
||||
context["categories"] = models.AssetCategory.objects.all()
|
||||
|
||||
context["statuses"] = models.AssetStatus.objects.all()
|
||||
context["page_title"] = "Asset List"
|
||||
return context
|
||||
|
||||
|
||||
@@ -208,9 +207,15 @@ class AssetAudit(AssetEdit):
|
||||
|
||||
class SupplierList(GenericListView):
|
||||
model = models.Supplier
|
||||
template_name = 'supplier_list.html'
|
||||
ordering = ['name']
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(SupplierList, self).get_context_data(**kwargs)
|
||||
context['create'] = 'supplier_create'
|
||||
context['edit'] = 'supplier_update'
|
||||
context['detail'] = 'supplier_detail'
|
||||
return context
|
||||
|
||||
|
||||
class SupplierSearch(SupplierList):
|
||||
hide_hidden_status = False
|
||||
|
||||
Reference in New Issue
Block a user