Add front page modules
This commit is contained in:
parent
0522d3d3cc
commit
ed057dfa07
@ -115,7 +115,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'Europe/Paris'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
@ -123,6 +123,7 @@ USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
DATE_FORMAT = "B j, Y, H:M"
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
@ -11,3 +11,6 @@ class ApiModuleListTests(TestCase):
|
||||
self.assertEqual(response['content-type'], 'application/json')
|
||||
self.assertJSONEqual(response.content, {'modules': ['module1', 'module2', 'module3']})
|
||||
|
||||
# class ModuleVersionsTests(TestCase):
|
||||
# def setUp(self):
|
||||
# for name in ['module1', 'module2', 'module3']
|
||||
|
@ -1,6 +1,7 @@
|
||||
{% extends 'base/base.html' %}
|
||||
|
||||
{% block body %}
|
||||
{% load l10n %}
|
||||
|
||||
|
||||
<main role="main">
|
||||
@ -24,32 +25,51 @@
|
||||
|
||||
|
||||
<div class="container">
|
||||
<h2>Most downloaded</h2>
|
||||
<div class="row">
|
||||
{% for i in '123'|make_list %}
|
||||
{% for module in most_downloaded %}
|
||||
<div class="col-md-4 my-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<h5 class="card-title">{{ module.name }}</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">Card subtitle - Description</h6>
|
||||
<p class="card-text">Donec id elit non mi porta gravida at eget metus. Fusce dapibus,
|
||||
tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo
|
||||
sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
|
||||
<h6 class="card-subtitle mb-2 text-muted">Downloaded {{ module.downloads }} times<h6>
|
||||
<p class="card-text">
|
||||
{{ module.desc }}
|
||||
</p>
|
||||
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
|
||||
<p><a class="btn btn-secondary" href="{% url 'mod_detail' pk=module.id %}" role="button">View details »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div> <!-- /container -->
|
||||
<div class="container my-5">
|
||||
<h2>Last updates</h2>
|
||||
<div class="row">
|
||||
{% for module in last_updates %}
|
||||
<div class="col-md-4 my-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">{{ module.name }}</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">
|
||||
Last update on
|
||||
{{ module.updated_at }}
|
||||
<h6>
|
||||
<p class="card-text">
|
||||
{{ module.desc }}
|
||||
</p>
|
||||
<p><a class="btn btn-secondary" href="{% url 'mod_detail' pk=module.id %}" role="button">View details »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
||||
</main>
|
||||
|
||||
<script>window.jQuery || document.write('<script src="/docs/4.3/assets/js/vendor/jquery-slim.min.js"><\/script>')
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -14,8 +14,8 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path, include
|
||||
from django.views.generic import TemplateView
|
||||
from .views import FrontPageView
|
||||
|
||||
urlpatterns = [
|
||||
path('', TemplateView.as_view(template_name="front/index.html"), name='front_page')
|
||||
path('', FrontPageView.as_view(), name='front_page'),
|
||||
]
|
||||
|
@ -1,3 +1,18 @@
|
||||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
from store.models import Module
|
||||
|
||||
# Create your views here.
|
||||
class FrontPageView(View):
|
||||
"""
|
||||
FrontPageView : a PDMI-presenting page, showing most downloaded modules and
|
||||
most recent modules (most liked modules in the future)
|
||||
"""
|
||||
def get(self, request):
|
||||
most_downloaded = Module.objects.all().order_by('-downloads')[0:3]
|
||||
last_updates = Module.objects.all().order_by('-updated_at')[0:3]
|
||||
|
||||
return render(request, 'front/index.html',
|
||||
{
|
||||
'most_downloaded': most_downloaded,
|
||||
'last_updates': last_updates,
|
||||
})
|
||||
|
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
</nav>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
{% endblock body %}
|
||||
{% include "base/legal.html" %}
|
||||
<script src="https://code.jquery.com/jquery-3.5.0.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>
|
||||
<script src="{% static 'js/jquery.bootstrap.modal.forms.min.js' %}"></script>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<footer class="container">
|
||||
<hr>
|
||||
<p>© Louis Chauvet 2019</p>
|
||||
</footer>
|
||||
|
Loading…
Reference in New Issue
Block a user