mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-07 14:47:49 +02:00
Compare commits
5 Commits
v0.17.5
...
better-doc
Author | SHA1 | Date | |
---|---|---|---|
c7db5fceb2
|
|||
f246656425
|
|||
570c00e34f
|
|||
81d251e310
|
|||
83b80cd7b0
|
Submodule arduino/CommandStation-EX updated: 911bbd63be...13488e1e93
@@ -137,10 +137,6 @@ class Catalog(BaseBook):
|
||||
ordering = ["manufacturer", "publication_year"]
|
||||
|
||||
def __str__(self):
|
||||
# if the object is new, return an empty string to avoid
|
||||
# calling self.scales.all() which would raise a infinite recursion
|
||||
if self.pk is None:
|
||||
return str() # empty string
|
||||
scales = self.get_scales()
|
||||
return "%s %s %s" % (self.manufacturer.name, self.years, scales)
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
"creation_time",
|
||||
"updated_time",
|
||||
)
|
||||
list_filter = ("company__name", "era", "published")
|
||||
list_filter = ("company", "era", "published")
|
||||
list_display = ("__str__",) + list_filter + ("country_flag",)
|
||||
search_fields = ("identifier",) + list_filter
|
||||
save_as = True
|
||||
|
@@ -1,18 +0,0 @@
|
||||
# Generated by Django 5.1.4 on 2025-04-27 19:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0015_consist_description"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="consistitem",
|
||||
name="order",
|
||||
field=models.PositiveIntegerField(),
|
||||
),
|
||||
]
|
@@ -39,25 +39,16 @@ class Consist(BaseModel):
|
||||
def get_absolute_url(self):
|
||||
return reverse("consist", kwargs={"uuid": self.uuid})
|
||||
|
||||
@property
|
||||
def length(self):
|
||||
return self.consist_item.count()
|
||||
|
||||
def get_type_count(self):
|
||||
return self.consist_item.annotate(
|
||||
type=models.F("rolling_stock__rolling_class__type__type")
|
||||
).values(
|
||||
"type"
|
||||
).annotate(
|
||||
count=models.Count("rolling_stock"),
|
||||
category=models.F("rolling_stock__rolling_class__type__category"),
|
||||
order=models.Max("order"),
|
||||
).order_by("order")
|
||||
|
||||
@property
|
||||
def country(self):
|
||||
return self.company.country
|
||||
|
||||
def clean(self):
|
||||
if self.consist_item.filter(rolling_stock__published=False).exists():
|
||||
raise ValidationError(
|
||||
"You must publish all items in the consist before publishing the consist." # noqa: E501
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["company", "-creation_time"]
|
||||
|
||||
@@ -67,7 +58,11 @@ class ConsistItem(models.Model):
|
||||
Consist, on_delete=models.CASCADE, related_name="consist_item"
|
||||
)
|
||||
rolling_stock = models.ForeignKey(RollingStock, on_delete=models.CASCADE)
|
||||
order = models.PositiveIntegerField(blank=False, null=False)
|
||||
order = models.PositiveIntegerField(
|
||||
default=1000, # make sure it is always added at the end
|
||||
blank=False,
|
||||
null=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["order"]
|
||||
@@ -81,12 +76,6 @@ class ConsistItem(models.Model):
|
||||
def __str__(self):
|
||||
return "{0}".format(self.rolling_stock)
|
||||
|
||||
def clean(self):
|
||||
if self.consist.published and not self.rolling_stock.published:
|
||||
raise ValidationError(
|
||||
"You must unpublish the the consist before using this item."
|
||||
)
|
||||
|
||||
def published(self):
|
||||
return self.rolling_stock.published
|
||||
published.boolean = True
|
||||
|
@@ -43,15 +43,13 @@ a.badge, a.badge:hover {
|
||||
border-top: calc(var(--bs-border-width) * 3) solid var(--bs-border-color);
|
||||
}
|
||||
|
||||
#nav-journal ul,
|
||||
#nav-journal ol {
|
||||
#nav-journal ul, #nav-journal ol {
|
||||
margin: 0;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
||||
#nav-journal p:last-child,
|
||||
#nav-journal ul:last-child,
|
||||
#nav-journal ol:last-child {
|
||||
margin-bottom: 0;
|
||||
#nav-journal p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#footer > p {
|
||||
|
@@ -46,10 +46,7 @@
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Company</th>
|
||||
<td>
|
||||
<img src="{{ d.item.company.country.flag }}" alt="{{ d.item.company.country }}">
|
||||
<abbr title="{{ d.item.company.extended_name }}">{{ d.item.company }}</abbr>
|
||||
</td>
|
||||
<td><abbr title="{{ d.item.company.extended_name }}">{{ d.item.company }}</abbr></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
@@ -57,7 +54,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ d.item.length }}</td>
|
||||
<td>{{ d.item.consist_item.count }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -43,7 +43,6 @@
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>
|
||||
<img src="{{ d.item.company.country.flag }}" alt="{{ d.item.company.country }}">
|
||||
<a href="{% url 'filtered' _filter="company" search=d.item.company.slug %}"><abbr title="{{ d.item.company.extended_name }}">{{ d.item.company }}</abbr></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@@ -109,7 +109,7 @@
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th scope="row">Length</th>
|
||||
<td>{{ consist.length }}: {% for t in consist.get_type_count %}{{ t.count }}x {{ t.type }} {{t.category }}{% if not forloop.last %} + {% endif %}{% endfor %}</td>
|
||||
<td>{{ data | length }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@@ -12,11 +12,9 @@
|
||||
<div class="container d-flex text-body-secondary">
|
||||
<p class="flex-fill small">Made with ❤️ for 🚂 and <i class="bi bi-github"></i> <a href="https://github.com/daniviga/django-ram">django-ram</a>
|
||||
{% if site_conf.show_version %}<br>Version {{ site_conf.version }}{% endif %}</p>
|
||||
<p class="text-end">
|
||||
{% if site_conf.disclaimer %}
|
||||
<a title="Disclaimer" href="" data-bs-toggle="modal" data-bs-target="#disclaimerModal"><i class="text-muted d-lg-none fs-5 bi bi-info-square-fill"></i><span class="d-none d-lg-inline small">Disclaimer</span></a><span class="d-none d-lg-inline small"> | </span>
|
||||
{% endif %}
|
||||
<a title="Back to top" href="#"><i class="text-muted d-lg-none fs-5 bi bi-arrow-up-left-square-fill"></i><span class="d-none d-lg-inline small">Back to top</span></a>
|
||||
<p class="text-end fs-5">
|
||||
{% if site_conf.disclaimer %}<a class="text-reset" title="Disclaimer" href="" data-bs-toggle="modal" data-bs-target="#disclaimerModal"><i class="bi bi-info-square-fill"></i></a> {% endif %}
|
||||
<a class="text-reset" title="Back to top" href="#"><i class="bi bi-arrow-up-left-square-fill"></i></a>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.17.5"
|
||||
__version__ = "0.17.0"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
@@ -273,11 +273,11 @@ class RollingStockAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
settings.CSV_SEPARATOR_ALT.join(
|
||||
t.name for t in obj.tags.all()
|
||||
),
|
||||
obj.get_decoder_interface_display(),
|
||||
obj.decoder_interface,
|
||||
obj.decoder,
|
||||
obj.address,
|
||||
obj.shop,
|
||||
obj.purchase_date,
|
||||
obj.shop,
|
||||
obj.price,
|
||||
properties,
|
||||
]
|
||||
|
Reference in New Issue
Block a user