Merge branch 'master' of gitlab.rezometz.org:klafyvel/site_tps
This commit is contained in:
commit
3bdfeb3e08
15 changed files with 189 additions and 11 deletions
|
@ -1,3 +1,6 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
from .models import Category, Content
|
||||||
|
|
||||||
|
admin.site.register(Category)
|
||||||
|
admin.site.register(Content)
|
||||||
|
|
0
content/templatetags/__init__.py
Normal file
0
content/templatetags/__init__.py
Normal file
15
content/templatetags/categories.py
Normal file
15
content/templatetags/categories.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django import template
|
||||||
|
from content.models import Category
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.tag('load_categories')
|
||||||
|
def load_site_settings(parser, token):
|
||||||
|
return LoadCategoriesNode()
|
||||||
|
|
||||||
|
|
||||||
|
class LoadCategoriesNode(template.Node):
|
||||||
|
def render(self, context):
|
||||||
|
context['categories'] = Category.objects.all()
|
||||||
|
return ''
|
|
@ -1,3 +1,6 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
from .models import SiteSettings, ContentSettings
|
||||||
|
|
||||||
|
admin.site.register(SiteSettings)
|
||||||
|
admin.site.register(ContentSettings)
|
||||||
|
|
31
settings/migrations/0002_auto_20180114_1832.py
Normal file
31
settings/migrations/0002_auto_20180114_1832.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Generated by Django 2.0.1 on 2018-01-14 18:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('settings', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name='allow_upload',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name='site_name',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name="Autoriser l'upload de vidéos.",
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name="Message de la page d'accueil",
|
||||||
|
field=models.TextField(default=''),
|
||||||
|
),
|
||||||
|
]
|
59
settings/migrations/0003_auto_20180114_1837.py
Normal file
59
settings/migrations/0003_auto_20180114_1837.py
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# Generated by Django 2.0.1 on 2018-01-14 18:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import settings.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('settings', '0002_auto_20180114_1832'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='Identifiant sur le FTP',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='Mot de passe',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='URL du FTP',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name="Autoriser l'upload de vidéos.",
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name="Message de la page d'accueil",
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='ftp_id',
|
||||||
|
field=models.CharField(default='', max_length=255, verbose_name='Identifiant sur le FTP'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='ftp_pass',
|
||||||
|
field=settings.models.AESEncryptedField(default='', max_length=255, verbose_name='Mot de passe'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='contentsettings',
|
||||||
|
name='ftp_url',
|
||||||
|
field=models.URLField(default='', max_length=255, verbose_name='URL du FTP'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name='allow_upload',
|
||||||
|
field=models.BooleanField(default=False, verbose_name="Autoriser l'upload de vidéos."),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sitesettings',
|
||||||
|
name='home_message',
|
||||||
|
field=models.TextField(default='', verbose_name="Message de la page d'accueil"),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
import binascii
|
import binascii
|
||||||
import site_tps.qaes
|
from site_tps import qaes
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,23 +17,31 @@ class AESEncryptedField(models.CharField):
|
||||||
class ContentSettings(models.Model):
|
class ContentSettings(models.Model):
|
||||||
ftp_url = models.URLField(
|
ftp_url = models.URLField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
name="URL du FTP",
|
verbose_name="URL du FTP",
|
||||||
|
default="",
|
||||||
)
|
)
|
||||||
ftp_id = models.CharField(
|
ftp_id = models.CharField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
name="Identifiant sur le FTP",
|
verbose_name="Identifiant sur le FTP",
|
||||||
|
default=""
|
||||||
)
|
)
|
||||||
ftp_pass = AESEncryptedField(
|
ftp_pass = AESEncryptedField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
name="Mot de passe"
|
verbose_name="Mot de passe",
|
||||||
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SiteSettings(models.Model):
|
class SiteSettings(models.Model):
|
||||||
allow_upload = models.BooleanField(
|
allow_upload = models.BooleanField(
|
||||||
help_text="Autoriser l'upload de vidéos."
|
verbose_name="Autoriser l'upload de vidéos.",
|
||||||
|
default=False,
|
||||||
)
|
)
|
||||||
site_name = models.CharField(
|
home_message = models.TextField(
|
||||||
max_length=255,
|
verbose_name="Message de la page d'accueil",
|
||||||
help_text="Nom du site",
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_settings(cls):
|
||||||
|
return cls.objects.get_or_create()[0]
|
||||||
|
|
0
settings/templatetags/__init__.py
Normal file
0
settings/templatetags/__init__.py
Normal file
15
settings/templatetags/load_settings.py
Normal file
15
settings/templatetags/load_settings.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django import template
|
||||||
|
from settings.models import SiteSettings
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.tag('load_site_settings')
|
||||||
|
def load_site_settings(parser, token):
|
||||||
|
return LoadSiteSettingsNode()
|
||||||
|
|
||||||
|
|
||||||
|
class LoadSiteSettingsNode(template.Node):
|
||||||
|
def render(self, context):
|
||||||
|
context['site_settings'] = SiteSettings.get_settings()
|
||||||
|
return ''
|
|
@ -56,7 +56,7 @@ ROOT_URLCONF = 'site_tps.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
|
|
@ -16,6 +16,9 @@ Including another URLconf
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('', views.home),
|
||||||
]
|
]
|
||||||
|
|
10
site_tps/views.py
Normal file
10
site_tps/views.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from settings.models import SiteSettings
|
||||||
|
|
||||||
|
|
||||||
|
def home(request):
|
||||||
|
settings, _created = SiteSettings.objects.get_or_create()
|
||||||
|
return render(request, "home.html", {
|
||||||
|
'upload_allowed': settings.allow_upload,
|
||||||
|
'message': settings.home_message,
|
||||||
|
})
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<title>NOM DE SITE</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% include 'nav_bar.html' %}
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
templates/home.html
Normal file
7
templates/home.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends 'base.html'%}
|
||||||
|
{% block content %}
|
||||||
|
<p> {{message|safe}} </p>
|
||||||
|
{% if not upload_allowed %}
|
||||||
|
<p>Les envois de contenu ne sont <em>pas autorisés</em> actuellement.</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
8
templates/nav_bar.html
Normal file
8
templates/nav_bar.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<nav class="navbar navbar-default vbar-fixed-top navbar-inverse">
|
||||||
|
<div class="container">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
|
||||||
|
<li><a href="#">Link</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
Loading…
Reference in a new issue