Beispiel #1
0
    def get(self, task_name):
        try:
            task = self.contest.get_task(task_name)
        except KeyError:
            raise tornado.web.HTTPError(404)

        for statement in itervalues(task.statements):
            lang_code = statement.language
            if is_language_country_code(lang_code):
                statement.language_name = \
                    translate_language_country_code(lang_code, self.locale)
            elif is_language_code(lang_code):
                statement.language_name = \
                    translate_language_code(lang_code, self.locale)
            elif is_country_code(lang_code):
                statement.language_name = \
                    translate_country_code(lang_code, self.locale)
            else:
                statement.language_name = lang_code

        self.r_params["primary_statements"] = task.primary_statements

        try:
            self.r_params["user_primary"] = \
                self.current_user.user.preferred_languages
        except ValueError as e:
            self.r_params["user_primary"] = []
            logger.error("Preferred languages for user %s is invalid [%r].",
                         self.current_user.user.username, e)

        self.render("task_description.html", task=task, **self.r_params)
Beispiel #2
0
Datei: task.py Projekt: Corea/cms
    def get(self, task_name):
        try:
            task = self.contest.get_task(task_name)
        except KeyError:
            raise tornado.web.HTTPError(404)

        for statement in task.statements.itervalues():
            lang_code = statement.language
            if is_language_country_code(lang_code):
                statement.language_name = \
                    translate_language_country_code(lang_code, self.locale)
            elif is_language_code(lang_code):
                statement.language_name = \
                    translate_language_code(lang_code, self.locale)
            elif is_country_code(lang_code):
                statement.language_name = \
                    translate_country_code(lang_code, self.locale)
            else:
                statement.language_name = lang_code

        self.render("task_description.html", task=task, **self.r_params)
Beispiel #3
0
    def get(self, task_name):
        try:
            task = self.contest.get_task(task_name)
        except KeyError:
            raise tornado.web.HTTPError(404)

        for statement in task.statements.itervalues():
            lang_code = statement.language
            if is_language_country_code(lang_code):
                statement.language_name = \
                    translate_language_country_code(lang_code, self.locale)
            elif is_language_code(lang_code):
                statement.language_name = \
                    translate_language_code(lang_code, self.locale)
            elif is_country_code(lang_code):
                statement.language_name = \
                    translate_country_code(lang_code, self.locale)
            else:
                statement.language_name = lang_code

        self.render("task_description.html", task=task, **self.r_params)
Beispiel #4
0
    def get(self, task_name):
        try:
            task = self.contest.get_task(task_name)
        except KeyError:
            raise tornado.web.HTTPError(404)
        if self.contest.restrict_level and self.current_user.user.level != task.level and self.current_user.user.level != "x" and task.level != "x":
            raise tornado.web.HTTPError(404)

        for statement in task.statements.itervalues():
            lang_code = statement.language
            if is_language_country_code(lang_code):
                statement.language_name = \
                    translate_language_country_code(lang_code, self.locale)
            elif is_language_code(lang_code):
                statement.language_name = \
                    translate_language_code(lang_code, self.locale)
            elif is_country_code(lang_code):
                statement.language_name = \
                    translate_country_code(lang_code, self.locale)
            else:
                statement.language_name = lang_code

        try:
            self.r_params["primary_statements"] = \
                json.loads(task.primary_statements)
        except ValueError as e:
            self.r_params["primary_statements"] = []
            logger.error("Primary statements for task %s is invalid [%r].",
                         task_name, e)

        try:
            self.r_params["user_primary"] = \
                json.loads(self.current_user.user.preferred_languages)
        except ValueError as e:
            self.r_params["user_primary"] = []
            logger.error("Preferred languages for user %s is invalid [%r].",
                         self.current_user.user.username, e)

        self.render("task_description.html", task=task, **self.r_params)