def add_store(request, viewmode): uid = request.user.id mallid = request.POST.get('mallid') name = request.POST.get('name') url = request.POST.get('url') tags = request.POST.get('tags') is_private = request.POST.get('is_private', 'off') filename = request.POST.get('filename') width = int(request.POST.get('width')) height = int(request.POST.get('height')) addStoreFormHTML = '' mallHTML = '' success_msg = '' error_msg = '' try: floor = 0 pos = len(Store.objects.filter(mall__id=mallid, floor=0).order_by('position')) dom = urlutils.getDomainFromUrl(url) (domain, created) = Domain.objects.get_or_create(domain=dom) new_store = Store.objects.create(mall=Mall.objects.get(pk=mallid), name=name, url=url, floor=floor, position=pos, tags=tags, domain=domain, is_private=is_private) new_store.save() except Exception, e: status = 'error' error_msg = 'We\'re unable to add the store %s at this time' % name print "unable to create store: %s" % str(e)
def add_to_wishlist(request): uid = request.user.id name = "default" url = request.POST.get('url') tags = request.POST.get('tags') is_private = request.POST.get('is_private', 'off') filename = request.POST.get('filename') width = request.POST.get('width') height = request.POST.get('height') addToWishlistFormHTML = '' wishlistHTML = '' successMsg = '' errorMsg = '' try: wl = Wishlist.objects.get(user=request.user, name=name) dom = urlutils.getDomainFromUrl(url) (domain, created) = Domain.objects.get_or_create(domain=dom) position = len(WishlistItem.objects.filter(wishlist=wl)) wli = WishlistItem(wishlist=wl, url=url, tags=tags, domain=domain, is_private=is_private, position=position) wli.save() except Exception, e: status = 'error' errorMsg = 'Unable to add %s to your wishlist.' % url print "Unable to add %s to wishlist: %s" % (url, str(e))