Ejemplo n.º 1
0
    def rename_entry(self, old_path, new_path, conf):
        """
        Rename entry identified by old_path to new_path.

        """
        file = models.File.objects.get(path=old_path)
        file.path = new_path
        file.save()
        if conf['file_as_name']:
            new_name = utils.name_from_file(new_path)
            entry = self.model.objects.get(file=file)
            entry.name = new_name
            entry.save()
Ejemplo n.º 2
0
    def rename_entry(self, old_path, new_path, conf):
        """
        Rename entry identified by old_path to new_path.

        """
        file = models.File.objects.get(path=old_path)
        file.path = new_path
        file.save()
        if conf['file_as_name']:
            new_name = utils.name_from_file(new_path)
            entry = self.model.objects.get(file=file)
            entry.name = new_name
            entry.save()
Ejemplo n.º 3
0
 def make_data(self, template, path, conf):
     data = self.optional.copy()
     if conf['file_as_name']:
         data['name'] = utils.name_from_file(path)
     context = Context()
     body = template.render(context)
     data.update(context.get('vars', {}))
     data['body'] = utils.markdown_convert(body)
     missing = self.missing_required_keys(data)
     if missing:
         logger.error("%s: the following required fields are missing: %s",
                      path, ', '.join(missing))
         return
     return data
Ejemplo n.º 4
0
 def make_data(self, template, path, conf):
     data = self.optional.copy()
     if conf['file_as_name']:
         data['name'] = utils.name_from_file(path)
     context = Context()
     body = template.render(context)
     data.update(context.get('vars', {}))
     data['body'] = utils.markdown_convert(body)
     missing = self.missing_required_keys(data)
     if missing:
         logger.error("%s: the following required fields are missing: %s",
                      path, ', '.join(missing))
         return
     return data
Ejemplo n.º 5
0
        # get Blog model object
        try:
            blog = models.Blog.objects.get(name=blog_info['blog'],
                                           language=blog_info['language'])
        except models.Blog.DoesNotExist:
            logger.error("blog '%s' doesn't exist", blog_info['blog'])
            continue

        # iterate through all comment files in the directory and import them to
        # the database
        for comment_file in files:
            if not comment_file.endswith('.yaml'):
                continue
            comment_file = os.path.join(root, comment_file)
            name = utils.name_from_file(comment_file)
            try:
                post = models.Post.objects.get(blog=blog, name=name)
            except models.Post.DoesNotExist:
                logger.error("post '%s' doesn't exist", name)
                continue
            comment_files_count += 1

            comments = load_comments(comment_file)
            comments_count += import_comments_list(comments, post)

    for root, dirs, files in os.walk(settings.PAGES_DIR):

        if not root.endswith('/comments'):
            continue
Ejemplo n.º 6
0
        # get Blog model object
        try:
            blog = models.Blog.objects.get(name=blog_info['blog'],
                                           language=blog_info['language'])
        except models.Blog.DoesNotExist:
            logger.error("blog '%s' doesn't exist", blog_info['blog'])
            continue

        # iterate through all comment files in the directory and import them to
        # the database
        for comment_file in files:
            if not comment_file.endswith('.yaml'):
                continue
            comment_file = os.path.join(root, comment_file)
            name = utils.name_from_file(comment_file)
            try:
                post = models.Post.objects.get(blog=blog, name=name)
            except models.Post.DoesNotExist:
                logger.error("post '%s' doesn't exist", name)
                continue
            comment_files_count += 1

            comments = load_comments(comment_file)
            comments_count += import_comments_list(comments, post)

    for root, dirs, files in os.walk(settings.PAGES_DIR):

        if not root.endswith('/comments'):
            continue