feat: Add homepage app
This commit is contained in:
parent
4ba636a9d3
commit
28567f31ca
13 changed files with 117 additions and 0 deletions
|
@ -33,6 +33,7 @@ ALLOWED_HOSTS = []
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'tea.apps.TeaConfig',
|
'tea.apps.TeaConfig',
|
||||||
'wine.apps.WineConfig',
|
'wine.apps.WineConfig',
|
||||||
|
'homepage.apps.HomepageConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
|
|
|
@ -18,6 +18,7 @@ from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('', include('homepage.urls')),
|
||||||
path('tea/', include('tea.urls')),
|
path('tea/', include('tea.urls')),
|
||||||
path('wine/', include('wine.urls')),
|
path('wine/', include('wine.urls')),
|
||||||
]
|
]
|
||||||
|
|
0
homepage/__init__.py
Normal file
0
homepage/__init__.py
Normal file
6
homepage/admin.py
Normal file
6
homepage/admin.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
|
||||||
|
from .models import Application
|
||||||
|
|
||||||
|
admin.site.register(Application)
|
6
homepage/apps.py
Normal file
6
homepage/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class HomepageConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'homepage'
|
22
homepage/migrations/0001_initial.py
Normal file
22
homepage/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 4.0.2 on 2022-03-06 09:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Application',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('url', models.CharField(max_length=20)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
0
homepage/migrations/__init__.py
Normal file
0
homepage/migrations/__init__.py
Normal file
9
homepage/models.py
Normal file
9
homepage/models.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Application(models.Model):
|
||||||
|
name = models.CharField(max_length=200)
|
||||||
|
url = models.CharField(max_length=20)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
40
homepage/templates/homepage/base.html
Normal file
40
homepage/templates/homepage/base.html
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
|
<title>Django StockPile</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<a class="navbar-brand" href="/">Django StockPile</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav mr-auto">
|
||||||
|
<li class="nav-item active">
|
||||||
|
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/tea">Thés</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/wine">Vins</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-8">
|
||||||
|
<hr class="mt-0 mb-4">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
homepage/templates/homepage/index.html
Normal file
7
homepage/templates/homepage/index.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends 'homepage/base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% for application in application_list %}
|
||||||
|
<h2><a href='{{ application.url }}'>{{ application.name }}</a></h2>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
3
homepage/tests.py
Normal file
3
homepage/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
8
homepage/urls.py
Normal file
8
homepage/urls.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'homepage'
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.IndexView.as_view(), name='index'),
|
||||||
|
]
|
14
homepage/views.py
Normal file
14
homepage/views.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from django.db.models import F
|
||||||
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
|
from django.shortcuts import render, get_object_or_404
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.views import generic
|
||||||
|
|
||||||
|
from .models import Application
|
||||||
|
|
||||||
|
class IndexView(generic.ListView):
|
||||||
|
model = Application
|
||||||
|
template_name = 'homepage/index.html'
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return Application.objects.order_by('name')
|
Reference in a new issue