mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Rename DCC project into RAM
RAM: Railroad Assets Manager
This commit is contained in:
0
ram/portal/__init__.py
Normal file
0
ram/portal/__init__.py
Normal file
6
ram/portal/admin.py
Normal file
6
ram/portal/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from solo.admin import SingletonModelAdmin
|
||||
|
||||
from portal.models import SiteConfiguration
|
||||
|
||||
admin.site.register(SiteConfiguration, SingletonModelAdmin)
|
6
ram/portal/apps.py
Normal file
6
ram/portal/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PortalConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'portal'
|
32
ram/portal/migrations/0001_initial.py
Normal file
32
ram/portal/migrations/0001_initial.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-08 22:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SiteConfiguration',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('site_name', models.CharField(default='Map viewer', max_length=256)),
|
||||
('site_author', models.CharField(blank=True, max_length=256)),
|
||||
('about', models.TextField(blank=True)),
|
||||
('maps_per_page', models.CharField(choices=[('6', '6'), ('9', '9'), ('12', '12'), ('15', '15'), ('18', '18'), ('21', '21'), ('24', '24'), ('27', '27'), ('30', '30')], default='6', max_length=2)),
|
||||
('homepage_content', models.TextField(blank=True)),
|
||||
('footer', models.TextField(blank=True)),
|
||||
('footer_short', models.TextField(blank=True)),
|
||||
('show_copyright', models.BooleanField(default=True)),
|
||||
('show_version', models.BooleanField(default=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Site Configuration',
|
||||
},
|
||||
),
|
||||
]
|
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-08 22:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='siteconfiguration',
|
||||
name='site_name',
|
||||
field=models.CharField(default='Trains assets manager', max_length=256),
|
||||
),
|
||||
]
|
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-09 20:31
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0002_alter_siteconfiguration_site_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='siteconfiguration',
|
||||
old_name='maps_per_page',
|
||||
new_name='items_per_page',
|
||||
),
|
||||
]
|
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-09 20:37
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0003_rename_maps_per_page_siteconfiguration_items_per_page'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='siteconfiguration',
|
||||
old_name='footer_short',
|
||||
new_name='footer_extended',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='siteconfiguration',
|
||||
name='show_copyright',
|
||||
),
|
||||
]
|
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-09 21:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0004_rename_footer_short_siteconfiguration_footer_extended_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='siteconfiguration',
|
||||
name='homepage_content',
|
||||
),
|
||||
]
|
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.3 on 2022-04-10 17:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('portal', '0005_remove_siteconfiguration_homepage_content'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='siteconfiguration',
|
||||
name='site_name',
|
||||
field=models.CharField(default='Railroad Assets Manager', max_length=256),
|
||||
),
|
||||
]
|
0
ram/portal/migrations/__init__.py
Normal file
0
ram/portal/migrations/__init__.py
Normal file
33
ram/portal/models.py
Normal file
33
ram/portal/models.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import django
|
||||
from django.db import models
|
||||
|
||||
from ram import __version__ as app_version
|
||||
from solo.models import SingletonModel
|
||||
|
||||
|
||||
class SiteConfiguration(SingletonModel):
|
||||
site_name = models.CharField(
|
||||
max_length=256,
|
||||
default="Railroad Assets Manager")
|
||||
site_author = models.CharField(max_length=256, blank=True)
|
||||
about = models.TextField(blank=True)
|
||||
items_per_page = models.CharField(
|
||||
max_length=2, choices=[
|
||||
(str(x * 3), str(x * 3)) for x in range(2, 11)],
|
||||
default='6'
|
||||
)
|
||||
footer = models.TextField(blank=True)
|
||||
footer_extended = models.TextField(blank=True)
|
||||
show_version = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Site Configuration"
|
||||
|
||||
def __str__(self):
|
||||
return "Site Configuration"
|
||||
|
||||
def version(self):
|
||||
return app_version
|
||||
|
||||
def django_version(self):
|
||||
return django.get_version()
|
11
ram/portal/static/css/main.css
Normal file
11
ram/portal/static/css/main.css
Normal file
@@ -0,0 +1,11 @@
|
||||
.card > a > img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn > span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#footer > p {
|
||||
display: inline;
|
||||
}
|
75
ram/portal/templates/flatpage.html
Normal file
75
ram/portal/templates/flatpage.html
Normal file
@@ -0,0 +1,75 @@
|
||||
{% load static %}
|
||||
{% load breadcrumbs %}
|
||||
{% load solo_tags %}
|
||||
{% get_solo 'portal.SiteConfiguration' as site_conf %}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="{{ site_conf.about }}">
|
||||
<meta name="author" content="{{ site_conf.site_author }}">
|
||||
<link rel="icon" type="image/png" href="{% static 'favicon-196x196.png' %}" sizes="196x196">
|
||||
<link rel="icon" type="image/png" href="{% static 'favicon-128.png' %}" sizes="128x128">
|
||||
<link rel="icon" type="image/png" href="{% static 'favicon-96x96.png' %}" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="{% static 'favicon-32x32.png' %}" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="{% static 'favicon-16x16.png' %}" sizes="16x16">
|
||||
|
||||
<title>{{ site_conf.site_name }} - {{ page.name }}</title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="{% static "css/dist/bootstrap.min.css" %}" rel="stylesheet">
|
||||
<link href="{% static "css/fonts.css" %}" rel="stylesheet">
|
||||
<link href="{% static "css/main.css" %}" rel="stylesheet">
|
||||
{% if site_conf.common_css %}<link rel="stylesheet" href="{{ site_conf.common_css.url }}">{% endif %}
|
||||
</head>
|
||||
|
||||
<body class="bg-dark">
|
||||
<div class="container-fluid h-100 d-flex flex-column">
|
||||
<header>
|
||||
{% include 'navbar.html' %}
|
||||
<div class="row collapse bg-dark shadow-sm" id="navbarHeader">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-8 col-md-7 py-4">
|
||||
{% if site_conf.about %}<h4 class="text-white">About</h4>
|
||||
<p class="text-muted">{{ site_conf.about | safe }}</p>{% endif %}
|
||||
{% breadcrumbs page.path %}
|
||||
</div>
|
||||
<div class="col-sm-4 offset-md-1 py-4 text-right">
|
||||
{% if request.user.is_staff %}<div class="dropdown btn-group">
|
||||
<button class="btn btn-sm btn-outline-danger dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Edit
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="{% url 'admin:portal_flatpage_change' page.pk %}">Edit page</a>
|
||||
<a class="dropdown-item" href="{% url 'admin:portal_flatpage_history' page.pk %}">History</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="{% url 'admin:portal_flatpage_delete' page.pk %}">Delete</a>
|
||||
</div>
|
||||
</div>{% endif %}
|
||||
{% include 'login.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
<main>
|
||||
<div class="album py-5 bg-white">
|
||||
<div class="container">
|
||||
{{ content }}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="{% static "js/dist/jquery.min.js" %}"></script>
|
||||
<script src="{% static "js/dist/bootstrap.bundle.min.js" %}"></script>
|
||||
</body>
|
||||
</html>
|
20
ram/portal/templates/footer.html
Normal file
20
ram/portal/templates/footer.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% load markdown %}
|
||||
|
||||
<footer class="text-muted py-5">
|
||||
<div class="container">
|
||||
<p class="float-end mb-1">
|
||||
<a href="#">Back to top</a>
|
||||
</p>
|
||||
<div id="footer" class="mb-1">
|
||||
<p>© {% now "Y" %}</p> {{ site_conf.footer | markdown | safe }}
|
||||
</div>
|
||||
<div id="footer_extended" class="mb-0">
|
||||
{{ site_conf.footer_extended | markdown | safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% if site_conf.show_version %}
|
||||
<div class="container">
|
||||
<p class="small text-muted">Version: {{ site_conf.version }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</footer>
|
216
ram/portal/templates/home.html
Normal file
216
ram/portal/templates/home.html
Normal file
@@ -0,0 +1,216 @@
|
||||
{% load static %}
|
||||
{% load solo_tags %}
|
||||
{% load markdown %}
|
||||
{% get_solo 'portal.SiteConfiguration' as site_conf %}
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
|
||||
<meta name="generator" content="Hugo 0.88.1">
|
||||
<title>{{ site_conf.site_name }}</title>
|
||||
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/album/">
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="{% static "css/main.css" %}" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.bd-placeholder-img {
|
||||
font-size: 1.125rem;
|
||||
text-anchor: middle;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.bd-placeholder-img-lg {
|
||||
font-size: 3.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class="navbar navbar-dark bg-dark shadow-sm">
|
||||
<div class="container">
|
||||
<a href="#" class="navbar-brand d-flex align-items-center">
|
||||
<svg class="me-2" width="26" height="16" enable-background="new 0 0 26 26" version="1" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m2.8125 0.0010991a1.0001 1.0001 0 0 0-0.8125 1c0 0.55455-0.44545 1-1 1a1.0001 1.0001 0 0 0-1 1v10a1.0001 1.0001 0 0 0 1 1c0.55455 0 1 0.44546 1 1a1.0001 1.0001 0 0 0 1 1h20a1.0001 1.0001 0 0 0 1-1c0-0.55454 0.44546-1 1-1a1.0001 1.0001 0 0 0 1-1v-10a1.0001 1.0001 0 0 0-1-1c-0.55454 0-1-0.44545-1-1a1.0001 1.0001 0 0 0-1-1h-20a1.0001 1.0001 0 0 0-0.09375 0 1.0001 1.0001 0 0 0-0.09375 0zm0.78125 2h14.406v1h2v-1h2.4062c0.30628 0.76906 0.82469 1.2875 1.5938 1.5938v8.8125c-0.76906 0.30628-1.2875 0.82469-1.5938 1.5938h-2.4062v-1h-2v1h-14.406c-0.30628-0.76906-0.82469-1.2875-1.5938-1.5938v-8.8125c0.76906-0.30628 1.2875-0.82469 1.5938-1.5938zm14.406 2v2h2v-2zm0 3v2h2v-2zm0 3v2h2v-2z" enable-background="accumulate" fill="#fff" overflow="visible" stroke-width="2" style="text-indent:0;text-transform:none"/>
|
||||
</svg>
|
||||
<strong>{{ site_conf.site_name }}</strong>
|
||||
</a>
|
||||
{% include 'login.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section class="py-1 text-start container">
|
||||
<div class="row py-lg-5">
|
||||
<div class="mx-auto">
|
||||
<h1 class="fw-light">About</h1>
|
||||
<p class="lead text-muted">{{ site_conf.about | markdown | safe }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="album py-5 bg-light">
|
||||
<div class="container">
|
||||
<a id="rolling-stock"></a>
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
|
||||
{% for r in rolling_stock %}
|
||||
<div class="col">
|
||||
<div class="card shadow-sm">
|
||||
<a href="#">
|
||||
{% for t in r.thumbnail.all %}{% if t.is_thumbnail %}<img src="{{ t.image.url }}" alt="Card image cap">
|
||||
{% else %}
|
||||
<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Missing thumbnail</text></svg>
|
||||
{% endif %}</a>{% endfor %}
|
||||
<div class="card-body">
|
||||
<p class="card-text"><strong>{{ r }}</strong></p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Type</th>
|
||||
<td>{{ r.rolling_class.type }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Company</th>
|
||||
<td>{{ r.rolling_class.company }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Class</th>
|
||||
<td>{{ r.rolling_class.identifier }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Road number</th>
|
||||
<td>{{ r.road_number }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Era</th>
|
||||
<td>{{ r.era }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="btn-group mb-4">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" data-bs-toggle="button"><span data-bs-toggle="collapse" data-bs-target="#collapseModel{{ r.pk }}" aria-expanded="false" aria-controls="collapseModel{{ r.pk }}">Model data</span></button>
|
||||
{% if r.decoder %}
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" data-bs-toggle="button"> <span data-bs-toggle="collapse" data-bs-target="#collapseDCC{{ r.pk }}" aria-expanded="false" aria-controls="collapseDCC{{ r.pk }}">DCC data</span></button>
|
||||
{% endif %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="#">Show all data</a>
|
||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:roster_rollingstock_change' r.pk %}">Edit</a>{% endif %}
|
||||
</div>
|
||||
<div class="collapse" id="collapseModel{{ r.pk }}">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">Model data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Manufacturer</th>
|
||||
<td>{{ r.manufacturer }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Scale</th>
|
||||
<td>{{ r.scale }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SKU</th>
|
||||
<td>{{ r.sku }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% if r.decoder %}
|
||||
<div class="collapse" id="collapseDCC{{ r.pk }}">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" scope="row">DCC data</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th width="35%" scope="row">Decoder</th>
|
||||
<td>{{ r.decoder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Address</th>
|
||||
<td>{{ r.address }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if r.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</p>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<small class="text-muted">Updated {{ r.updated_time | date:"M d, Y H:m" }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
{% if rolling_stock.has_other_pages %}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center mt-4">
|
||||
{% if rolling_stock.has_previous %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="/page/{{ rolling_stock.previous_page_number }}#rolling_stock" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Previous</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in rolling_stock.paginator.page_range %}
|
||||
{% if rolling_stock.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }}</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item"><a class="page-link" href="/page/{{ i }}#rolling-stock">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if rolling_stock.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="/page/{{ rolling_stock.next_page_number }}#rolling-stock" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Next</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{% include 'footer.html' %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
20
ram/portal/templates/login.html
Normal file
20
ram/portal/templates/login.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% if request.user.is_staff %}
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-outline-light dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Welcome back, <strong>{{ request.user }}</strong>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenu2">
|
||||
<li><a class="dropdown-item" href="{% url 'admin:roster_rollingstock_changelist' %}">Rolling stock</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:consist_consist_changelist' %}">Consists</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'admin:app_list' 'metadata' %}">Metadata</a></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: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>
|
||||
</div>
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-outline-light" href="{% url 'admin:login' %}?next={{ request.path }}">Log in</a>
|
||||
{% endif %}
|
0
ram/portal/templatetags/__init__.py
Normal file
0
ram/portal/templatetags/__init__.py
Normal file
12
ram/portal/templatetags/markdown.py
Normal file
12
ram/portal/templatetags/markdown.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django import template
|
||||
from django.template.defaultfilters import stringfilter
|
||||
|
||||
import markdown as md
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
@stringfilter
|
||||
def markdown(value):
|
||||
return md.markdown(value, extensions=['markdown.extensions.fenced_code'])
|
3
ram/portal/tests.py
Normal file
3
ram/portal/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
ram/portal/urls.py
Normal file
7
ram/portal/urls.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from portal.views import GetHome
|
||||
|
||||
urlpatterns = [
|
||||
path("<int:page>", GetHome.as_view(), name='index_pagination'),
|
||||
]
|
6
ram/portal/utils.py
Normal file
6
ram/portal/utils.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
def get_site_conf():
|
||||
SiteConfiguration = apps.get_model('portal', 'SiteConfiguration')
|
||||
return SiteConfiguration.get_solo()
|
26
ram/portal/views.py
Normal file
26
ram/portal/views.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from django.views import View
|
||||
from django.shortcuts import render
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from portal.utils import get_site_conf
|
||||
from roster.models import RollingStock, RollingStockImage
|
||||
|
||||
|
||||
class GetHome(View):
|
||||
def get(self, request, page=1):
|
||||
site_conf = get_site_conf()
|
||||
rolling_stock = RollingStock.objects.all()
|
||||
thumbnails = RollingStockImage.objects.filter(is_thumbnail=True)
|
||||
paginator = Paginator(rolling_stock, site_conf.items_per_page)
|
||||
|
||||
try:
|
||||
rolling_stock = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
rolling_stock = paginator.page(1)
|
||||
except EmptyPage:
|
||||
rolling_stock = paginator.page(paginator.num_pages)
|
||||
|
||||
return render(request, 'home.html', {
|
||||
'rolling_stock': rolling_stock,
|
||||
'thumbnails': thumbnails
|
||||
})
|
Reference in New Issue
Block a user