Commit 67848ff6 by muzaffaryousaf Committed by Andy Armstrong

Link to learner profile page from username in discussions.

TNL-1503
parent 4f97cd7a
...@@ -444,9 +444,9 @@ class DiscussionUserProfilePage(CoursePage): ...@@ -444,9 +444,9 @@ class DiscussionUserProfilePage(CoursePage):
return ( return (
self.q(css='section.discussion-user-threads[data-course-id="{}"]'.format(self.course_id)).present self.q(css='section.discussion-user-threads[data-course-id="{}"]'.format(self.course_id)).present
and and
self.q(css='section.user-profile div.sidebar-username').present self.q(css='section.user-profile a.leaner-profile-link').present
and and
self.q(css='section.user-profile div.sidebar-username').text[0] == self.username self.q(css='section.user-profile a.leaner-profile-link').text[0] == self.username
) )
@wait_for_js @wait_for_js
...@@ -526,6 +526,10 @@ class DiscussionUserProfilePage(CoursePage): ...@@ -526,6 +526,10 @@ class DiscussionUserProfilePage(CoursePage):
"Window is on top" "Window is on top"
).fulfill() ).fulfill()
def click_on_sidebar_username(self):
self.wait_for_page()
self.q(css='.leaner-profile-link').first.click()
class DiscussionTabHomePage(CoursePage, DiscussionPageMixin): class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
......
...@@ -19,6 +19,8 @@ from ...pages.lms.discussion import ( ...@@ -19,6 +19,8 @@ from ...pages.lms.discussion import (
DiscussionTabHomePage, DiscussionTabHomePage,
DiscussionSortPreferencePage, DiscussionSortPreferencePage,
) )
from ...pages.lms.learner_profile import LearnerProfilePage
from ...fixtures.course import CourseFixture, XBlockFixtureDesc from ...fixtures.course import CourseFixture, XBlockFixtureDesc
from ...fixtures.discussion import ( from ...fixtures.discussion import (
SingleThreadViewFixture, SingleThreadViewFixture,
...@@ -753,6 +755,24 @@ class DiscussionUserProfileTest(UniqueCourseTest): ...@@ -753,6 +755,24 @@ class DiscussionUserProfileTest(UniqueCourseTest):
page.wait_for_ajax() page.wait_for_ajax()
self.assertTrue(page.is_window_on_top()) self.assertTrue(page.is_window_on_top())
def test_redirects_to_learner_profile(self):
"""
Scenario: Verify that learner-profile link is present on forum discussions page and we can navigate to it.
Given that I am on discussion forum user's profile page.
And I can see a username on left sidebar
When I click on my username.
Then I will be navigated to Learner Profile page.
And I can my username on Learner Profile page
"""
learner_profile_page = LearnerProfilePage(self.browser, self.PROFILED_USERNAME)
page = self.check_pages(1)
page.click_on_sidebar_username()
learner_profile_page.wait_for_page()
self.assertTrue(learner_profile_page.field_is_visible('username'))
@attr('shard_1') @attr('shard_1')
class DiscussionSearchAlertTest(UniqueCourseTest): class DiscussionSearchAlertTest(UniqueCourseTest):
......
...@@ -9,6 +9,7 @@ import xml.sax.saxutils as saxutils ...@@ -9,6 +9,7 @@ import xml.sax.saxutils as saxutils
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.http import Http404, HttpResponseBadRequest from django.http import Http404, HttpResponseBadRequest
from django.views.decorators.http import require_GET from django.views.decorators.http import require_GET
...@@ -411,16 +412,18 @@ def user_profile(request, course_key, user_id): ...@@ -411,16 +412,18 @@ def user_profile(request, course_key, user_id):
'annotated_content_info': _attr_safe_json(annotated_content_info), 'annotated_content_info': _attr_safe_json(annotated_content_info),
}) })
else: else:
django_user = User.objects.get(id=user_id)
context = { context = {
'course': course, 'course': course,
'user': request.user, 'user': request.user,
'django_user': User.objects.get(id=user_id), 'django_user': django_user,
'profiled_user': profiled_user.to_dict(), 'profiled_user': profiled_user.to_dict(),
'threads': _attr_safe_json(threads), 'threads': _attr_safe_json(threads),
'user_info': _attr_safe_json(user_info), 'user_info': _attr_safe_json(user_info),
'annotated_content_info': _attr_safe_json(annotated_content_info), 'annotated_content_info': _attr_safe_json(annotated_content_info),
'page': query_params['page'], 'page': query_params['page'],
'num_pages': query_params['num_pages'], 'num_pages': query_params['num_pages'],
'learner_profile_page_url': reverse('learner_profile', kwargs={'username': django_user.username})
} }
return render_to_response('discussion/user_profile.html', context) return render_to_response('discussion/user_profile.html', context)
......
<%! from django.utils.translation import ugettext as _, ungettext %> <%! from django.utils.translation import ugettext as _, ungettext %>
<%def name="span(num)"><span>${num}</span></%def> <%def name="span(num)"><span>${num}</span></%def>
<div class="user-profile"> <div class="user-profile">
<div class="sidebar-username">${django_user.username | h}</div> <div class="sidebar-username"><a class="leaner-profile-link" href="${learner_profile_page_url}">${django_user.username | h}</a></div>
<div class="sidebar-user-roles"> <div class="sidebar-user-roles">
${_(', ').join(sorted(set(map(_, [role.name for role in django_user.roles.all()]))))} ${_(', ').join(sorted(set(map(_, [role.name for role in django_user.roles.all()]))))}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment