2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 15:21:52 +00:00

[svn] Beginnings of expo calendar

Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8174 by aaron @ 1/18/2009 1:15 AM
This commit is contained in:
substantialnoninfringinguser 2009-05-13 05:35:11 +01:00
parent b66189bc9e
commit cda0a7a5e1
3 changed files with 83 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from django.contrib import admin
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
import os import os
import troggle.settings as settings import troggle.settings as settings
import datetime
from models_survex import * from models_survex import *
class Expedition(models.Model): class Expedition(models.Model):
@ -17,6 +18,14 @@ class Expedition(models.Model):
def __unicode__(self): def __unicode__(self):
return self.year 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): def GetPersonExpedition(self, name):
person_expeditions = PersonExpedition.objects.filter(expedition=self) person_expeditions = PersonExpedition.objects.filter(expedition=self)
res = None res = None

View File

@ -1,5 +1,5 @@
from django.shortcuts import render_to_response 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 import troggle.settings as settings
from django import forms from django import forms
from django.db.models import Q from django.db.models import Q
@ -17,3 +17,14 @@ def stats(request):
def frontPage(request): def frontPage(request):
return render_to_response('index.html', {'randSent':randSent.randomLogbookSentence(),'settings':settings}) 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)

61
templates/calendar.html Normal file
View File

@ -0,0 +1,61 @@
{% extends "base.html" %}
{% block title %}
CUCC expedition calendar:
{% if expedition %}
{{ expedition.year }}
{% else %}
choose a year
{% endif %}
{% endblock %}
{% block javascript %}
<style type="text/css">
<!--
td.f { background: #7f96e8; width: 80pt; font-size: 10pt }
td.ff { background: #ff6666; width: 80pt; font-size: 10pt }
td.fe { background: #7f96e8; width: 80pt; text-align:right; font-size: 10pt }
td.ffe { background: #ff6666; width: 80pt; text-align:right; font-size: 10pt }
td.e { background: #aaaaaa; width: 80pt; text-align:center; font-size: 10pt }
td.n { width: 120pt }
td.t { font-size: 10pt }
td.week { width: 4pt }
td.h { width: 80pt; font-size: 8pt; text-align: center }
tr.r { height: 40pt }
tr.brk { height: 12pt }
tr.sbrk { height: 2pt }
tr.dblsbrk { height: 4pt }
td.sbrk { background: #dddddd }
td.dblsbrk { background: #dddddd; font-size: 6pt }
span.l { background: #7f96e8 }
span.s { background: #ff6666 }
table.t { background: #dddddd }
body { margin-left: 5%; margin-right: 5% }
-->
</style>
{% endblock %}
{% block content %}
{% if expedition %}
<table>
<tr>
{% for date in expedition.ListDays %}
{% ifchanged date.month %}
<td class="h">{{ date|date:"F" }}</td>
{% else %}
<td class="h"></td>
{% endifchanged %}
{% endfor %}
<tr>
{% for date in expedition.ListDays %}
<td class="h">{{ date|date:"D" }}</td>
{% endfor %}
<tr>
<tr>
{% for date in expedition.ListDays %}
<td class="h">{{ date|date:"d" }}</td>
{% endfor %}
<tr>
{% endif %}
{% endblock %}