From 3cd1e314e38451a62188048b3e123cf1f4123285 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Thu, 20 Sep 2018 23:28:54 -0400 Subject: [PATCH] Add upcoming events to user profile page. Fixes #121 --- events/forms.py | 2 +- events/templates/events/profile_form.html | 4 +- .../get_together/users/show_profile.html | 81 +++++++++++++------ get_together/views/user.py | 5 ++ 4 files changed, 66 insertions(+), 26 deletions(-) diff --git a/events/forms.py b/events/forms.py index 62a3e93..09ed31b 100644 --- a/events/forms.py +++ b/events/forms.py @@ -401,7 +401,7 @@ class UserForm(forms.ModelForm): class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile - fields = ['avatar', 'realname', 'city', 'tz', 'send_notifications', 'do_not_track'] + fields = ['realname', 'web_url', 'city', 'tz', 'avatar', 'send_notifications', 'do_not_track'] labels = { 'send_notifications': _('Send me notification emails'), 'do_not_track': _('Do not track'), diff --git a/events/templates/events/profile_form.html b/events/templates/events/profile_form.html index 6772da3..dc17674 100644 --- a/events/templates/events/profile_form.html +++ b/events/templates/events/profile_form.html @@ -1,4 +1,4 @@ -{{ profile_form }} -{{ user_form }} + {{ user_form }} + {{ profile_form }}
diff --git a/get_together/templates/get_together/users/show_profile.html b/get_together/templates/get_together/users/show_profile.html index 8c86d34..642e324 100644 --- a/get_together/templates/get_together/users/show_profile.html +++ b/get_together/templates/get_together/users/show_profile.html @@ -9,12 +9,12 @@ {% block content %} {% if user %} -
+
- {{user.user}} + {{ user.realname}} {% if user.user.id == request.user.id %} -

Full name: {{user.realname}}

- - {% if user.weburl %} -

Homepage: {{user.weburl}}

- {% endif %} -{% if talks %} -

Talks

-
-
- {% for talk in talks %} -
-
-
-

{{talk.title}}

-
- {{ talk.speaker }} -
-
-
+
+ {% if user.web_url %} +
+
Homepage:
+ {% endif %} +
+
Timezone:
{{user.tz}}
+
+
+ + + {% if upcoming_events %} +
+

Upcoming Events

+ {% for event in upcoming_events %} +
+
{% if event.status == event.CANCELED %}{% endif %}{{event.name}}{% if event.status == event.CANCELED %} (Canceled){% endif %}
+
{{ event.place }}
+
{{ event.local_start_time }}
+
+ {% endfor %} +
+ {% endif %} + + {% if recent_events %} +
+

Past Events

+ {% for event in recent_events %} +
+ +
{{ event.place }}
+
{{ event.local_start_time }}
+
+ {% endfor %} +
+ {% endif %} + + {% if talks %} +

Talks

+
+ {% for talk in talks %} +
+ +
+ {{ talk.speaker }} +
+
{% endfor %}
-
-{% endif %} + {% endif %}
{% if badges %} +

Badges

{% for badge in badges %} @@ -65,8 +95,10 @@
{% endfor %}
+
{% endif %} {% if teams %} +

Teams

    {% for t in teams %} @@ -75,7 +107,9 @@ {% endfor %}
+
{% endif %} +

Categories

    {% for c in user.categories.all %} @@ -84,6 +118,7 @@ {% endfor %}
+
diff --git a/get_together/views/user.py b/get_together/views/user.py index 5c76e61..48a6fc2 100644 --- a/get_together/views/user.py +++ b/get_together/views/user.py @@ -66,11 +66,16 @@ def show_profile(request, user_id): teams = user.memberships.all() talks = Talk.objects.filter(speaker__user=user) badges = user.user.account.badges.all() + upcoming_events = Event.objects.filter(team=user.personal_team, end_time__gt=datetime.datetime.now()).order_by('start_time') + recent_events = None#Event.objects.filter(team=user.personal_team, end_time__lte=datetime.datetime.now()).order_by('-start_time')[:3] + context = { 'user': user, 'teams': teams, 'talks': talks, 'badges': badges, + 'upcoming_events': upcoming_events, + 'recent_events': recent_events, } return render(request, 'get_together/users/show_profile.html', context)