Skip to content

Commit

Permalink
fix: pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Faraz Maqsood committed Oct 11, 2024
1 parent 3162554 commit af8e057
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ def unFlagAbuse(self, user, voteable, removeAll):
if is_forum_v2_enabled(course_key):
if voteable.type == "thread":
response = forum_api.update_thread_flag(
voteable.id, "unflag", user.id, bool(removeAll), str(course_key)
thread_id=voteable.id,
action="unflag",
user_id=user.id,
update_all=bool(removeAll),
course_id=str(course_key)
)
else:
response = forum_api.update_comment_flag(
voteable.id, "unflag", user.id, bool(removeAll), str(course_key)
comment_id=voteable.id,
action="unflag",
user_id=user.id,
update_all=bool(removeAll),
course_id=str(course_key)
)
else:
params = {'user_id': user.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _retrieve(self, *args, **kwargs):
response = None
if is_forum_v2_enabled(course_key):
if self.type == "comment":
response = forum_api.get_parent_comment(self.attributes["id"], str(course_key))
response = forum_api.get_parent_comment(comment_id=self.attributes["id"], course_id=str(course_key))
if response is None:
raise CommentClientRequestError("Forum v2 API call is missing")
else:
Expand Down Expand Up @@ -177,9 +177,9 @@ def delete(self):
if is_forum_v2_enabled(course_key):
response = None
if self.type == "comment":
response = forum_api.delete_comment(self.attributes["id"], str(course_key))
response = forum_api.delete_comment(comment_id=self.attributes["id"], course_id=str(course_key))
elif self.type == "thread":
response = forum_api.delete_thread(self.attributes["id"], str(course_key))
response = forum_api.delete_thread(thread_id=self.attributes["id"], course_id=str(course_key))
if response is None:
raise CommentClientRequestError("Forum v2 API call is missing")
else:
Expand Down Expand Up @@ -365,7 +365,7 @@ def handle_create_thread(self, course_id):
user_id = str(request_data["user_id"])
except KeyError as e:
raise e

request_data = {
"title": title,
"body": body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def fetch(cls, thread_id, course_id, query_params):
course_key = utils.get_course_key(course_id)
if is_forum_v2_enabled(course_key):
response = forum_api.get_thread_subscriptions(
thread_id, params["page"], params["per_page"], str(course_key)
thread_id=thread_id,
page=params["page"],
per_page=params["per_page"],
course_id=str(course_key)
)
else:
response = utils.perform_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ def _retrieve(self, *args, **kwargs):
if is_forum_v2_enabled(course_key):
if user_id := request_params.get('user_id'):
request_params['user_id'] = str(user_id)
response = forum_api.get_thread(self.id, request_params, str(course_key))
response = forum_api.get_thread(
thread_id=self.id,
params=request_params,
course_id=str(course_key)
)
else:
response = utils.perform_request(
'get',
Expand Down Expand Up @@ -217,7 +221,13 @@ def unFlagAbuse(self, user, voteable, removeAll):
raise utils.CommentClientRequestError("Can only flag/unflag for threads or comments")
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
response = forum_api.update_thread_flag(voteable.id, "unflag", user.id, bool(removeAll), str(course_key))
response = forum_api.update_thread_flag(
thread_id=voteable.id,
action="unflag",
user_id=user.id,
update_all=bool(removeAll),
course_id=str(course_key)
)
else:
params = {'user_id': user.id}
#if you're an admin, when you unflag, remove ALL flags
Expand All @@ -236,7 +246,11 @@ def unFlagAbuse(self, user, voteable, removeAll):
def pin(self, user, thread_id):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
response = forum_api.pin_thread(user.id, thread_id, str(course_key))
response = forum_api.pin_thread(
user_id=user.id,
thread_id=thread_id,
course_id=str(course_key)
)
else:
url = _url_for_pin_thread(thread_id)
params = {'user_id': user.id}
Expand All @@ -252,7 +266,11 @@ def pin(self, user, thread_id):
def un_pin(self, user, thread_id):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
response = forum_api.unpin_thread(user.id, thread_id, str(course_key))
response = forum_api.unpin_thread(
user_id=user.id,
thread_id=thread_id,
course_id=str(course_key)
)
else:
url = _url_for_un_pin_thread(thread_id)
params = {'user_id': user.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def read(self, source):
def follow(self, source):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
forum_api.create_subscription(self.id, source.id, str(course_key))
forum_api.create_subscription(
user_id=self.id,
source_id=source.id,
course_id=str(course_key)
)
else:
params = {'source_type': source.type, 'source_id': source.id}
utils.perform_request(
Expand All @@ -69,7 +73,11 @@ def follow(self, source):
def unfollow(self, source):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
forum_api.delete_subscription(self.id, source.id, str(course_key))
forum_api.delete_subscription(
user_id=self.id,
source_id=source.id,
course_id=str(course_key)
)
else:
params = {'source_type': source.type, 'source_id': source.id}
utils.perform_request(
Expand All @@ -90,9 +98,19 @@ def vote(self, voteable, value):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
if voteable.type == 'thread':
response = forum_api.update_thread_votes(voteable.id, self.id, value, str(course_key))
response = forum_api.update_thread_votes(
thread_id=voteable.id,
user_id=self.id,
value=value,
course_id=str(course_key)
)
else:
response = forum_api.update_comment_votes(voteable.id, self.id, value, str(course_key))
response = forum_api.update_comment_votes(
comment_id=voteable.id,
user_id=self.id,
value=value,
course_id=str(course_key)
)
else:
params = {'user_id': self.id, 'value': value}
response = utils.perform_request(
Expand All @@ -114,9 +132,17 @@ def unvote(self, voteable):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
if voteable.type == 'thread':
response = forum_api.delete_thread_vote(voteable.id, self.id, str(course_key))
response = forum_api.delete_thread_vote(
thread_id=voteable.id,
user_id=self.id,
course_id=str(course_key)
)
else:
response = forum_api.delete_comment_vote(voteable.id, self.id, str(course_key))
response = forum_api.delete_comment_vote(
comment_id=voteable.id,
user_id=self.id,
course_id=str(course_key)
)
else:
params = {'user_id': self.id}
response = utils.perform_request(
Expand Down Expand Up @@ -245,7 +271,7 @@ def _retrieve(self, *args, **kwargs):
def retire(self, retired_username):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
forum_api.retire_user(self.id, retired_username, str(course_key))
forum_api.retire_user(user_id=self.id, retired_username=retired_username, course_id=str(course_key))
else:
url = _url_for_retire(self.id)
params = {'retired_username': retired_username}
Expand All @@ -261,7 +287,7 @@ def retire(self, retired_username):
def replace_username(self, new_username):
course_key = utils.get_course_key(self.attributes.get("course_id"))
if is_forum_v2_enabled(course_key):
forum_api.update_username(self.id, new_username, str(course_key))
forum_api.update_username(user_id=self.id, new_username=new_username, course_id=str(course_key))
else:
url = _url_for_username_replacement(self.id)
params = {"new_username": new_username}
Expand Down

0 comments on commit af8e057

Please sign in to comment.