Add the 5 most recent past events to a team's page
This commit is contained in:
parent
4ceb57e788
commit
037dd7f3b5
3 changed files with 27 additions and 8 deletions
|
@ -46,12 +46,15 @@ class UserProfile(models.Model):
|
||||||
return "Unknown Profile"
|
return "Unknown Profile"
|
||||||
|
|
||||||
def avatar_url(self):
|
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'
|
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):
|
def get_timezone(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
<h4>Upcoming Events</h4>
|
<h4>Upcoming Events</h4>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{% for event in events_list %}
|
{% for event in upcoming_events %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col"><a href="{{ event.get_absolute_url }}">{{event.name}}</a></div>
|
<div class="col"><a href="{{ event.get_absolute_url }}">{{event.name}}</a></div>
|
||||||
<div class="col">{{ event.place }}</div>
|
<div class="col">{{ event.place }}</div>
|
||||||
|
@ -50,6 +50,20 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
{% if recent_events %}
|
||||||
|
<h4>Recent Events</h4>
|
||||||
|
<div class="container">
|
||||||
|
{% for event in recent_events %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col"><a href="{{ event.get_absolute_url }}">{{event.name}}</a></div>
|
||||||
|
<div class="col">{{ event.place }}</div>
|
||||||
|
<div class="col">{{ event.start_time }}</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
|
|
|
@ -25,10 +25,12 @@ def teams_list(request, *args, **kwargs):
|
||||||
|
|
||||||
def show_team(request, team_id, *args, **kwargs):
|
def show_team(request, team_id, *args, **kwargs):
|
||||||
team = Team.objects.get(id=team_id)
|
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 = {
|
context = {
|
||||||
'team': team,
|
'team': team,
|
||||||
'events_list': team_events,
|
'upcoming_event': upcoming_events,
|
||||||
|
'recent_events': recent_events,
|
||||||
'is_member': request.user.profile in team.members.all(),
|
'is_member': request.user.profile in team.members.all(),
|
||||||
'member_list': Member.objects.filter(team=team),
|
'member_list': Member.objects.filter(team=team),
|
||||||
'can_create_event': request.user.profile.can_create_event(team),
|
'can_create_event': request.user.profile.can_create_event(team),
|
||||||
|
|
Loading…
Reference in a new issue