Fix regression that broke replacing SR-image of same CSS name.

This commit is contained in:
Andre D
2011-11-01 07:55:36 -04:00
committed by Neil Williams
parent acf5d348ed
commit 4eaaf5d451
2 changed files with 7 additions and 13 deletions

View File

@@ -1196,9 +1196,7 @@ class ApiController(RedditController):
errors['BAD_CSS_NAME'] = _("bad image name")
if c.site.images and add_image_to_sr:
if c.site.images.has_key(name):
errors['IMAGE_ERROR'] = _("An image with that name already exists")
elif c.site.get_num_images() >= g.max_sr_images:
if c.site.get_num_images() >= g.max_sr_images:
errors['IMAGE_ERROR'] = _("too many images (you only get %d)") % g.max_sr_images
if any(errors.values()):

View File

@@ -43,7 +43,6 @@ import os.path
import random
class SubredditExists(Exception): pass
class ImageExists(Exception): pass
class Subreddit(Thing, Printable):
# Note: As of 2010/03/18, nothing actually overrides the static_path
@@ -582,15 +581,12 @@ class Subreddit(Thing, Printable):
if max_num is not None and self.get_num_images() >= max_num:
raise ValueError, "too many images"
if not self.images.has_key(name):
# copy and blank out the images list to flag as _dirty
l = self.images
self.images = None
# update the dictionary and rewrite to images attr
l[name] = url
self.images = l
else:
raise ImageExists, "image already exists"
# copy and blank out the images list to flag as _dirty
l = self.images
self.images = None
# update the dictionary and rewrite to images attr
l[name] = url
self.images = l
def del_image(self, name):
"""