mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
WIP: Audit modal works
Need to get the ID search working.
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_assets.html' %}
|
||||
{% load widget_tweaks %}
|
||||
{% block title %}Audit Asset {{ object.asset_id }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
Audit Asset: {{ object.asset_id }}
|
||||
</h1>
|
||||
</div>
|
||||
<form class="form-horizontal" method="post" id="asset_update_form" action="{% url 'asset_audit' pk=object.asset_id%}">
|
||||
<form class="form-horizontal" method="post" id="asset_update_form" action="{{ form.action|default:request.path }}">
|
||||
{% include 'form_errors.html' %}
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id" value="{{ object.id|default:0 }}" hidden=true>
|
||||
@@ -58,25 +53,10 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-10 pull-right">
|
||||
<button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i> Audit</button>
|
||||
<br>
|
||||
<button type="reset" class="btn btn-link" onclick="history.back()">Cancel</button>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary pull-left" type="submit"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block js%}
|
||||
{% if edit %}
|
||||
<script>
|
||||
function checkIfCableHidden() {
|
||||
if (document.getElementById("id_is_cable").checked) {
|
||||
document.getElementById("cable-table").hidden = false;
|
||||
} else {
|
||||
document.getElementById("cable-table").hidden = true;
|
||||
}
|
||||
}
|
||||
checkIfCableHidden();
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
46
assets/templates/asset_audit_list.html
Normal file
46
assets/templates/asset_audit_list.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% block title %}Asset Audit List{% endblock %}
|
||||
{% load static %}
|
||||
{% load paginator from filters %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block js %}
|
||||
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
|
||||
<script src="{% static "js/interaction.js" %}"></script>
|
||||
<script src="{% static "js/modal.js" %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1 class="text-center">Asset Audit List</h1>
|
||||
</div>
|
||||
|
||||
<form id="asset-search-form" class="form-horizontal" method="POST">
|
||||
<div class="input-group pull-right" style="width: auto;">
|
||||
{% render_field form.query|add_class:'form-control' placeholder='Enter Asset ID' style="width: 250px"%}
|
||||
<label for="query" class="sr-only">Asset ID:</label>
|
||||
<span class="input-group-btn"><a class="btn btn-default modal-href" href="{% url 'asset_audit' 9000 %}"">Search</a></span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Asset ID</th>
|
||||
<th>Description</th>
|
||||
<th>Category</th>
|
||||
<th>Status</th>
|
||||
<th class="hidden-xs">Quick Links</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="asset_table_body">
|
||||
{% include 'partials/asset_list_table_body.html' %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if is_paginated %}
|
||||
<div class="text-center">
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base_assets.html' %}
|
||||
{% load widget_tweaks %}
|
||||
{% block title %}Asset {{ object.asset_id }}{% endblock %}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ urlpatterns = [
|
||||
views.AssetOembed.as_view(),
|
||||
name='asset_oembed'),
|
||||
|
||||
path('asset/audit/', permission_required_with_403('assets.view_asset')(views.AssetAuditList.as_view()), name='asset_audit_list'),
|
||||
path('asset/id/<str:pk>/audit/', permission_required_with_403('assets.view_asset')(views.AssetAudit.as_view()), name='asset_audit'),
|
||||
path('asset/audit/', permission_required_with_403('assets.change_asset')(views.AssetAuditList.as_view()), name='asset_audit_list'),
|
||||
path('asset/id/<str:pk>/audit/', permission_required_with_403('assets.change_asset')(views.AssetAudit.as_view()), name='asset_audit'),
|
||||
|
||||
path('supplier/list', views.SupplierList.as_view(), name='supplier_list'),
|
||||
path('supplier/<int:pk>', views.SupplierDetail.as_view(), name='supplier_detail'),
|
||||
|
||||
@@ -4,9 +4,11 @@ from django.http import HttpResponse, Http404
|
||||
from django.views import generic
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.urls import reverse
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.core import serializers
|
||||
from django.contrib import messages
|
||||
from assets import models, forms
|
||||
from RIGS import versioning
|
||||
|
||||
@@ -110,7 +112,14 @@ class AssetEdit(LoginRequiredMixin, AssetIDUrlMixin, generic.UpdateView):
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("asset_detail", kwargs={"pk": self.object.asset_id})
|
||||
if self.request.is_ajax():
|
||||
url = reverse_lazy('closemodal')
|
||||
update_url = str(reverse_lazy('asset_update', kwargs={'pk': self.object.pk}))
|
||||
messages.info(self.request, "modalobject=" + serializers.serialize("json", [self.object]))
|
||||
messages.info(self.request, "modalobject[0]['update_url']='" + update_url + "'")
|
||||
else:
|
||||
url = reverse_lazy('asset_detail', kwargs={'pk': self.object.asset_id, })
|
||||
return url
|
||||
|
||||
|
||||
class AssetCreate(LoginRequiredMixin, generic.CreateView):
|
||||
@@ -174,24 +183,13 @@ class AssetEmbed(AssetDetail):
|
||||
template_name = 'asset_embed.html'
|
||||
|
||||
|
||||
class AssetAuditList(LoginRequiredMixin, generic.ListView):
|
||||
model = models.Asset
|
||||
template_name = 'asset_list.html'
|
||||
paginate_by = 40
|
||||
ordering = ['-pk']
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
class AssetAuditList(AssetList):
|
||||
template_name = 'asset_audit_list.html'
|
||||
|
||||
|
||||
class AssetAudit(LoginRequiredMixin, AssetIDUrlMixin, generic.UpdateView):
|
||||
class AssetAudit(AssetEdit):
|
||||
template_name = 'asset_audit.html'
|
||||
model = models.Asset
|
||||
form_class = forms.AssetForm
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['edit'] = True
|
||||
context['connectors'] = models.Connector.objects.all()
|
||||
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
# TODO For some reason this doesn't stick when done in form_valid??
|
||||
@@ -199,7 +197,7 @@ class AssetAudit(LoginRequiredMixin, AssetIDUrlMixin, generic.UpdateView):
|
||||
asset.last_audited_by = self.request.user
|
||||
asset.last_audited_at = datetime.datetime.now()
|
||||
asset.save()
|
||||
return reverse("asset_audit_list")
|
||||
return super().get_success_url()
|
||||
|
||||
|
||||
class SupplierList(generic.ListView):
|
||||
|
||||
Reference in New Issue
Block a user