mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Add private properties and consist thumbnail
This commit is contained in:
@@ -31,6 +31,7 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin):
|
|||||||
"consist_address",
|
"consist_address",
|
||||||
"company",
|
"company",
|
||||||
"era",
|
"era",
|
||||||
|
"image",
|
||||||
"notes",
|
"notes",
|
||||||
"tags",
|
"tags",
|
||||||
)
|
)
|
||||||
|
18
ram/consist/migrations/0003_consist_image.py
Normal file
18
ram/consist/migrations/0003_consist_image.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.0.6 on 2022-07-12 12:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('consist', '0002_alter_consist_options'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='consist',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to='images/'),
|
||||||
|
),
|
||||||
|
]
|
@@ -17,6 +17,7 @@ class Consist(models.Model):
|
|||||||
Company, on_delete=models.CASCADE, null=True, blank=True
|
Company, on_delete=models.CASCADE, null=True, blank=True
|
||||||
)
|
)
|
||||||
era = models.CharField(max_length=32, blank=True)
|
era = models.CharField(max_length=32, blank=True)
|
||||||
|
image = models.ImageField(upload_to="images/", null=True, blank=True)
|
||||||
notes = models.TextField(blank=True)
|
notes = models.TextField(blank=True)
|
||||||
creation_time = models.DateTimeField(auto_now_add=True)
|
creation_time = models.DateTimeField(auto_now_add=True)
|
||||||
updated_time = models.DateTimeField(auto_now=True)
|
updated_time = models.DateTimeField(auto_now=True)
|
||||||
|
18
ram/metadata/migrations/0003_property_private.py
Normal file
18
ram/metadata/migrations/0003_property_private.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.0.6 on 2022-07-12 10:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('metadata', '0002_alter_decoder_manufacturer'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='property',
|
||||||
|
name='private',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
@@ -8,6 +8,7 @@ from ram.utils import get_image_preview, slugify
|
|||||||
|
|
||||||
class Property(models.Model):
|
class Property(models.Model):
|
||||||
name = models.CharField(max_length=128, unique=True)
|
name = models.CharField(max_length=128, unique=True)
|
||||||
|
private = models.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "Properties"
|
verbose_name_plural = "Properties"
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
{% for c in consist %}
|
{% for c in consist %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
|
{% if c.image %}<a href="{{ c.get_absolute_url }}"><img src="{{ c.image.url }}" alt="Card image cap"></a>{% endif %}
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text"><strong>{{ c.identifier }}</strong></p>
|
<p class="card-text"><strong>{{ c.identifier }}</strong></p>
|
||||||
{% if c.tags.all %}
|
{% if c.tags.all %}
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<div class="btn-group mb-4">
|
<div class="btn-group mb-4">
|
||||||
<a class="btn btn-sm btn-outline-primary" href="{{ c.get_absolute_url }}">Show all data</a>
|
<a class="btn btn-sm btn-outline-primary" href="{{ c.get_absolute_url }}">Show all data</a>
|
||||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{# url 'admin:consist_consist_change' c.pk #}">Edit</a>{% endif %}
|
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:consist_consist_change' c.pk %}">Edit</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<small class="text-muted">Updated {{ c.updated_time | date:"M d, Y H:m" }}</small>
|
<small class="text-muted">Updated {{ c.updated_time | date:"M d, Y H:m" }}</small>
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
<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>
|
<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.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 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 rolling_stock.property.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 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 %}
|
{% 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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for p in rolling_stock.property.all %}
|
{% for p in properties %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{{ p.property }}</th>
|
<th scope="row">{{ p.property }}</th>
|
||||||
<td>{{ p.value }}</td>
|
<td>{{ p.value }}</td>
|
||||||
|
@@ -113,11 +113,18 @@ class GetRollingStock(View):
|
|||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
properties = (
|
||||||
|
rolling_stock.property.all() if
|
||||||
|
request.user.is_authenticated else
|
||||||
|
rolling_stock.property.filter(property__private=False)
|
||||||
|
)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"page.html",
|
"page.html",
|
||||||
{
|
{
|
||||||
"rolling_stock": rolling_stock,
|
"rolling_stock": rolling_stock,
|
||||||
|
"properties": properties,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from ram.utils import git_suffix
|
from ram.utils import git_suffix
|
||||||
|
|
||||||
__version__ = "0.0.3"
|
__version__ = "0.0.4"
|
||||||
__version__ += git_suffix(__file__)
|
__version__ += git_suffix(__file__)
|
||||||
|
Reference in New Issue
Block a user