mirror of
https://github.com/nanoy42/coope
synced 2024-12-24 16:03:47 +00:00
Page d'accueil
This commit is contained in:
parent
bb5e2258f6
commit
8265a7535b
8 changed files with 83 additions and 4 deletions
|
@ -20,6 +20,7 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.home, name="home"),
|
path('', views.home, name="home"),
|
||||||
|
path('home', views.homepage, name="homepage"),
|
||||||
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('users/', include('users.urls')),
|
path('users/', include('users.urls')),
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from preferences.models import GeneralPreferences
|
||||||
|
from gestion.models import Keg
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
if(request.user.has_perm('gestion.can_manage')):
|
if(request.user.has_perm('gestion.can_manage')):
|
||||||
return redirect(reverse('gestion:manage'))
|
return redirect(reverse('gestion:manage'))
|
||||||
else:
|
else:
|
||||||
return redirect(reverse('users:profile', kwargs={'pk': request.user.pk}))
|
return redirect(reverse('homepage'))
|
||||||
else:
|
else:
|
||||||
return redirect(reverse('users:login'))
|
return redirect(reverse('users:login'))
|
||||||
|
|
||||||
|
def homepage(request):
|
||||||
|
gp, _ = GeneralPreferences.objects.get_or_create(pk=1)
|
||||||
|
kegs = Keg.objects.filter(is_active=True)
|
||||||
|
return render(request, "home.html", {"home_text": gp.home_text, "kegs": kegs})
|
||||||
|
|
|
@ -36,5 +36,6 @@ class GeneralPreferencesForm(forms.ModelForm):
|
||||||
'treasurer': forms.TextInput(attrs={'placeholder': 'Trésorier'}),
|
'treasurer': forms.TextInput(attrs={'placeholder': 'Trésorier'}),
|
||||||
'brewer': forms.TextInput(attrs={'placeholder': 'Maître brasseur'}),
|
'brewer': forms.TextInput(attrs={'placeholder': 'Maître brasseur'}),
|
||||||
'grocer': forms.TextInput(attrs={'placeholder': 'Epic épicier'}),
|
'grocer': forms.TextInput(attrs={'placeholder': 'Epic épicier'}),
|
||||||
|
'home_text': forms.Textarea(attrs={'placeholder': 'Ce message sera affiché sur la page d\'accueil'})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
preferences/migrations/0006_auto_20190119_2326.py
Normal file
23
preferences/migrations/0006_auto_20190119_2326.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 2.1 on 2019-01-19 22:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0005_auto_20190106_0513'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generalpreferences',
|
||||||
|
name='home_text',
|
||||||
|
field=models.TextField(blank=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='historicalgeneralpreferences',
|
||||||
|
name='home_text',
|
||||||
|
field=models.TextField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -34,6 +34,7 @@ class GeneralPreferences(models.Model):
|
||||||
use_pinte_monitoring = models.BooleanField(default=False)
|
use_pinte_monitoring = models.BooleanField(default=False)
|
||||||
lost_pintes_allowed = models.PositiveIntegerField(default=0)
|
lost_pintes_allowed = models.PositiveIntegerField(default=0)
|
||||||
floating_buttons = models.BooleanField(default=False)
|
floating_buttons = models.BooleanField(default=False)
|
||||||
|
home_text = models.TextField(blank=True)
|
||||||
history = HistoricalRecords()
|
history = HistoricalRecords()
|
||||||
|
|
||||||
class Cotisation(models.Model):
|
class Cotisation(models.Model):
|
||||||
|
|
|
@ -127,12 +127,21 @@
|
||||||
<header class="major">
|
<header class="major">
|
||||||
<h2>Autre</h2>
|
<h2>Autre</h2>
|
||||||
</header>
|
</header>
|
||||||
|
<br>
|
||||||
|
<h3>Boutons flottants</h3>
|
||||||
<div class="row uniform">
|
<div class="row uniform">
|
||||||
<div class="12u">
|
<div class="12u">
|
||||||
{{form.floating_buttons}}
|
{{form.floating_buttons}}
|
||||||
<label for="{{form.floating_buttons.id_for_label}}">Utiliser les boutons de paiement flottants ?</label>
|
<label for="{{form.floating_buttons.id_for_label}}">Utiliser les boutons de paiement flottants ?</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
|
<h3>Texte de la page d'accueil</h3>
|
||||||
|
<div class="row uniform">
|
||||||
|
<div class="12u">
|
||||||
|
{{form.home_text}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row uniform">
|
<div class="row uniform">
|
||||||
<div class="12u">
|
<div class="12u">
|
||||||
<button type="submit"><i class="fa fa-save"></i> Enregistrer</button>
|
<button type="submit"><i class="fa fa-save"></i> Enregistrer</button>
|
||||||
|
|
31
templates/home.html
Normal file
31
templates/home.html
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block entete %}Accueil{% endblock %}
|
||||||
|
{% block navbar %}
|
||||||
|
<ul>
|
||||||
|
<li><a href="#first">Accueil</a></li>
|
||||||
|
<li><a href="#second">Les pressions du moment</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<section id="first" class="main">
|
||||||
|
<header class="major">
|
||||||
|
<h2>Accueil</h2>
|
||||||
|
</header>
|
||||||
|
<section>
|
||||||
|
{{ home_text }}
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
<section id="second" class="main">
|
||||||
|
<header class="major">
|
||||||
|
<h2>Les pressions du moment</h2>
|
||||||
|
</header>
|
||||||
|
<section>
|
||||||
|
Les bières pressions actuellement en Coopé :
|
||||||
|
<ul>
|
||||||
|
{% for keg in kegs %}
|
||||||
|
<li>{{keg}} ({% if keg.pinte %} Pinte : {{keg.pinte.amount}}€,{% endif %}{% if keg.demi %} Demi : {{keg.demi.amount}}€,{% endif %}{% if keg.galopin %} Galopin : {{keg.galopin.amount}}€{% endif %})</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
|
@ -1,3 +1,6 @@
|
||||||
|
<span class="tabulation2">
|
||||||
|
<i class="fa fa-home"></i> <a href="{% url 'homepage' %}">Accueil</a>
|
||||||
|
</span>
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<span class="tabulation2">
|
<span class="tabulation2">
|
||||||
<i class="fa fa-user"></i> <a href="{% url 'users:profile' request.user.pk %}">Mon profil</a>
|
<i class="fa fa-user"></i> <a href="{% url 'users:profile' request.user.pk %}">Mon profil</a>
|
||||||
|
@ -18,11 +21,11 @@
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="tabulation2">
|
<span class="tabulation2">
|
||||||
|
<br>
|
||||||
<i class="fa fa-list-ol"></i> <a href="{% url 'gestion:ranking' %}">Classement</a>
|
<i class="fa fa-list-ol"></i> <a href="{% url 'gestion:ranking' %}">Classement</a>
|
||||||
</span>
|
</span>
|
||||||
{% if perms.preferences.change_generalpreferences %}
|
{% if perms.preferences.change_generalpreferences %}
|
||||||
<span class="tabulation2">
|
<span class="tabulation2">
|
||||||
<br>
|
|
||||||
<i class="fa fa-tools"></i> <a href="{% url 'preferences:generalPreferences' %}">Admin</a>
|
<i class="fa fa-tools"></i> <a href="{% url 'preferences:generalPreferences' %}">Admin</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -45,5 +48,7 @@
|
||||||
<i class="fa fa-bed"></i> <a href="{% url 'users:logout' %}">Deconnexion</a>
|
<i class="fa fa-bed"></i> <a href="{% url 'users:logout' %}">Deconnexion</a>
|
||||||
</span>
|
</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="fa fa-sign-in-alt"></i> <a href="{% url 'users:login' %}">Connexion</a>
|
<span class="tabulation2">
|
||||||
|
<i class="fa fa-sign-in-alt"></i> <a href="{% url 'users:login' %}">Connexion</a>
|
||||||
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue