Exemple #1
0
    def dump_json(self, path=None):
        if path is None:
            man_path = os.path.join(self.get_path(), 'manifest.json')
        else:
            man_path = path

        dct = export_article(self)
        data = json_writer.dumps(dct, indent=4, ensure_ascii=False)
        json_data = open(man_path, "w")
        json_data.write(data.encode('utf-8'))
        json_data.close()
Exemple #2
0
    def dump_json(self, path=None):
        if path is None:
            man_path = os.path.join(self.get_path(), 'manifest.json')
        else:
            man_path = path

        dct = export_article(self)
        data = json_writer.dumps(dct, indent=4, ensure_ascii=False)
        json_data = open(man_path, "w")
        json_data.write(data.encode('utf-8'))
        json_data.close()
Exemple #3
0
    def _prepare(cls, create, **kwargs):
        article = super(ArticleFactory, cls)._prepare(create, **kwargs)

        path = article.get_path()
        if not os.path.isdir(path):
            os.makedirs(path, mode=0o777)

        man = export_article(article)
        repo = Repo.init(path, bare=False)
        repo = Repo(path)

        f = open(os.path.join(path, 'manifest.json'), "w")
        f.write(json_writer.dumps(man, indent=4, ensure_ascii=False).encode('utf-8'))
        f.close()
        f = open(os.path.join(path, article.text), "w")
        f.write(u'Test')
        f.close()
        repo.index.add(['manifest.json', article.text])
        cm = repo.index.commit("Init Article")

        article.sha_draft = cm.hexsha
        return article
Exemple #4
0
    def _prepare(cls, create, **kwargs):
        article = super(ArticleFactory, cls)._prepare(create, **kwargs)

        path = article.get_path()
        if not os.path.isdir(path):
            os.makedirs(path, mode=0o777)

        man = export_article(article)
        repo = Repo.init(path, bare=False)
        repo = Repo(path)

        f = open(os.path.join(path, 'manifest.json'), "w")
        f.write(json_writer.dumps(man, indent=4, ensure_ascii=False).encode('utf-8'))
        f.close()
        f = open(os.path.join(path, article.text), "w")
        f.write(u'Test')
        f.close()
        repo.index.add(['manifest.json', article.text])
        cm = repo.index.commit("Init Article")

        article.sha_draft = cm.hexsha
        return article
Exemple #5
0
    def _prepare(cls, create, **kwargs):
        light = kwargs.pop('light', False)

        authors = []
        if "authors" in kwargs:
            authors = kwargs.pop("authors")

        article = super(ArticleFactory, cls)._prepare(create, **kwargs)

        for auth in authors:
            article.authors.add(User.objects.get(pk=auth))

        path = article.get_path()
        if not os.path.isdir(path):
            os.makedirs(path, mode=0o777)

        man = export_article(article)
        repo = Repo.init(path, bare=False)
        repo = Repo(path)

        f = open(os.path.join(path, 'manifest.json'), "w")
        f.write(
            json_writer.dumps(man, indent=4,
                              ensure_ascii=False).encode('utf-8'))
        f.close()
        f = open(os.path.join(path, article.text), "w")

        if light:
            f.write(content_light.encode('utf-8'))
        else:
            f.write(content_long.encode('utf-8'))

        f.close()
        repo.index.add(['manifest.json', article.text])
        cm = repo.index.commit("Init Article")

        article.sha_draft = cm.hexsha
        return article