diff --git a/events/models/profiles.py b/events/models/profiles.py index bb5aee5..33cee39 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -46,12 +46,15 @@ class UserProfile(models.Model): return "Unknown Profile" def avatar_url(self): - if self.avatar is None or self.avatar.name is None: + try: + if self.avatar is None or self.avatar.name is None: + return settings.STATIC_URL + 'img/avatar_placeholder.png' + elif self.avatar.name.startswith('http'): + return self.avatar.name + else: + return self.avatar.url + except: return settings.STATIC_URL + 'img/avatar_placeholder.png' - elif self.avatar.name.startswith('http'): - return self.avatar.name - else: - return self.avatar.url def get_timezone(self): try: diff --git a/get_together/templates/get_together/teams/show_team.html b/get_together/templates/get_together/teams/show_team.html index b9f7947..fcfadb5 100644 --- a/get_together/templates/get_together/teams/show_team.html +++ b/get_together/templates/get_together/teams/show_team.html @@ -34,7 +34,7 @@

Upcoming Events

- {% for event in events_list %} + {% for event in upcoming_events %}
{{ event.place }}
@@ -50,6 +50,20 @@ {% endif %}

+ + {% if recent_events %} +

Recent Events

+
+ {% for event in recent_events %} +
+ +
{{ event.place }}
+
{{ event.start_time }}
+
+ {% endfor %} +
+
+ {% endif %}
diff --git a/get_together/views/teams.py b/get_together/views/teams.py index dcaad19..99e5684 100644 --- a/get_together/views/teams.py +++ b/get_together/views/teams.py @@ -25,10 +25,12 @@ def teams_list(request, *args, **kwargs): def show_team(request, team_id, *args, **kwargs): team = Team.objects.get(id=team_id) - team_events = Event.objects.filter(team=team, end_time__gt=datetime.datetime.now()).order_by('start_time') + upcoming_events = Event.objects.filter(team=team, end_time__gt=datetime.datetime.now()).order_by('start_time') + recent_events = Event.objects.filter(team=team, end_time__lte=datetime.datetime.now()).order_by('-start_time')[:5] context = { 'team': team, - 'events_list': team_events, + 'upcoming_event': upcoming_events, + 'recent_events': recent_events, 'is_member': request.user.profile in team.members.all(), 'member_list': Member.objects.filter(team=team), 'can_create_event': request.user.profile.can_create_event(team),