mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
Still improve the DCC section
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load dcc %}
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
{% if d.item.image.exists %}
|
{% if d.item.image.exists %}
|
||||||
@@ -75,7 +77,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">DCC</th>
|
<th scope="row">DCC</th>
|
||||||
<td>{{ d.item.dcc|safe }}</td>
|
<td>{% dcc d.item %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load dcc %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{% if rolling_stock.tags.all %}
|
{% if rolling_stock.tags.all %}
|
||||||
@@ -142,7 +143,9 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">DCC data</th>
|
<th colspan="2" scope="row">DCC data
|
||||||
|
<span class="mt-1 float-end">{% dcc rolling_stock %}</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
@@ -153,11 +156,15 @@
|
|||||||
{% if rolling_stock.decoder %}
|
{% if rolling_stock.decoder %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Decoder</th>
|
<th scope="row">Decoder</th>
|
||||||
<td>{{ rolling_stock.decoder }}
|
<td>{{ rolling_stock.decoder }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Sound</th>
|
||||||
|
<td>
|
||||||
{% if rolling_stock.decoder.sound %}
|
{% if rolling_stock.decoder.sound %}
|
||||||
| <span class="badge text-bg-secondary">
|
<i class="bi bi-check-circle-fill text-success"></i>
|
||||||
<abbr title="Sound decoder"<i class="bi bi-volume-up-fill"></i></abbr>
|
{% else %}
|
||||||
</span>
|
<i class="bi bi-x-circle-fill text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -345,12 +352,14 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">Decoder data</th>
|
<th colspan="2" scope="row">Decoder data
|
||||||
|
<span class="mt-1 float-end">{% dcc rolling_stock %}</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Interface</th>
|
<th class="w-33" scope="row">Interface</th>
|
||||||
<td>{{ rolling_stock.get_decoder_interface }}</td>
|
<td>{{ rolling_stock.get_decoder_interface }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -359,18 +368,31 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Name</th>
|
<th scope="row">Name</th>
|
||||||
<td>{{ rolling_stock.decoder.name }}
|
<td>{{ rolling_stock.decoder.name }}</td>
|
||||||
{% if rolling_stock.decoder.sound %}
|
|
||||||
| <span class="badge text-bg-secondary">
|
|
||||||
<abbr title="Sound decoder"<i class="bi bi-volume-up-fill"></i></abbr>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Version</th>
|
<th scope="row">Version</th>
|
||||||
<td>{{ rolling_stock.decoder.version | default:"-"}}</td>
|
<td>{{ rolling_stock.decoder.version | default:"-"}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Sound</th>
|
||||||
|
<td>
|
||||||
|
{% if rolling_stock.decoder.sound %}
|
||||||
|
<i class="bi bi-check-circle-fill text-success"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="bi bi-x-circle-fill text-secondary"></i>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" scope="row">Decoder configuration</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Address</th>
|
<th class="w-33" scope="row">Address</th>
|
||||||
<td>{{ rolling_stock.address }}</td>
|
<td>{{ rolling_stock.address }}</td>
|
||||||
|
36
ram/portal/templatetags/dcc.py
Normal file
36
ram/portal/templatetags/dcc.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from django import template
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def dcc(object):
|
||||||
|
socket = (
|
||||||
|
'<i class="bi bi-ban small"></i>'
|
||||||
|
)
|
||||||
|
decoder = ''
|
||||||
|
if object.decoder_interface is not None:
|
||||||
|
socket = (
|
||||||
|
f'<abbr title="{object.get_decoder_interface()}">'
|
||||||
|
f'<i class="bi bi-dice-6"></i></abbr>'
|
||||||
|
)
|
||||||
|
if object.decoder:
|
||||||
|
if object.decoder.sound:
|
||||||
|
decoder = (
|
||||||
|
f'<abbr title="{object.decoder}">'
|
||||||
|
'<i class="bi bi-volume-up-fill"></i></abbr>'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
decoder = (
|
||||||
|
f'<abbr title="{object.decoder}'
|
||||||
|
f'({object.get_decoder_interface()})">'
|
||||||
|
'<i class="bi bi-cpu-fill"></i></abbr>'
|
||||||
|
)
|
||||||
|
|
||||||
|
if decoder:
|
||||||
|
return format_html(
|
||||||
|
f'{socket} <i class="bi bi-arrow-bar-left"></i> {decoder}'
|
||||||
|
)
|
||||||
|
|
||||||
|
return format_html(socket)
|
@@ -1,4 +1,4 @@
|
|||||||
from ram.utils import git_suffix
|
from ram.utils import git_suffix
|
||||||
|
|
||||||
__version__ = "0.17.11"
|
__version__ = "0.17.12"
|
||||||
__version__ += git_suffix(__file__)
|
__version__ += git_suffix(__file__)
|
||||||
|
Reference in New Issue
Block a user