Skip to content

Commit

Permalink
Photologue + Django 1.10 compatibility (#24)
Browse files Browse the repository at this point in the history
* Update feeds.py

* Photologue compatibility

* Migrations for Photologue compatibility

* Photologue compatibility model + migrations

* Podcasting bugfix for photologue

* Translation corrected

* Photologue for runtests

* migration file removed
  • Loading branch information
urtzai authored and rizumu committed Mar 23, 2017
1 parent 89f74b2 commit 15524e0
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 38 deletions.
18 changes: 18 additions & 0 deletions podcasting/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,31 @@
import imagekit
easy_thumbnails = False
sorl = False
photologue = False
except ImportError:
pass

try:
import photologue
imagekit = False # noqa
easy_thumbnails = False
sorl = False
except ImportError:
pass

try:
import easy_thumbnails
imagekit = False # noqa
sorl = False
photologue = False
except ImportError:
pass

try:
import sorl
imagekit = False
easy_thumbnails = False # noqa
photologue = False
except ImportError:
pass

Expand All @@ -56,6 +67,10 @@ def add_root_elements(self, handler):
if imagekit:
itunes_sm_url = show.img_itunes_sm.url
itunes_lg_url = show.img_itunes_lg.url
elif photologue:
site = Site.objects.get_current()
itunes_sm_url = "%s%s" % (site.domain, show.original_image.get_img_itunes_sm_url())
itunes_lg_url = "%s%s" % (site.domain, show.original_image.get_img_itunes_lg_url())
elif easy_thumbnails:
aliases = settings.THUMBNAIL_ALIASES["podcasting.Show.original_image"]
thumbnailer = easy_thumbnails.files.get_thumbnailer(show.original_image)
Expand Down Expand Up @@ -118,6 +133,9 @@ def add_item_elements(self, handler, item):
if imagekit:
itunes_sm_url = episode.img_itunes_sm.url
itunes_lg_url = episode.img_itunes_lg.url
elif photologue:
itunes_sm_url = episode.original_image.get_img_itunes_sm_url()
itunes_lg_url = episode.original_image.get_img_itunes_lg_url()
elif easy_thumbnails:
aliases = settings.THUMBNAIL_ALIASES["podcasting.Episode.original_image"]
thumbnailer = easy_thumbnails.files.get_thumbnailer(episode.original_image)
Expand Down
14 changes: 8 additions & 6 deletions podcasting/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

class BaseShowForm(forms.ModelForm):

original_image = forms.ImageField(
widget=CustomAdminThumbnailWidget,
help_text=Show._meta.get_field("original_image").help_text)
if 'photologue' in settings.INSTALLED_APPS:
original_image = forms.ImageField(
widget=CustomAdminThumbnailWidget,
help_text=Show._meta.get_field("original_image").help_text)

publish = forms.BooleanField(
required=False,
Expand Down Expand Up @@ -70,9 +71,10 @@ def clean_publish(self):

class BaseEpisodeForm(forms.ModelForm):

original_image = forms.ImageField(
widget=CustomAdminThumbnailWidget,
help_text=Episode._meta.get_field("original_image").help_text)
if 'photologue' in settings.INSTALLED_APPS:
original_image = forms.ImageField(
widget=CustomAdminThumbnailWidget,
help_text=Episode._meta.get_field("original_image").help_text)

publish = forms.BooleanField(
required=False,
Expand Down
3 changes: 1 addition & 2 deletions podcasting/locale/eu/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ msgstr "Ez da Podcast hori existitzen."
#: templates/podcasting/_show_list.html:4
#: templates/podcasting/show_list.html:5
msgid "Podcast Shows"
msgstr "Podcast"
msgstr "Podcast saioak"

#: templates/podcasting/_show_list.html:17
msgid "There are no shows."
Expand All @@ -500,4 +500,3 @@ msgstr "Momentuko edizioa"
#: templates/podcasting/episode_list.html:5
msgid "Archive"
msgstr "Fitxategia"

98 changes: 68 additions & 30 deletions podcasting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
except ImportError:
custom_image_field = False

try:
from photologue.models import Photo
custom_image_field = True
except ImportError:
custom_image_field = False

if not custom_image_field:
try:
from sorl.thumbnail import ImageField # noqa
Expand Down Expand Up @@ -178,21 +184,37 @@ class Show(models.Model):
description, or itunes:keywords tags. This field can be up
to 4000 characters."""))

original_image = ImageField(
_("image"), upload_to=get_show_upload_folder, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))
if 'photologue' in settings.INSTALLED_APPS:
original_image = models.ForeignKey(Photo, verbose_name=_("image"), default=None, null=True, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))
else:
original_image = ImageField(
_("image"), upload_to=get_show_upload_folder, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))

if ResizeToFill:
admin_thumb_sm = ImageSpecField(source="original_image",
Expand Down Expand Up @@ -321,21 +343,37 @@ class Episode(models.Model):

tweet_text = models.CharField(_("tweet text"), max_length=140, editable=False)

original_image = ImageField(
_("image"), upload_to=get_episode_upload_folder, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))
if 'photologue' in settings.INSTALLED_APPS:
original_image = models.ForeignKey(Photo, verbose_name=_("image"), default=None, null=True, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))
else:
original_image = ImageField(
_("image"), upload_to=get_episode_upload_folder, blank=True, help_text=_("""
A podcast must have 1400 x 1400 pixel cover art in JPG or PNG
format using RGB color space. See our technical spec for
details. To be eligible for featuring on iTunes Stores,
choose an attractive, original, and square JPEG (.jpg) or
PNG (.png) image at a size of 1400x1400 pixels. The image
will be scaled down to 50x50 pixels at smallest in iTunes.
For reference see the <a
href="http://www.apple.com/itunes/podcasts/specs.html#metadata">iTunes
Podcast specs</a>.<br /><br /> For episode artwork to
display in iTunes, image must be <a
href="http://answers.yahoo.com/question/index?qid=20080501164348AAjvBvQ">
saved to file's <strong>metadata</strong></a> before
enclosure uploading!"""))

if ImageSpecField:
admin_thumb_sm = ImageSpecField(source="original_image",
Expand Down
7 changes: 7 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
import licenses
except ImportError:
licenses = False

try:
import photologue
except ImportError:
photologue = False


DEFAULT_SETTINGS = dict(
Expand Down Expand Up @@ -38,6 +43,8 @@
if licenses:
DEFAULT_SETTINGS["INSTALLED_APPS"] += ("licenses",)

if photologue:
DEFAULT_SETTINGS["INSTALLED_APPS"] += ("photologue",)

def runtests(*test_args):
if not settings.configured:
Expand Down

0 comments on commit 15524e0

Please sign in to comment.