2019-01-19 22:39:48 +00:00
|
|
|
from django.shortcuts import redirect, render
|
2018-09-01 19:57:09 +00:00
|
|
|
from django.urls import reverse
|
|
|
|
|
2019-01-19 22:39:48 +00:00
|
|
|
from preferences.models import GeneralPreferences
|
|
|
|
from gestion.models import Keg
|
|
|
|
|
2018-09-01 19:57:09 +00:00
|
|
|
def home(request):
|
2018-10-05 22:03:02 +00:00
|
|
|
if request.user.is_authenticated:
|
2018-09-01 19:57:09 +00:00
|
|
|
if(request.user.has_perm('gestion.can_manage')):
|
|
|
|
return redirect(reverse('gestion:manage'))
|
|
|
|
else:
|
2019-01-19 22:39:48 +00:00
|
|
|
return redirect(reverse('homepage'))
|
2018-09-01 19:57:09 +00:00
|
|
|
else:
|
|
|
|
return redirect(reverse('users:login'))
|
2019-01-19 22:39:48 +00:00
|
|
|
|
|
|
|
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})
|
2019-01-20 08:28:11 +00:00
|
|
|
|
|
|
|
def coope_runner(request):
|
|
|
|
return render(request, "coope-runner.html")
|