diff --git a/ram/consist/admin.py b/ram/consist/admin.py index 451f0d6..fdcfe57 100644 --- a/ram/consist/admin.py +++ b/ram/consist/admin.py @@ -31,6 +31,7 @@ class ConsistAdmin(SortableAdminBase, admin.ModelAdmin): "consist_address", "company", "era", + "image", "notes", "tags", ) diff --git a/ram/consist/migrations/0003_consist_image.py b/ram/consist/migrations/0003_consist_image.py new file mode 100644 index 0000000..6cf7480 --- /dev/null +++ b/ram/consist/migrations/0003_consist_image.py @@ -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/'), + ), + ] diff --git a/ram/consist/models.py b/ram/consist/models.py index 3bf1d6d..831ed59 100644 --- a/ram/consist/models.py +++ b/ram/consist/models.py @@ -17,6 +17,7 @@ class Consist(models.Model): Company, on_delete=models.CASCADE, null=True, 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) creation_time = models.DateTimeField(auto_now_add=True) updated_time = models.DateTimeField(auto_now=True) diff --git a/ram/metadata/migrations/0003_property_private.py b/ram/metadata/migrations/0003_property_private.py new file mode 100644 index 0000000..b83ad9d --- /dev/null +++ b/ram/metadata/migrations/0003_property_private.py @@ -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), + ), + ] diff --git a/ram/metadata/models.py b/ram/metadata/models.py index 33999bb..7abf8be 100644 --- a/ram/metadata/models.py +++ b/ram/metadata/models.py @@ -8,6 +8,7 @@ from ram.utils import get_image_preview, slugify class Property(models.Model): name = models.CharField(max_length=128, unique=True) + private = models.BooleanField(default=False) class Meta: verbose_name_plural = "Properties" diff --git a/ram/portal/templates/consists.html b/ram/portal/templates/consists.html index 6c77ddb..139ff33 100644 --- a/ram/portal/templates/consists.html +++ b/ram/portal/templates/consists.html @@ -8,6 +8,7 @@ {% for c in consist %}
+ {% if c.image %}Card image cap{% endif %}

{{ c.identifier }}

{% if c.tags.all %} @@ -46,7 +47,7 @@
Show all data - {% if request.user.is_staff %}Edit{% endif %} + {% if request.user.is_staff %}Edit{% endif %}
Updated {{ c.updated_time | date:"M d, Y H:m" }} diff --git a/ram/portal/templates/page.html b/ram/portal/templates/page.html index 1ea1716..9a9074c 100644 --- a/ram/portal/templates/page.html +++ b/ram/portal/templates/page.html @@ -29,7 +29,7 @@ {% if rolling_stock.decoder %}{% endif %} {% if rolling_stock.notes %}{% endif %} - {% if rolling_stock.property.count > 0 %}{% endif %} + {% if properties.count > 0 %}{% endif %} {% if rolling_stock.document.count > 0 %}{% endif %}
@@ -217,7 +217,7 @@ - {% for p in rolling_stock.property.all %} + {% for p in properties %} {{ p.property }} {{ p.value }} diff --git a/ram/portal/views.py b/ram/portal/views.py index 85b32d7..3d5cd20 100644 --- a/ram/portal/views.py +++ b/ram/portal/views.py @@ -113,11 +113,18 @@ class GetRollingStock(View): except ObjectDoesNotExist: raise Http404 + properties = ( + rolling_stock.property.all() if + request.user.is_authenticated else + rolling_stock.property.filter(property__private=False) + ) + return render( request, "page.html", { "rolling_stock": rolling_stock, + "properties": properties, }, ) diff --git a/ram/ram/__init__.py b/ram/ram/__init__.py index 5cad5cb..80b08bd 100644 --- a/ram/ram/__init__.py +++ b/ram/ram/__init__.py @@ -1,4 +1,4 @@ from ram.utils import git_suffix -__version__ = "0.0.3" +__version__ = "0.0.4" __version__ += git_suffix(__file__)