Merge branch 'view-profile' of https://github.com/bheesham/GetTogether into bheesham-view-profile
This commit is contained in:
commit
856d48bbcb
7 changed files with 82 additions and 3 deletions
23
events/migrations/0009_auto_20180224_0556.py
Normal file
23
events/migrations/0009_auto_20180224_0556.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.0 on 2018-02-24 05:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('events', '0008_add-team-description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='searchable',
|
||||
name='venue_name',
|
||||
field=models.CharField(blank=True, max_length=256),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='userprofile',
|
||||
name='avatar',
|
||||
field=models.URLField(blank=True, max_length=150, null=True, verbose_name='Photo Image'),
|
||||
),
|
||||
]
|
|
@ -7,7 +7,7 @@
|
|||
<td>{{ team.country.name|default:'' }}</td>
|
||||
<td>{{ team.spr.name|default:'' }}</td>
|
||||
<td>{{ team.city.name|default:'' }}</td>
|
||||
<td>{{ team.owner_profile }}</td>
|
||||
<td><a href="{% url 'show-profile' team.owner_profile.id %}" title="{{team.owner_profile}}'s profile">{{ team.owner_profile }}</a></td>
|
||||
<td>{{ team.created_time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -75,7 +75,9 @@
|
|||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in attendee.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<h6 class="mt-2 mb-0">{{attendee.user}} <span class="badge badge-success align-top">{{ attendee.status_name }}</span></h6>
|
||||
<h6 class="mt-2 mb-0">
|
||||
<a href="{% url 'show-profile' attendee.user.id %}" title="{{attendee.user}}'s profile">{{attendee.user}}</a>
|
||||
<span class="badge badge-success align-top">{{ attendee.status_name }}</span></h6>
|
||||
{% if attendee.role > 0 %}<small class="text-muted">{{ attendee.role_name }}</small>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<img class="mr-1 gt-profile-avatar" src="{{member.user.avatar}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in member.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<h6 class="mt-0 mb-0">{{member.user}}</h6>
|
||||
<h6 class="mt-0 mb-0"><a href="{% url 'show-profile' member.user.id %}" title="{{member.user}}'s profile">{{member.user}}</a></h6>
|
||||
{% if member.role > 0 %}<small class="text-muted">{{ member.role_name }}</small>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
32
get_together/templates/get_together/users/show_profile.html
Normal file
32
get_together/templates/get_together/users/show_profile.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
{% extends "get_together/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if user %}
|
||||
|
||||
<h2>Profile: {{user.user}}</h2>
|
||||
|
||||
Realname: {{user.realname}} <br>
|
||||
|
||||
{% if user.weburl %}
|
||||
Homepage: {{user.weburl}} <br>
|
||||
{% endif %}
|
||||
|
||||
{% if teams %}
|
||||
<h3>Teams</h3>
|
||||
<ul>
|
||||
{% for t in teams %}
|
||||
<li>
|
||||
<a href="{% url 'show-team' t.id %}" title="Team page for {{t.team.name}}">{{t.team.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
<h2>User not found.</h2>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -36,6 +36,7 @@ urlpatterns = [
|
|||
path('api/find_city/', event_views.find_city),
|
||||
|
||||
path('profile/+edit', views.edit_profile, name='edit-profile'),
|
||||
path('profile/<int:user_id>/', views.show_profile, name='show-profile'),
|
||||
|
||||
path('events/', views.events_list, name='events'),
|
||||
path('+create-team/', views.create_team, name='create-team'),
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.contrib import messages
|
|||
from django.contrib.auth import logout as logout_user
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from events.models.profiles import Team, UserProfile, Member
|
||||
from events.forms import UserForm, UserProfileForm
|
||||
|
@ -27,6 +28,26 @@ def login(request):
|
|||
return redirect('home')
|
||||
return render(request, 'get_together/users/login.html')
|
||||
|
||||
|
||||
def show_profile(request, user_id):
|
||||
|
||||
template = 'get_together/users/show_profile.html'
|
||||
|
||||
try:
|
||||
user = UserProfile.objects.get(id=user_id)
|
||||
except ObjectDoesNotExist:
|
||||
return render(request, template, {'user': None}, status=404)
|
||||
|
||||
teams = Member.objects.filter(user_id=user_id)
|
||||
|
||||
context = {
|
||||
'user': user,
|
||||
'teams': teams,
|
||||
}
|
||||
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
def edit_profile(request):
|
||||
if not request.user.is_authenticated:
|
||||
messages.add_message(request, messages.WARNING, message=_('You must be logged in to edit your profile.'))
|
||||
|
|
Loading…
Reference in a new issue