Skip to content

Commit 1ccdfc1

Browse files
prandlaveluca93
authored andcommitted
Make QuestionActionHandler an abstract class
1 parent f4763b0 commit 1ccdfc1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cms/server/admin/handlers/contestquestion.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
2626
"""
2727

28+
from abc import ABCMeta, abstractmethod
2829
import logging
2930

3031
import collections
@@ -65,10 +66,11 @@ def get(self, contest_id):
6566

6667

6768

68-
class QuestionActionHandler(BaseHandler):
69+
class QuestionActionHandler(BaseHandler, metaclass=ABCMeta):
6970
"""Base class for handlers for actions on questions."""
7071

71-
def do(self, question: Question):
72+
@abstractmethod
73+
def process_question(self, question: Question):
7274
"""Called on POST requests. Perform the appropriate action on the
7375
question."""
7476
pass
@@ -88,15 +90,15 @@ def post(self, contest_id, question_id):
8890
if self.contest is not question.participation.contest:
8991
raise tornado_web.HTTPError(404)
9092

91-
self.do(question)
93+
self.process_question(question)
9294
self.redirect(ref)
9395

9496
class QuestionReplyHandler(QuestionActionHandler):
9597
"""Called when the manager replies to a question made by a user.
9698
9799
"""
98100

99-
def do(self, question):
101+
def process_question(self, question):
100102
reply_subject_code: str = self.get_argument(
101103
"reply_question_quick_answer", "")
102104
question.reply_text = self.get_argument("reply_question_text", "")
@@ -125,7 +127,7 @@ class QuestionIgnoreHandler(QuestionActionHandler):
125127
question.
126128
127129
"""
128-
def do(self, question):
130+
def process_question(self, question):
129131
should_ignore = self.get_argument("ignore", "no") == "yes"
130132

131133
# Commit the change.
@@ -143,7 +145,7 @@ def do(self, question):
143145
class QuestionClaimHandler(QuestionActionHandler):
144146
"""Called when the manager chooses to claim or unclaim a question."""
145147

146-
def do(self, question):
148+
def process_question(self, question):
147149
# Can claim/unclaim only a question not ignored or answered.
148150
if question.ignored or question.reply_timestamp is not None:
149151
raise tornado_web.HTTPError(405)

0 commit comments

Comments
 (0)