Skip to content

Commit 8ba02df

Browse files
committed
Added fixes for various profile page problems found by the test crawler.
- Legacy-Id: 11321
1 parent e3cbaba commit 8ba02df

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

ietf/person/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
urlpatterns = patterns('',
55
(r'^search/(?P<model_name>(person|email))/$', "ietf.person.views.ajax_select2_search", None, 'ajax_select2_search_person_email'),
66
(r'^(?P<personid>[a-z0-9]+).json$', ajax.person_json),
7-
(ur'^(?P<email_or_name>[\w\s]+)', views.profile),
7+
(ur'^(?P<email_or_name>[-\w\s\']+)', views.profile),
88
)

ietf/person/views.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

22
from django.db.models import Q
3-
from django.http import HttpResponse
3+
from django.http import HttpResponse, Http404
44
from django.shortcuts import render, get_object_or_404
55

6+
import debug # pyflakes:ignore
7+
68
from ietf.person.models import Email, Person, Alias
79
from ietf.person.fields import select2_id_name_json
810

@@ -55,5 +57,8 @@ def profile(request, email_or_name):
5557
if '@' in email_or_name:
5658
person = get_object_or_404(Email, address=email_or_name).person
5759
else:
58-
person = get_object_or_404(Alias, name=email_or_name).person
59-
return render(request, 'person/profile.html', {'person': person})
60+
aliases = Alias.objects.filter(name=email_or_name)
61+
persons = set([ a.person for a in aliases ])
62+
if not persons:
63+
raise Http404
64+
return render(request, 'person/profile.html', {'persons': persons})

ietf/templates/person/profile.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@
66
{% block title %}Profile for {{ person }}{% endblock %}
77

88
{% block content %}
9-
109
{% origin %}
11-
<h1>{{ person.name }}</h1>
12-
13-
<div class="bio-text">
14-
{% if person.photo %}
15-
<a href="{{person.photo.url}}">
16-
<img class="bio-photo" src="{{ person.photo.url }}" alt="Photo of {{ person }}" />
17-
</a>
18-
{% else %}
19-
<img class="bio-photo" src="{{ MEDIA_URL }}photos/nopictureavailable.jpg" alt="No photo available"/>
20-
{% endif %}
21-
{{ person.biography | apply_markup:"restructuredtext" }}
10+
{% if persons|length > 1 %}
11+
<div class="col-md-12">
12+
<h4>Duplicate person records found. This is an error. Showing all:</h4>
13+
<hr>
2214
</div>
15+
{% endif %}
16+
{% for person in persons %}
17+
<div class="col-md-12">
18+
{% if not forloop.first %}<hr>{% endif %}
2319

20+
<h1>{{ person.name }}</h1>
21+
22+
<div class="bio-text">
23+
{% if person.photo %}
24+
<a href="{{person.photo.url}}">
25+
<img class="bio-photo" src="{{ person.photo.url }}" alt="Photo of {{ person }}" />
26+
</a>
27+
{% else %}
28+
<img class="bio-photo" src="{{ MEDIA_URL }}photos/nopictureavailable.jpg" alt="No photo available"/>
29+
{% endif %}
30+
{{ person.biography | apply_markup:"restructuredtext" }}
31+
</div>
32+
</div>
33+
{% endfor %}
2434
{% endblock %}

0 commit comments

Comments
 (0)