mirror of
https://github.com/nanoy42/coope
synced 2024-11-25 04:43:11 +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 = [
|
||||
path('', views.home, name="home"),
|
||||
path('home', views.homepage, name="homepage"),
|
||||
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
path('admin/', admin.site.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 preferences.models import GeneralPreferences
|
||||
from gestion.models import Keg
|
||||
|
||||
def home(request):
|
||||
if request.user.is_authenticated:
|
||||
if(request.user.has_perm('gestion.can_manage')):
|
||||
return redirect(reverse('gestion:manage'))
|
||||
else:
|
||||
return redirect(reverse('users:profile', kwargs={'pk': request.user.pk}))
|
||||
return redirect(reverse('homepage'))
|
||||
else:
|
||||
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'}),
|
||||
'brewer': forms.TextInput(attrs={'placeholder': 'Maître brasseur'}),
|
||||
'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)
|
||||
lost_pintes_allowed = models.PositiveIntegerField(default=0)
|
||||
floating_buttons = models.BooleanField(default=False)
|
||||
home_text = models.TextField(blank=True)
|
||||
history = HistoricalRecords()
|
||||
|
||||
class Cotisation(models.Model):
|
||||
|
|
|
@ -127,12 +127,21 @@
|
|||
<header class="major">
|
||||
<h2>Autre</h2>
|
||||
</header>
|
||||
<br>
|
||||
<h3>Boutons flottants</h3>
|
||||
<div class="row uniform">
|
||||
<div class="12u">
|
||||
{{form.floating_buttons}}
|
||||
<label for="{{form.floating_buttons.id_for_label}}">Utiliser les boutons de paiement flottants ?</label>
|
||||
</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="12u">
|
||||
<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 %}
|
||||
<span class="tabulation2">
|
||||
<i class="fa fa-user"></i> <a href="{% url 'users:profile' request.user.pk %}">Mon profil</a>
|
||||
|
@ -18,11 +21,11 @@
|
|||
</span>
|
||||
{% endif %}
|
||||
<span class="tabulation2">
|
||||
<br>
|
||||
<i class="fa fa-list-ol"></i> <a href="{% url 'gestion:ranking' %}">Classement</a>
|
||||
</span>
|
||||
{% if perms.preferences.change_generalpreferences %}
|
||||
<span class="tabulation2">
|
||||
<br>
|
||||
<i class="fa fa-tools"></i> <a href="{% url 'preferences:generalPreferences' %}">Admin</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
@ -45,5 +48,7 @@
|
|||
<i class="fa fa-bed"></i> <a href="{% url 'users:logout' %}">Deconnexion</a>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="tabulation2">
|
||||
<i class="fa fa-sign-in-alt"></i> <a href="{% url 'users:login' %}">Connexion</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue