From cec58f885b568978fd81c515e179c82f823e10ca Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 6 Dec 2013 13:11:53 -0500 Subject: [PATCH] Remove forum user profile moderator toggle button This button has been broken for at least a year, so the code has suffered from bit rot and should be reimplmemented if the feature is necessary in the short term (which is unlikely since it has been broken for so long). --- .../coffee/src/discussion/user_profile.coffee | 30 ---------------- .../static/coffee/src/discussion/utils.coffee | 1 - .../django_comment_client/base/urls.py | 1 - .../django_comment_client/base/views.py | 35 ------------------- .../django_comment_client/permissions.py | 1 - lms/static/sass/_discussion.scss | 6 ---- lms/templates/discussion/_user_profile.html | 7 ---- .../discussion/ajax_user_profile.html | 1 - 8 files changed, 82 deletions(-) delete mode 100644 common/static/coffee/src/discussion/user_profile.coffee delete mode 100644 lms/templates/discussion/ajax_user_profile.html diff --git a/common/static/coffee/src/discussion/user_profile.coffee b/common/static/coffee/src/discussion/user_profile.coffee deleted file mode 100644 index 9f0600dd1d8a..000000000000 --- a/common/static/coffee/src/discussion/user_profile.coffee +++ /dev/null @@ -1,30 +0,0 @@ -if Backbone? - class @DiscussionUserProfileView extends Backbone.View - toggleModeratorStatus: (event) -> - confirmValue = confirm("Are you sure?") - if not confirmValue then return - $elem = $(event.target) - if $elem.hasClass("sidebar-promote-moderator-button") - isModerator = true - else if $elem.hasClass("sidebar-revoke-moderator-button") - isModerator = false - else - console.error "unrecognized moderator status" - return - url = DiscussionUtil.urlFor('update_moderator_status', $$profiled_user_id) - DiscussionUtil.safeAjax - $elem: $elem - url: url - type: "POST" - dataType: 'json' - data: - is_moderator: isModerator - error: (response, textStatus, e) -> - console.log e - success: (response, textStatus) => - parent = @$el.parent() - @$el.replaceWith(response.html) - view = new DiscussionUserProfileView el: parent.children(".user-profile") - - events: - "click .sidebar-toggle-moderator-button": "toggleModeratorStatus" diff --git a/common/static/coffee/src/discussion/utils.coffee b/common/static/coffee/src/discussion/utils.coffee index 466beff4191b..a85e4f0eaa1e 100644 --- a/common/static/coffee/src/discussion/utils.coffee +++ b/common/static/coffee/src/discussion/utils.coffee @@ -78,7 +78,6 @@ class @DiscussionUtil tags_autocomplete : "/courses/#{$$course_id}/discussion/threads/tags/autocomplete" retrieve_discussion : "/courses/#{$$course_id}/discussion/forum/#{param}/inline" retrieve_single_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}" - update_moderator_status : "/courses/#{$$course_id}/discussion/users/#{param}/update_moderator_status" openclose_thread : "/courses/#{$$course_id}/discussion/threads/#{param}/close" permanent_link_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}" permanent_link_comment : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}##{param2}" diff --git a/lms/djangoapps/django_comment_client/base/urls.py b/lms/djangoapps/django_comment_client/base/urls.py index 5b653e1c68a4..97ba282db216 100644 --- a/lms/djangoapps/django_comment_client/base/urls.py +++ b/lms/djangoapps/django_comment_client/base/urls.py @@ -2,7 +2,6 @@ urlpatterns = patterns('django_comment_client.base.views', # nopep8 url(r'upload$', 'upload', name='upload'), - url(r'users/(?P\w+)/update_moderator_status$', 'update_moderator_status', name='update_moderator_status'), url(r'threads/tags/autocomplete$', 'tags_autocomplete', name='tags_autocomplete'), url(r'threads/(?P[\w\-]+)/update$', 'update_thread', name='update_thread'), url(r'threads/(?P[\w\-]+)/reply$', 'create_comment', name='create_comment'), diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 0e0bedc141a1..4e3331e59275 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -508,41 +508,6 @@ def unfollow_user(request, course_id, followed_user_id): return JsonResponse({}) -@require_POST -@login_required -@permitted -def update_moderator_status(request, course_id, user_id): - """ - given a course id and user id, check if the user has moderator - and send back a user profile - """ - is_moderator = request.POST.get('is_moderator', '').lower() - if is_moderator not in ["true", "false"]: - return JsonError("Must provide is_moderator as boolean value") - is_moderator = is_moderator == "true" - user = User.objects.get(id=user_id) - role = Role.objects.get(course_id=course_id, name="Moderator") - if is_moderator: - user.roles.add(role) - else: - user.roles.remove(role) - if request.is_ajax(): - course = get_course_with_access(request.user, course_id, 'load') - discussion_user = cc.User(id=user_id, course_id=course_id) - context = { - 'course': course, - 'course_id': course_id, - 'user': request.user, - 'django_user': user, - 'profiled_user': discussion_user.to_dict(), - } - return JsonResponse({ - 'html': render_to_string('discussion/ajax_user_profile.html', context) - }) - else: - return JsonResponse({}) - - @require_GET def search_similar_threads(request, course_id, commentable_id): """ diff --git a/lms/djangoapps/django_comment_client/permissions.py b/lms/djangoapps/django_comment_client/permissions.py index 5cc4ff18df9e..3c83556a7e75 100644 --- a/lms/djangoapps/django_comment_client/permissions.py +++ b/lms/djangoapps/django_comment_client/permissions.py @@ -102,7 +102,6 @@ def test(user, per, operator="or"): 'unfollow_commentable': ['unfollow_commentable'], 'unfollow_user': ['unfollow_user'], 'create_thread': ['create_thread'], - 'update_moderator_status': ['manage_moderator'], } diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 8f55f6c5fd0d..5fa86f922534 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -519,12 +519,6 @@ body.discussion { .sidebar-comments-count span { font-weight: 700; } - - .sidebar-toggle-moderator-button { - @include blue-button; - margin-top: $baseline; - text-align: center; - } } diff --git a/lms/templates/discussion/_user_profile.html b/lms/templates/discussion/_user_profile.html index 2e803a31ce4b..98f1c06a6499 100644 --- a/lms/templates/discussion/_user_profile.html +++ b/lms/templates/discussion/_user_profile.html @@ -14,11 +14,4 @@ - % if check_permissions_by_view(user, course.id, content=None, name='update_moderator_status'): - % if "Moderator" in role_names: - ${_("Revoke Moderator rights")} - % else: - ${_("Promote to Moderator")} - % endif - % endif diff --git a/lms/templates/discussion/ajax_user_profile.html b/lms/templates/discussion/ajax_user_profile.html deleted file mode 100644 index c24081845f7b..000000000000 --- a/lms/templates/discussion/ajax_user_profile.html +++ /dev/null @@ -1 +0,0 @@ -<%include file="_user_profile.html" />