too many ways we might add to wishlist to test for. adding argument for notification. [[#37780515]
parent
02145b22b5
commit
ae9a541ed5
|
@ -296,7 +296,7 @@ def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id
|
|||
match = re.search('/show/(\d+)', link)
|
||||
if match:
|
||||
identifier= models.Identifier.get_or_add(type = 'gdrd', value = match.group(1), edition = edition, work = edition.work)
|
||||
user.wishlist.add_work(edition.work, 'goodreads')
|
||||
user.wishlist.add_work(edition.work, 'goodreads', True)
|
||||
logger.info("Work with isbn %s added to wishlist.", isbn)
|
||||
else:
|
||||
logger.error("unable to extract goodreads id from %s", link)
|
||||
|
|
|
@ -228,7 +228,7 @@ def load_librarything_into_wishlist(user, lt_username, max_books=None):
|
|||
identifier= models.Identifier.get_or_add(type = 'ltwk', value = book['work_id'], work = edition.work)
|
||||
if book['lc_call_number']:
|
||||
identifier= models.Identifier.get_or_add(type = 'lccn', value = book['lc_call_number'], edition = edition, work = edition.work)
|
||||
user.wishlist.add_work(edition.work, 'librarything')
|
||||
user.wishlist.add_work(edition.work, 'librarything', True)
|
||||
if edition.new:
|
||||
tasks.populate_edition.delay(edition.isbn_13)
|
||||
logger.info("Work with isbn %s added to wishlist.", isbn)
|
||||
|
|
|
@ -928,7 +928,7 @@ class Wishlist(models.Model):
|
|||
def __unicode__(self):
|
||||
return "%s's Wishlist" % self.user.username
|
||||
|
||||
def add_work(self, work, source):
|
||||
def add_work(self, work, source, notify=False):
|
||||
try:
|
||||
w = Wishes.objects.get(wishlist=self,work=work)
|
||||
except:
|
||||
|
@ -936,7 +936,7 @@ class Wishlist(models.Model):
|
|||
work.update_num_wishes()
|
||||
# only send notification in case of new wishes
|
||||
# and only when they result from user action, not (e.g.) our tests
|
||||
if source=='user' or source=='pledging':
|
||||
if notify:
|
||||
wishlist_added.send(sender=self, work=work, supporter=self.user)
|
||||
|
||||
def remove_work(self, work):
|
||||
|
|
|
@ -987,9 +987,10 @@ class PledgeCompleteView(TemplateView):
|
|||
correct_transaction_type = False
|
||||
|
||||
# add the work corresponding to the Transaction on the user's wishlist if it's not already on the wishlist
|
||||
# fire add-wishlist notification if needed
|
||||
if user is not None and correct_transaction_type and (campaign is not None) and (work is not None):
|
||||
# ok to overwrite Wishes.source?
|
||||
user.wishlist.add_work(work, 'pledging')
|
||||
user.wishlist.add_work(work, 'pledging', True)
|
||||
|
||||
worklist = slideshow(8)
|
||||
works = worklist[:4]
|
||||
|
@ -1512,7 +1513,7 @@ def wishlist(request):
|
|||
if edition.new:
|
||||
# add related editions asynchronously
|
||||
tasks.populate_edition.delay(edition.isbn_13)
|
||||
request.user.wishlist.add_work(edition.work,'user')
|
||||
request.user.wishlist.add_work(edition.work,'user', True)
|
||||
except bookloader.LookupFailure:
|
||||
logger.warning("failed to load googlebooks_id %s" % googlebooks_id)
|
||||
except Exception, e:
|
||||
|
@ -1540,7 +1541,7 @@ def wishlist(request):
|
|||
except models.WasWork.DoesNotExist:
|
||||
raise Http404
|
||||
|
||||
request.user.wishlist.add_work(work,'user')
|
||||
request.user.wishlist.add_work(work,'user', True)
|
||||
return HttpResponseRedirect('/')
|
||||
|
||||
class InfoPageView(TemplateView):
|
||||
|
|
Loading…
Reference in New Issue