[svn r8175]

This commit is contained in:
aaron 2009-01-18 05:42:54 +01:00
parent c72fa16090
commit 0fe420d711
3 changed files with 56 additions and 32 deletions

View File

@ -18,6 +18,12 @@ class SurveyAdmin(admin.ModelAdmin):
class LogbookEntryAdmin(admin.ModelAdmin):
search_fields = ('title',)
class PersonAdmin(admin.ModelAdmin):
search_fields = ('first_name','last_name')
class PersonExpeditionAdmin(admin.ModelAdmin):
search_fields = ('person__first_name',)
admin.site.register(Photo)
admin.site.register(Cave)
admin.site.register(Area)
@ -27,9 +33,9 @@ admin.site.register(SurveyStation)
admin.site.register(Entrance)
admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition)
admin.site.register(Person)
admin.site.register(Person,PersonAdmin)
admin.site.register(PersonRole)
admin.site.register(PersonExpedition)
admin.site.register(PersonExpedition,PersonExpeditionAdmin)
admin.site.register(Role)
admin.site.register(LogbookEntry, LogbookEntryAdmin)
admin.site.register(PersonTrip)

View File

@ -19,12 +19,13 @@ class Expedition(models.Model):
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
if self.start_date and self.end_date:
res=[]
date=self.start_date
while date <= self.end_date:
res.append(date)
date+=datetime.timedelta(days=1)
return res
def GetPersonExpedition(self, name):
person_expeditions = PersonExpedition.objects.filter(expedition=self)
@ -67,6 +68,22 @@ class PersonExpedition(models.Model):
res.append(self.nickname)
return res
def ListDays(self):
if self.from_date and self.to_date:
res=[]
date=self.from_date
while date <= self.to_date:
res.append(date)
date+=datetime.timedelta(days=1)
return res
def ListDaysTF(self):
if self.from_date and self.to_date:
res=[]
for date in self.expedition.ListDays():
res.append(date in self.ListDays())
return res
def __unicode__(self):
return "%s: (%s)" % (self.person, self.expedition)

View File

@ -12,25 +12,9 @@
{% 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% }
td.yes { background: #7f96e8; width: 80pt; font-size: 10pt }
td.no { background: #ff6666; width: 80pt; font-size: 10pt }
td.name { background: #7f96e8; width: 80pt; text-align:right; font-size: 10pt }
-->
</style>
@ -39,7 +23,7 @@ body { margin-left: 5%; margin-right: 5% }
{% block content %}
{% if expedition %}
<table>
<tr>
<tr><td />
{% for date in expedition.ListDays %}
{% ifchanged date.month %}
<td class="h">{{ date|date:"F" }}</td>
@ -47,15 +31,32 @@ body { margin-left: 5%; margin-right: 5% }
<td class="h"></td>
{% endifchanged %}
{% endfor %}
<tr>
</tr>
<tr><td />
{% for date in expedition.ListDays %}
<td class="h">{{ date|date:"D" }}</td>
{% endfor %}
<tr>
<tr>
</tr>
<tr><td />
{% for date in expedition.ListDays %}
<td class="h">{{ date|date:"d" }}</td>
{% endfor %}
<tr>
</tr>
{% for personexpedition in expedition.personexpedition_set.all %}
<tr>
<td class="name">
{{ personexpedition.person }}
</td>
{% for dateTF in personexpedition.ListDaysTF %}
<td {{ dateTF|yesno:"class='yes',class='no'"|safe }}></td>
{% empty %}
<td colspan="{{ expedition.ListDays|length }}">No data yet.</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}