Move properties under model and class sections

This commit is contained in:
2022-07-13 20:40:42 +02:00
parent 1f4966ad49
commit 899e33da61
6 changed files with 78 additions and 21 deletions

View File

@@ -0,0 +1,7 @@
<section class="py-4 text-center container">
<div class="row">
<div class="mx-auto">
{% block header_content %}{% endblock %}
</div>
</div>
</section>

View File

@@ -29,7 +29,6 @@
<button class="nav-link" id="nav-class-tab" data-bs-toggle="tab" data-bs-target="#nav-class" type="button" role="tab" aria-controls="nav-class" aria-selected="false">Class data</button>
{% if rolling_stock.decoder %}<button class="nav-link" id="nav-dcc-tab" data-bs-toggle="tab" data-bs-target="#nav-dcc" type="button" role="tab" aria-controls="nav-dcc" aria-selected="false">DCC</button>{% endif %}
{% if rolling_stock.notes %}<button class="nav-link" id="nav-notes-tab" data-bs-toggle="tab" data-bs-target="#nav-notes" type="button" role="tab" aria-controls="nav-notes" aria-selected="false">Notes</button>{% endif %}
{% if properties.count > 0 %}<button class="nav-link" id="nav-properties-tab" data-bs-toggle="tab" data-bs-target="#nav-properties" type="button" role="tab" aria-controls="nav-properties" aria-selected="false">Properties</button>{% endif %}
{% if rolling_stock.document.count > 0 %}<button class="nav-link" id="nav-documents-tab" data-bs-toggle="tab" data-bs-target="#nav-documents" type="button" role="tab" aria-controls="nav-documents" aria-selected="false">Documents</button>{% endif %}
</div>
</nav>
@@ -139,6 +138,23 @@
</tr>
</tbody>
</table>
{% if rolling_stock_properties %}
<table class="table table-striped">
<thead>
<tr>
<th colspan="2" scope="row">Properties</th>
</tr>
</thead>
<tbody>
{% for p in rolling_stock_properties %}
<tr>
<th width="35%" scope="row">{{ p.property }}</th>
<td>{{ p.value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
<div class="tab-pane fade" id="nav-class" role="tabpanel" aria-labelledby="nav-class-tab">
<table class="table table-striped">
@@ -170,6 +186,23 @@
</tr>
</tbody>
</table>
{% if class_properties %}
<table class="table table-striped">
<thead>
<tr>
<th colspan="2" scope="row">Properties</th>
</tr>
</thead>
<tbody>
{% for p in class_properties %}
<tr>
<th width="35%" scope="row">{{ p.property }}</th>
<td>{{ p.value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
<div class="tab-pane fade" id="nav-dcc" role="tabpanel" aria-labelledby="nav-dcc-tab">
<table class="table table-striped">
@@ -209,23 +242,6 @@
<div class="tab-pane fade" id="nav-notes" role="tabpanel" aria-labelledby="nav-notes-tab">
{{ rolling_stock.notes | markdown | safe }}
</div>
<div class="tab-pane fade" id="nav-properties" role="tabpanel" aria-labelledby="nav-properties-tab">
<table class="table table-striped">
<thead>
<tr>
<th colspan="2" scope="row">Properties</th>
</tr>
</thead>
<tbody>
{% for p in properties %}
<tr>
<th scope="row">{{ p.property }}</th>
<td>{{ p.value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="tab-pane fade" id="nav-documents" role="tabpanel" aria-labelledby="nav-documents-tab">
<table class="table table-striped">
<thead>

View File

@@ -113,7 +113,14 @@ class GetRollingStock(View):
except ObjectDoesNotExist:
raise Http404
properties = (
import pdb; pdb.set_trace()
class_properties = (
rolling_stock.rolling_class.property.all() if
request.user.is_authenticated else
rolling_stock.rolling_class.property.filter(
property__private=False)
)
rolling_stock_properties = (
rolling_stock.property.all() if
request.user.is_authenticated else
rolling_stock.property.filter(property__private=False)
@@ -124,7 +131,8 @@ class GetRollingStock(View):
"page.html",
{
"rolling_stock": rolling_stock,
"properties": properties,
"class_properties": class_properties,
"rolling_stock_properties": rolling_stock_properties,
},
)

View File

@@ -1,4 +1,4 @@
from ram.utils import git_suffix
__version__ = "0.0.4"
__version__ = "0.0.5"
__version__ += git_suffix(__file__)

View File

@@ -0,0 +1,24 @@
# Generated by Django 4.0.6 on 2022-07-13 17:58
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('roster', '0005_alter_rollingstockproperty_rolling_stock'),
]
operations = [
migrations.AlterField(
model_name='rollingclassproperty',
name='rolling_class',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='property', to='roster.rollingclass', verbose_name='Class'),
),
migrations.AlterField(
model_name='rollingstock',
name='rolling_class',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rolling_class', to='roster.rollingclass', verbose_name='Class'),
),
]

View File

@@ -55,6 +55,7 @@ class RollingClassProperty(models.Model):
on_delete=models.CASCADE,
null=False,
blank=False,
related_name="property",
verbose_name="Class",
)
property = models.ForeignKey(Property, on_delete=models.CASCADE)
@@ -74,6 +75,7 @@ class RollingStock(models.Model):
on_delete=models.CASCADE,
null=False,
blank=False,
related_name="rolling_class",
verbose_name="Class",
)
road_number = models.CharField(max_length=128, unique=False)