Esempio n. 1
0
    def get_success_url(self):
        form = super().get_form()

        argzz = [form.data["wiki_id"]]
        argzz.extend(file_name_tools.to_page_dirs(form.data["page_name"]))

        return reverse('wikis.attachments:attachment', args=argzz)
Esempio n. 2
0
    def clean_page_name(self):
        # wikiID
        wiki_id = self.data["wiki_id"]

        # ページ名
        page_name = self.cleaned_data['page_name']

        # NGword
        # URLのパスと重複するIDを禁止する。
        ngname = [
            "attachment",
            "attachments",
            "comment",
            "comments",
            "history",
            "histories",
            "maintenance",
            "maintenances",
            "page",
            "pages",
            "create",
            "copy",
            "list",
            "updates",
            "help",
            "sitemap.xml",
        ]

        page_dirs = file_name_tools.to_page_dirs(page_name)
        if page_dirs[0] in ngname:
            raise forms.ValidationError('対象のページ名は予約語であるため、使用出来ません。')

        # ファイル名
        file_name = file_name_tools.page_name_to_file_name(page_name)

        # ページ一覧
        page_file = json.loads(file_utils.get_file(wiki_id, "pages.json"))
        pages = page_file["data"]["pages"]

        # 新規作成するページが既に存在していないかチェック
        for page in pages:

            if file_name == page["file_name"]:
                raise forms.ValidationError("対象のページは既に存在しています。")

        return page_name
Esempio n. 3
0
def get_comments(request, wiki_id):
    if request.method == 'GET':
        page_name = request.GET.get('page_name')

        if not wiki_id or not page_name:
            return HttpResponse("")

        context = {}
        context["wiki_id"] = wiki_id

        context["comments"] = comment_tool.get_comments_short(
            wiki_id, page_name)
        context["form"] = {"page_name": {"value": page_name}}

        argzz = [wiki_id]
        argzz.extend(file_name_tools.to_page_dirs(page_name))
        context["comment_url"] = reverse('wikis.comments:comment', args=argzz)

        return render(request, 'wikis/comments/show_comments.html', context)

    return HttpResponse("")