예제 #1
0
    def website_error(request, code, ctxt, nav_param=None):
        if not nav_param:
            nav_param = {}

        label, template = template_dict.get(WebsiteError(code), WebsiteError.UNKNOWN)

        return render_template(request, label, template, ctxt, nav_param=nav_param)
예제 #2
0
파일: add.py 프로젝트: stefaneutu/Jelly-Bot
    def get(self, request, *args, **kwargs):
        root_uid = get_root_oid(request)

        return render_template(
            request, _("Add an Auto-Reply module"), "ar/add.html", {
                "max_responses":
                AutoReply.MaxResponses,
                "max_length":
                AutoReply.MaxContentLength,
                "platform_list":
                list(Platform),
                "contenttype_list_kw": [
                    t for t in list(AutoReplyContentType)
                    if t != AutoReplyContentType.IMAGE
                ],
                "contenttype_list_rep":
                list(AutoReplyContentType),
                "tag_splitter":
                AutoReply.TagSplitter,
                "user_ch_list":
                ProfileManager.get_user_channel_profiles(
                    root_uid, inside_only=True, accessbible_only=True),
                "root_uid_str":
                str(root_uid),
                "perm_pin_access":
                ProfilePermission.AR_ACCESS_PINNED_MODULE.code,
                "oid_key":
                OID_KEY
            })
예제 #3
0
    def get(self, request, *args, **kwargs):
        keyword = request.GET.get("w")
        include_inactive = safe_cast(request.GET.get("include_inactive"), bool)

        channel_data = self.get_channel_data(*args, **kwargs)
        channel_name = channel_data.model.get_channel_name(
            get_root_oid(request))

        module_list = list(
            AutoReplyManager.get_conn_list(channel_data.model.id, keyword,
                                           not include_inactive))

        uids = []
        for module in module_list:
            uids.append(module.creator_oid)
            if not module.active and module.remover_oid:
                uids.append(module.remover_oid)

        username_dict = IdentitySearcher.get_batch_user_name(
            uids, channel_data.model, on_not_found="")

        return render_template(
            request,
            _("Auto-Reply search in {}").format(channel_name),
            "ar/search-main.html", {
                "channel_name": channel_name,
                "channel_oid": channel_data.model.id,
                "module_list": module_list,
                "username_dict": username_dict,
                "include_inactive": include_inactive,
                "keyword": keyword or ""
            },
            nav_param=kwargs)
예제 #4
0
    def get(self, request, *args, **kwargs):
        root_uid = get_root_oid(request)

        return render_template(
            request, _("Auto-Reply ranking channel list"), "ar/rk-chlist.html",
            {
                "channel_list": ProfileManager.get_user_channel_profiles(
                    root_uid, inside_only=True, accessbible_only=True)
            }, nav_param=kwargs)
예제 #5
0
    def get(self, request, *args, **kwargs):
        github_commit = GithubWrapper.get_latest_commit(System.GitHubRepoIDName, System.GitHubRepoBranch)

        return render_template(request, _("About"), "about.html", {
            "commit":
                github_commit.sha,
            "commit_url":
                GithubWrapper.get_commit_url(System.GitHubRepoIDName, github_commit.sha),
            "commit_branch":
                System.GitHubRepoBranch
        })
예제 #6
0
 def get(self, request, code, *args, **kwargs):
     node = cmd_root.get_child_node(code)
     if node:
         return render_template(request,
                                _("Bot Command - {}").format(
                                    node.main_cmd_code),
                                "doc/botcmd_node.html", {"cmd_node": node},
                                nav_param={"code": code})
     else:
         return WebsiteErrorView.website_error(
             request,
             WebsiteError.BOT_CMD_NOT_FOUND, {"cmd_code": code},
             nav_param={"code": code})
예제 #7
0
    def get(self, request, *args, **kwargs):
        cmd_splitters_html = "<b>"\
            + f"</b>&nbsp;{_('or')}&nbsp;<b>".join([str(char_description(spl)) for spl in cmd_root.splitters])\
            + "</b>"

        return render_template(
            request, _("Bot Commands List"), "doc/botcmd_main.html", {
                "cmd_prefix": cmd_root.prefix,
                "cmd_splitters_html": cmd_splitters_html,
                "cmd_nodes": cmd_root.child_nodes,
                "case_insensitive": cmd_root.case_insensitive,
                "case_insensitive_prefix": Bot.CaseInsensitivePrefix
            })
예제 #8
0
    def get(self, request, *args, **kwargs):
        channel_data = self.get_channel_data(*args, **kwargs)

        limit = get_limit(request.GET, Website.AutoReply.RankingMaxCount)

        return render_template(
            request, _("Auto-Reply ranking in {}").format(channel_data.model.id), "ar/rk-main.html",
            {
                "rk_module": AutoReplyManager.get_module_count_stats(channel_data.model.id, limit),
                "rk_ukw": AutoReplyManager.get_unique_keyword_count_stats(channel_data.model.id, limit),
                "channel_current": channel_data.model,
                "limit": limit,
                "max": Website.AutoReply.RankingMaxCount
            }, nav_param=kwargs)
예제 #9
0
    def get(self, request, *args, **kwargs):
        root_oid = get_root_oid(request)
        if root_oid and now_utc_aware() - root_oid.generation_time < timedelta(
                days=Website.NewRegisterThresholdDays):
            messages.info(
                request,
                _('It seems that you haven\'t integrate your account. '
                  'Visit <a href="{}{}">this page</a> to know what to do to fully utilize this bot!'
                  ).format(
                      HostUrl,
                      reverse("page.doc.botcmd.cmd",
                              kwargs={"code": cmd_uintg.main_cmd_code})),
                extra_tags="safe")

        return render_template(request, _("Home Page"), "index.html")
예제 #10
0
 def get(self, request, *args, **kwargs):
     return render_template(request, _("Terms Explanation"),
                            "doc/terms.html",
                            {"terms_collection": terms_collection})
예제 #11
0
 def get(self, request, *args, **kwargs):
     return render_template(request, _("Auto-Reply Home"), "ar/main.html")