mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Bugfixing (#27)
* Enforce ordering on some metadata models * Fix a 500 error while accessing flat pages * Clean up HTML and fix cards (missing class) * Make the "driver" app optional and disabled by default
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 4.2.6 on 2023-10-10 12:44
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("metadata", "0013_decoderdocument_private"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="decoder",
|
||||
options={"ordering": ["manufacturer", "name"]},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name="tag",
|
||||
options={"ordering": ["name"]},
|
||||
),
|
||||
]
|
@@ -95,6 +95,9 @@ class Decoder(models.Model):
|
||||
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
ordering = ["manufacturer", "name"]
|
||||
|
||||
def __str__(self):
|
||||
return "{0} - {1}".format(self.manufacturer, self.name)
|
||||
|
||||
@@ -163,6 +166,9 @@ class Tag(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
slug = models.CharField(max_length=128, unique=True)
|
||||
|
||||
class Meta(object):
|
||||
ordering = ["name"]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
@@ -1,11 +1,7 @@
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
{% if d.item.image.all %}
|
||||
<a href="{{ d.item.get_absolute_url }}">
|
||||
{% for r in d.item.image.all %}
|
||||
{% if forloop.first %}<img src="{{ r.image.url }}" alt="Card image cap">{% endif %}
|
||||
{% endfor %}
|
||||
</a>
|
||||
{% if d.item.image.exists %}
|
||||
<a href="{{d.item.get_absolute_url}}"><img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d }}"></a>
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<p class="card-text" style="position: relative;">
|
||||
|
@@ -2,12 +2,10 @@
|
||||
<div class="card shadow-sm">
|
||||
<a href="{{ d.item.get_absolute_url }}">
|
||||
{% if d.item.image %}
|
||||
<img src="{{ d.item.image.url }}" alt="Card image cap">
|
||||
<img class="card-img-top" src="{{ d.item.image.url }}" alt="{{ d }}">
|
||||
{% else %}
|
||||
{% with d.item.consist_item.first.rolling_stock as r %}
|
||||
{% for i in r.image.all %}
|
||||
{% if forloop.first %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
||||
{% endfor %}
|
||||
<img class="card-img-top" src="{{ r.image.first.image.url }}" alt="{{ d }}"></a>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</a>
|
||||
|
@@ -14,7 +14,6 @@
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:index' %}">Admin</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:portal_siteconfiguration_changelist' %}">Site configuration</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:driver_driverconfiguration_changelist' %}">DCC configuration</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
</ul>
|
||||
|
@@ -444,14 +444,15 @@ class GetBook(View):
|
||||
|
||||
class GetFlatpage(View):
|
||||
def get(self, request, flatpage):
|
||||
_filter = Q(published=True) # Show only published pages
|
||||
if request.user.is_authenticated:
|
||||
_filter = Q() # Reset the filter if user is authenticated
|
||||
|
||||
try:
|
||||
flatpage = Flatpage.objects.get(path=flatpage)
|
||||
flatpage = Flatpage.objects.filter(_filter).get(path=flatpage)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
flatpage = flatpage.filter(published=False)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"flatpages/flatpage.html",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.6.5"
|
||||
__version__ = "0.7.0"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
@@ -51,7 +51,7 @@ INSTALLED_APPS = [
|
||||
"rest_framework",
|
||||
"ram",
|
||||
"portal",
|
||||
"driver",
|
||||
# "driver",
|
||||
"metadata",
|
||||
"roster",
|
||||
"consist",
|
||||
|
@@ -13,6 +13,7 @@ Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
from django.conf.urls.static import static
|
||||
@@ -27,10 +28,15 @@ urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
path("api/v1/consist/", include("consist.urls")),
|
||||
path("api/v1/roster/", include("roster.urls")),
|
||||
path("api/v1/dcc/", include("driver.urls")),
|
||||
path("api/v1/bookshelf/", include("bookshelf.urls")),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# Enable the "/dcc" routing only if the "driver" app is active
|
||||
if apps.is_installed("driver"):
|
||||
urlpatterns += [
|
||||
path("api/v1/dcc/", include("driver.urls")),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
from django.views.generic import TemplateView
|
||||
from rest_framework.schemas import get_schema_view
|
||||
|
Reference in New Issue
Block a user