Skip to content
Snippets Groups Projects
views.py 1.54 KiB
Newer Older
Dorian Lesbre's avatar
Dorian Lesbre committed
from django.contrib.sitemaps import Sitemap
Dorian Lesbre's avatar
Dorian Lesbre committed
from django.shortcuts import redirect, render
Dorian Lesbre's avatar
Dorian Lesbre committed
from django.urls import reverse
from django.views.generic import TemplateView
Dorian Lesbre's avatar
Dorian Lesbre committed

Dorian Lesbre's avatar
Dorian Lesbre committed
from home.models import InterludesActivity


class HomeView(TemplateView):
	"""Vue pour la page d'acceuil"""
	template_name = "home.html"


class ActivityView(TemplateView):
	"""Vue pour la liste des activités"""
	template_name = "activites.html"

	def get_context_data(self, **kwargs):
		"""ajoute la liste des activités au contexte"""
		context = super(ActivityView, self).get_context_data(**kwargs)
		context['activities'] = InterludesActivity.objects.filter(display=True).order_by("title")
		return context


class FAQView(TemplateView):
	"""Vue pour la FAQ"""
	template_name = "faq.html"

Dorian Lesbre's avatar
Dorian Lesbre committed

Dorian Lesbre's avatar
Dorian Lesbre committed
def sign_up(request):
	"""Page d'inscription"""
	if not settings.REGISTRATION_EVENT_INSCRIPTIONS_OPEN:
Dorian Lesbre's avatar
Dorian Lesbre committed
		return static_view(request, "inscription/closed.html")
	if not request.user.is_authenticated:
		return static_view(request, "inscription/signin.html")
	# TODO : actual inscription form
Dorian Lesbre's avatar
Dorian Lesbre committed
class StaticViewSitemap(Sitemap):
Dorian Lesbre's avatar
Dorian Lesbre committed
	"""Vue générant la sitemap.xml du site"""
Dorian Lesbre's avatar
Dorian Lesbre committed
	changefreq = 'monthly'

	def items(self):
Dorian Lesbre's avatar
Dorian Lesbre committed
		"""list of pages to appear in sitemap"""
Dorian Lesbre's avatar
Dorian Lesbre committed
		return ["home", "inscription", "activites", "FAQ"]

	def location(self, item):
Dorian Lesbre's avatar
Dorian Lesbre committed
		"""real url of an item"""
Dorian Lesbre's avatar
Dorian Lesbre committed
		return reverse(item)

	def priority(self, obj):
Dorian Lesbre's avatar
Dorian Lesbre committed
		"""priority to appear in sitemap"""
Dorian Lesbre's avatar
Dorian Lesbre committed
		# Priorize home page over the rest in search results
		if obj == "home" or obj == "":
				return 0.8
		else:
Dorian Lesbre's avatar
Dorian Lesbre committed
			return None # defaults to 0.5 when unset