diff --git a/troggle/expo/admin.py b/troggle/expo/admin.py index 2f7fd4a3c..7c170d9b2 100644 --- a/troggle/expo/admin.py +++ b/troggle/expo/admin.py @@ -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) diff --git a/troggle/expo/models.py b/troggle/expo/models.py index e6ab637d4..26f6f9160 100644 --- a/troggle/expo/models.py +++ b/troggle/expo/models.py @@ -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) diff --git a/troggle/templates/calendar.html b/troggle/templates/calendar.html index 559ef798a..a39556c00 100644 --- a/troggle/templates/calendar.html +++ b/troggle/templates/calendar.html @@ -12,25 +12,9 @@ {% block javascript %} @@ -39,7 +23,7 @@ body { margin-left: 5%; margin-right: 5% } {% block content %} {% if expedition %} - + @@ -47,15 +31,32 @@ body { margin-left: 5%; margin-right: 5% } {% endifchanged %} {% endfor %} - + + {% endfor %} - - + + {% endfor %} - + + + {% for personexpedition in expedition.personexpedition_set.all %} + + + {% for dateTF in personexpedition.ListDaysTF %} + + {% empty %} + + {% endfor %} + + + + {% endfor %} +
{% for date in expedition.ListDays %} {% ifchanged date.month %} {{ date|date:"F" }}
{% for date in expedition.ListDays %} {{ date|date:"D" }}
{% for date in expedition.ListDays %} {{ date|date:"d" }}
+ {{ personexpedition.person }} + No data yet.
{% endif %} {% endblock %} \ No newline at end of file