def update_post_image_data(self, post, post_id):
        results = self.get_post_image_data(post_id)
        if results:
            original_photo_url = results

            source, filename = self.get_download_path_and_filename(
                original_photo_url,
                text_type(get_setting("ARTICLE_PHOTO_URL_PATTERN"))
            )
            try:
                self.download_image(source, filename)
                post.main_image = AttributedImage.objects.get(title=filename)
            except DownloadException as e:
                if e.response:
                    ImportDownloadError.objects.create(url=e.url, status_code=e.response.status_code)
                else:
                    ImportDownloadError.objects.create(url=e.url, status_code=404)
 def __init__(self, *args, **kwargs):
     super(Command, self).__init__(*args, **kwargs)
     self.connection = None
     self.image_download_domains = get_setting("IMAGE_DOWNLOAD_DOMAINS")
     self.category_names_to_id = None
     self.category_id_to_slug = None
Exemplo n.º 3
0
 def testLoadingSetDjangoSetting(self):
     with self.settings(WP_IMPORTER_SOME_VARIABLE_SET_IN_SETTINGS='Something awesome'):
         value = get_setting("SOME_VARIABLE_SET_IN_SETTINGS")
         self.assertEqual("Something awesome", value)
Exemplo n.º 4
0
 def testLoadingSetEnvironmentVariable(self):
     environ["WP_IMPORTER_SOME_VARIABLE"] = "This value"
     value = get_setting("SOME_VARIABLE")
     self.assertEqual("This value", value)