Fix cable type detail

This commit is contained in:
2021-01-31 03:49:57 +00:00
parent add06431ce
commit ea66342aa4
4 changed files with 52 additions and 41 deletions

View File

@@ -58,4 +58,8 @@ def test_page_titles(admin_client):
response = admin_client.get(request_url)
if hasattr(response, "context_data") and "page_title" in response.context_data:
expected_title = response.context_data["page_title"]
# try:
assertInHTML('<title>{} | Rig Information Gathering System'.format(expected_title), response.content.decode())
print("{} | {}".format(request_url, expected_title)) # If test fails, tell me where!
# except:
# print(response.content.decode(), file=open('output.html', 'w'))

View File

@@ -0,0 +1,40 @@
{% extends 'base_assets.html' %}
{% load button from filters %}
{% load cache %}
{% block content %}
<div class="row">
<div class="col-sm-12">
<div class="col">
<div class="card">
<dl class="card-body row">
<dt class="col-6">Socket</dt>
<dd>{{ object.socket|default_if_none:'-' }}</dd>
<dt class="col-6">Plug</dt>
<dd>{{ object.plug|default_if_none:'-' }}</dd>
<dt class="col-6">Circuits</dt>
<dd>{{ object.circuits|default_if_none:'-' }}</dd>
<dt class="col-6">Cores</dt>
<dd>{{ object.cores|default_if_none:'-' }}</dd>
</dl>
</div>
</div>
<div class="col mt-2 text-right">
{% button 'edit' url='cable_type_update' pk=object.id %}
</div>
{% cache None cable_type_assets object %}
<div class="col mt-2">
<div class="card">
<div class="card-header">Associated Assets</div>
{% with object.asset_set.all as object_list %}
{% include 'partials/asset_list_table.html' %}
{% endwith %}
</div>
</div>
{% endcache %}
</div>
</div>
{% endblock %}

View File

@@ -14,47 +14,14 @@
<input type="hidden" name="id" value="{{ object.id|default:0 }}" hidden="">
<div class="row">
<div class="col-sm-12">
{% if create or edit %}
{% for field in form %}
<div class="form-group">
{% include 'partials/form_field.html' with field=field %}
</div>
{% endfor %}
<div class="text-right">
{% button 'submit' %}
{% for field in form %}
<div class="form-group">
{% include 'partials/form_field.html' with field=field %}
</div>
{% else %}
<div class="col">
<div class="card">
<dl class="card-body row">
<dt class="col-6">Socket</dt>
<dd>{{ object.socket|default_if_none:'-' }}</dd>
<dt class="col-6">Plug</dt>
<dd>{{ object.plug|default_if_none:'-' }}</dd>
<dt class="col-6">Circuits</dt>
<dd>{{ object.circuits|default_if_none:'-' }}</dd>
<dt class="col-6">Cores</dt>
<dd>{{ object.cores|default_if_none:'-' }}</dd>
</dl>
</div>
</div>
<div class="col mt-2 text-right">
{% button 'edit' url='cable_type_update' pk=object.id %}
</div>
{% cache None cable_type_assets object %}
<div class="col mt-2">
<div class="card">
<div class="card-header">Associated Assets</div>
{% with object.asset_set.all as object_list %}
{% include 'partials/asset_list_table.html' %}
{% endwith %}
</div>
</div>
{% endcache %}
{% endif %}
{% endfor %}
<div class="text-right">
{% button 'submit' %}
</div>
</div>
</div>
</form>

View File

@@ -314,7 +314,7 @@ class CableTypeList(generic.ListView):
class CableTypeDetail(generic.DetailView):
model = models.CableType
template_name = 'cable_type_form.html'
template_name = 'cable_type_detail.html'
def get_context_data(self, **kwargs):
context = super(CableTypeDetail, self).get_context_data(**kwargs)