diff --git a/troggle/expo/models.py b/troggle/expo/models.py index 4bbf4216b..e6ab637d4 100644 --- a/troggle/expo/models.py +++ b/troggle/expo/models.py @@ -6,6 +6,7 @@ from django.contrib import admin from django.core.files.storage import FileSystemStorage import os import troggle.settings as settings +import datetime from models_survex import * class Expedition(models.Model): @@ -17,6 +18,14 @@ class Expedition(models.Model): def __unicode__(self): return self.year + def ListDays(self): + dates=[] + date=self.start_date + while date <= self.end_date: + dates.append(date) + date+=datetime.timedelta(days=1) + return dates + def GetPersonExpedition(self, name): person_expeditions = PersonExpedition.objects.filter(expedition=self) res = None diff --git a/troggle/expo/views_other.py b/troggle/expo/views_other.py index 88a855912..771816a0b 100644 --- a/troggle/expo/views_other.py +++ b/troggle/expo/views_other.py @@ -1,5 +1,5 @@ from django.shortcuts import render_to_response -from troggle.expo.models import Cave, Expedition, Person, LogbookEntry +from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition import troggle.settings as settings from django import forms from django.db.models import Q @@ -16,4 +16,15 @@ def stats(request): def frontPage(request): - return render_to_response('index.html', {'randSent':randSent.randomLogbookSentence(),'settings':settings}) \ No newline at end of file + return render_to_response('index.html', {'randSent':randSent.randomLogbookSentence(),'settings':settings}) + +def calendar(request,year): + week=['S','S','M','T','W','T','F'] + if year: + expedition=Expedition.objects.get(year=year) + PersonExpeditions=expedition.personexpedition_set.all() + + dictToPass=locals() + dictToPass.update({'settings':settings}) + return render_to_response('calendar.html', dictToPass) + \ No newline at end of file diff --git a/troggle/templates/calendar.html b/troggle/templates/calendar.html new file mode 100644 index 000000000..559ef798a --- /dev/null +++ b/troggle/templates/calendar.html @@ -0,0 +1,61 @@ +{% extends "base.html" %} + +{% block title %} + CUCC expedition calendar: + {% if expedition %} + {{ expedition.year }} + {% else %} + choose a year + {% endif %} +{% endblock %} + +{% block javascript %} + + +{% endblock %} + +{% block content %} + {% if expedition %} + + + {% for date in expedition.ListDays %} + {% ifchanged date.month %} + + {% else %} + + {% endifchanged %} + {% endfor %} + + {% for date in expedition.ListDays %} + + {% endfor %} + + + {% for date in expedition.ListDays %} + + {% endfor %} + + {% endif %} +{% endblock %} \ No newline at end of file
{{ date|date:"F" }}
{{ date|date:"D" }}
{{ date|date:"d" }}