Link to learner profile page from username in discussions.
TNL-1503
This commit is contained in:
committed by
Andy Armstrong
parent
4f97cd7a04
commit
67848ff67b
@@ -444,9 +444,9 @@ class DiscussionUserProfilePage(CoursePage):
|
||||
return (
|
||||
self.q(css='section.discussion-user-threads[data-course-id="{}"]'.format(self.course_id)).present
|
||||
and
|
||||
self.q(css='section.user-profile div.sidebar-username').present
|
||||
self.q(css='section.user-profile a.leaner-profile-link').present
|
||||
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
|
||||
@@ -526,6 +526,10 @@ class DiscussionUserProfilePage(CoursePage):
|
||||
"Window is on top"
|
||||
).fulfill()
|
||||
|
||||
def click_on_sidebar_username(self):
|
||||
self.wait_for_page()
|
||||
self.q(css='.leaner-profile-link').first.click()
|
||||
|
||||
|
||||
class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ from ...pages.lms.discussion import (
|
||||
DiscussionTabHomePage,
|
||||
DiscussionSortPreferencePage,
|
||||
)
|
||||
from ...pages.lms.learner_profile import LearnerProfilePage
|
||||
|
||||
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||
from ...fixtures.discussion import (
|
||||
SingleThreadViewFixture,
|
||||
@@ -753,6 +755,24 @@ class DiscussionUserProfileTest(UniqueCourseTest):
|
||||
page.wait_for_ajax()
|
||||
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')
|
||||
class DiscussionSearchAlertTest(UniqueCourseTest):
|
||||
|
||||
@@ -9,6 +9,7 @@ import xml.sax.saxutils as saxutils
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.context_processors import csrf
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import Http404, HttpResponseBadRequest
|
||||
from django.views.decorators.http import require_GET
|
||||
@@ -411,16 +412,18 @@ def user_profile(request, course_key, user_id):
|
||||
'annotated_content_info': _attr_safe_json(annotated_content_info),
|
||||
})
|
||||
else:
|
||||
django_user = User.objects.get(id=user_id)
|
||||
context = {
|
||||
'course': course,
|
||||
'user': request.user,
|
||||
'django_user': User.objects.get(id=user_id),
|
||||
'django_user': django_user,
|
||||
'profiled_user': profiled_user.to_dict(),
|
||||
'threads': _attr_safe_json(threads),
|
||||
'user_info': _attr_safe_json(user_info),
|
||||
'annotated_content_info': _attr_safe_json(annotated_content_info),
|
||||
'page': query_params['page'],
|
||||
'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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%! from django.utils.translation import ugettext as _, ungettext %>
|
||||
<%def name="span(num)"><span>${num}</span></%def>
|
||||
<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">
|
||||
${_(', ').join(sorted(set(map(_, [role.name for role in django_user.roles.all()]))))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user