[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): class LogbookEntryAdmin(admin.ModelAdmin):
search_fields = ('title',) 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(Photo)
admin.site.register(Cave) admin.site.register(Cave)
admin.site.register(Area) admin.site.register(Area)
@ -27,9 +33,9 @@ admin.site.register(SurveyStation)
admin.site.register(Entrance) admin.site.register(Entrance)
admin.site.register(SurvexBlock, SurvexBlockAdmin) admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition) admin.site.register(Expedition)
admin.site.register(Person) admin.site.register(Person,PersonAdmin)
admin.site.register(PersonRole) admin.site.register(PersonRole)
admin.site.register(PersonExpedition) admin.site.register(PersonExpedition,PersonExpeditionAdmin)
admin.site.register(Role) admin.site.register(Role)
admin.site.register(LogbookEntry, LogbookEntryAdmin) admin.site.register(LogbookEntry, LogbookEntryAdmin)
admin.site.register(PersonTrip) admin.site.register(PersonTrip)

View File

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

View File

@ -12,25 +12,9 @@
{% block javascript %} {% block javascript %}
<style type="text/css"> <style type="text/css">
<!-- <!--
td.f { background: #7f96e8; width: 80pt; font-size: 10pt } td.yes { background: #7f96e8; width: 80pt; font-size: 10pt }
td.ff { background: #ff6666; width: 80pt; font-size: 10pt } td.no { background: #ff6666; width: 80pt; font-size: 10pt }
td.fe { background: #7f96e8; width: 80pt; text-align:right; font-size: 10pt } td.name { 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> </style>
@ -39,7 +23,7 @@ body { margin-left: 5%; margin-right: 5% }
{% block content %} {% block content %}
{% if expedition %} {% if expedition %}
<table> <table>
<tr> <tr><td />
{% for date in expedition.ListDays %} {% for date in expedition.ListDays %}
{% ifchanged date.month %} {% ifchanged date.month %}
<td class="h">{{ date|date:"F" }}</td> <td class="h">{{ date|date:"F" }}</td>
@ -47,15 +31,32 @@ body { margin-left: 5%; margin-right: 5% }
<td class="h"></td> <td class="h"></td>
{% endifchanged %} {% endifchanged %}
{% endfor %} {% endfor %}
<tr> </tr>
<tr><td />
{% for date in expedition.ListDays %} {% for date in expedition.ListDays %}
<td class="h">{{ date|date:"D" }}</td> <td class="h">{{ date|date:"D" }}</td>
{% endfor %} {% endfor %}
<tr> </tr>
<tr> <tr><td />
{% for date in expedition.ListDays %} {% for date in expedition.ListDays %}
<td class="h">{{ date|date:"d" }}</td> <td class="h">{{ date|date:"d" }}</td>
{% endfor %} {% endfor %}
</tr>
{% for personexpedition in expedition.personexpedition_set.all %}
<tr> <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 %} {% endif %}
{% endblock %} {% endblock %}