Skip to content
Snippets Groups Projects
views.py 794 B
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
Dorian Lesbre's avatar
Dorian Lesbre committed

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

Dorian Lesbre's avatar
Dorian Lesbre committed
def static_view(request, template):
	"""Simple vues statique (rendu html)"""
	activities = InterludesActivity.objects.filter(display=True).order_by("title")
Dorian Lesbre's avatar
Dorian Lesbre committed
	return render(request, template, {'activities': activities})
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):
		return ["home", "inscription", "activites", "FAQ"]

	def location(self, item):
		return reverse(item)

	def priority(self, obj):
		# Priorize home page over the rest in search results
		if obj == "home" or obj == "":
				return 0.8
		else:
			return None # defaults to 0.5 when unset