mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +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
|
upload_to="images/", storage=DeduplicatedStorage, null=True, blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
ordering = ["manufacturer", "name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{0} - {1}".format(self.manufacturer, self.name)
|
return "{0} - {1}".format(self.manufacturer, self.name)
|
||||||
|
|
||||||
@@ -163,6 +166,9 @@ class Tag(models.Model):
|
|||||||
name = models.CharField(max_length=128, unique=True)
|
name = models.CharField(max_length=128, unique=True)
|
||||||
slug = models.CharField(max_length=128, unique=True)
|
slug = models.CharField(max_length=128, unique=True)
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
ordering = ["name"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
{% if d.item.image.all %}
|
{% if d.item.image.exists %}
|
||||||
<a href="{{ d.item.get_absolute_url }}">
|
<a href="{{d.item.get_absolute_url}}"><img class="card-img-top" src="{{ d.item.image.first.image.url }}" alt="{{ d }}"></a>
|
||||||
{% for r in d.item.image.all %}
|
|
||||||
{% if forloop.first %}<img src="{{ r.image.url }}" alt="Card image cap">{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text" style="position: relative;">
|
<p class="card-text" style="position: relative;">
|
||||||
|
@@ -2,12 +2,10 @@
|
|||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<a href="{{ d.item.get_absolute_url }}">
|
<a href="{{ d.item.get_absolute_url }}">
|
||||||
{% if d.item.image %}
|
{% 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 %}
|
{% else %}
|
||||||
{% with d.item.consist_item.first.rolling_stock as r %}
|
{% with d.item.consist_item.first.rolling_stock as r %}
|
||||||
{% for i in r.image.all %}
|
<img class="card-img-top" src="{{ r.image.first.image.url }}" alt="{{ d }}"></a>
|
||||||
{% if forloop.first %}<img src="{{ i.image.url }}" alt="Card image cap">{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
<li><hr class="dropdown-divider"></li>
|
<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: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: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><hr class="dropdown-divider"></li>
|
||||||
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -444,14 +444,15 @@ class GetBook(View):
|
|||||||
|
|
||||||
class GetFlatpage(View):
|
class GetFlatpage(View):
|
||||||
def get(self, request, flatpage):
|
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:
|
try:
|
||||||
flatpage = Flatpage.objects.get(path=flatpage)
|
flatpage = Flatpage.objects.filter(_filter).get(path=flatpage)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
if not request.user.is_authenticated:
|
|
||||||
flatpage = flatpage.filter(published=False)
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"flatpages/flatpage.html",
|
"flatpages/flatpage.html",
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from ram.utils import git_suffix
|
from ram.utils import git_suffix
|
||||||
|
|
||||||
__version__ = "0.6.5"
|
__version__ = "0.7.0"
|
||||||
__version__ += git_suffix(__file__)
|
__version__ += git_suffix(__file__)
|
||||||
|
@@ -51,7 +51,7 @@ INSTALLED_APPS = [
|
|||||||
"rest_framework",
|
"rest_framework",
|
||||||
"ram",
|
"ram",
|
||||||
"portal",
|
"portal",
|
||||||
"driver",
|
# "driver",
|
||||||
"metadata",
|
"metadata",
|
||||||
"roster",
|
"roster",
|
||||||
"consist",
|
"consist",
|
||||||
|
@@ -13,6 +13,7 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
@@ -27,10 +28,15 @@ urlpatterns = [
|
|||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("api/v1/consist/", include("consist.urls")),
|
path("api/v1/consist/", include("consist.urls")),
|
||||||
path("api/v1/roster/", include("roster.urls")),
|
path("api/v1/roster/", include("roster.urls")),
|
||||||
path("api/v1/dcc/", include("driver.urls")),
|
|
||||||
path("api/v1/bookshelf/", include("bookshelf.urls")),
|
path("api/v1/bookshelf/", include("bookshelf.urls")),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + 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:
|
if settings.DEBUG:
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from rest_framework.schemas import get_schema_view
|
from rest_framework.schemas import get_schema_view
|
||||||
|
Reference in New Issue
Block a user