Esempio n. 1
0
    def post(self, task_name):
        task = self.get_task(task_name)
        if task is None:
            raise tornado.web.HTTPError(404)

        # Only set the official bit when the user can compete and we are not in
        # analysis mode.
        official = self.r_params["actual_phase"] == 0

        query_args = dict()

        try:
            submission = accept_submission(
                self.sql_session, self.service.file_cacher, self.current_user,
                task, self.timestamp, self.request.files,
                self.get_argument("language", None), official)
            self.sql_session.commit()
        except UnacceptableSubmission as e:
            logger.info("Sent error: `%s' - `%s'", e.subject, e.formatted_text)
            self.notify_error(e.subject, e.text, e.text_params)
        else:
            self.service.evaluation_service.new_submission(
                submission_id=submission.id)
            self.notify_success(N_("Submission received"),
                                N_("Your submission has been received "
                                   "and is currently being evaluated."))
            # The argument (encrypted submission id) is not used by CWS
            # (nor it discloses information to the user), but it is
            # useful for automatic testing to obtain the submission id).
            query_args["submission_id"] = \
                encrypt_number(submission.id, config.secret_key)

        self.redirect(self.contest_url("tasks", task.name, "submissions",
                                       **query_args))
Esempio n. 2
0
    def post(self, task_name):
        task = self.get_task(task_name)
        if task is None:
            raise tornado.web.HTTPError(404)

        # Only set the official bit when the user can compete and we are not in
        # analysis mode.
        official = self.r_params["actual_phase"] == 0

        query_args = dict()

        try:
            submission = accept_submission(
                self.sql_session, self.service.file_cacher, self.current_user,
                task, self.timestamp, self.request.files,
                self.get_argument("language", None), official)
            self.sql_session.commit()
        except UnacceptableSubmission as e:
            logger.info("Sent error: `%s' - `%s'", e.subject, e.text)
            self.notify_error(e.subject, e.text)
        else:
            self.service.evaluation_service.new_submission(
                submission_id=submission.id)
            self.notify_success(N_("Submission received"),
                                N_("Your submission has been received "
                                   "and is currently being evaluated."))
            # The argument (encrypted submission id) is not used by CWS
            # (nor it discloses information to the user), but it is
            # useful for automatic testing to obtain the submission id).
            query_args["submission_id"] = \
                encrypt_number(submission.id, config.secret_key)

        self.redirect(self.contest_url("tasks", task.name, "submissions",
                                       **query_args))
Esempio n. 3
0
    def post(self, task_name):
        task = self.get_task(task_name)
        if task is None:
            raise tornado.web.HTTPError(404)

        # Only set the official bit when the user can compete and we are not in
        # analysis mode.
        official = self.r_params["actual_phase"] == 0

        query_args = dict()

        # fill in any missing files with text contents
        for filename in task.submission_format:
            if filename not in self.request.files:
                ta_input = self.get_argument('ta_' + filename)

                # potentially append new file
                if ta_input:
                    stored_filename = filename
                    language = self.get_argument("language", None)
                    if language:
                        extension = get_language(language).source_extension
                        stored_filename = filename.replace(".%l", extension)

                    logger.info("Appending file from contents: " +
                                stored_filename)
                    ta_file = HTTPFile(filename=stored_filename,
                                       body=ta_input.encode(),
                                       type='text/plain')
                    self.request.files[filename] = [ta_file]

        try:
            submission = accept_submission(self.sql_session,
                                           self.service.file_cacher,
                                           self.current_user, task,
                                           self.timestamp, self.request.files,
                                           self.get_argument("language",
                                                             None), official)
            self.sql_session.commit()
        except UnacceptableSubmission as e:
            logger.info("Sent error: `%s' - `%s'", e.subject, e.formatted_text)
            self.notify_error(e.subject, e.text, e.text_params)
        else:
            self.service.evaluation_service.new_submission(
                submission_id=submission.id)
            self.notify_success(
                N_("Submission received"),
                N_("Your submission has been received "
                   "and is currently being evaluated."))
            # The argument (encrypted submission id) is not used by CWS
            # (nor it discloses information to the user), but it is
            # useful for automatic testing to obtain the submission id).
            query_args["submission_id"] = \
                encrypt_number(submission.id, config.secret_key)
            query_args["tab"] = "submissions"

        # self.redirect(self.contest_url("tasks", task.name, "submissions",
        #                               **query_args))
        self.redirect(
            self.contest_url("tasks", task.name, "full", **query_args))
Esempio n. 4
0
 def call(self):
     return accept_submission(
         self.session, self.file_cacher, self.participation, self.task,
         self.timestamp, self.tornado_files, self.language_name,
         self.official)