Exemple #1
0
def remove_store(request, viewmode):
    uid = request.user.id
    mallid = request.POST.get("mallid")
    storeid = request.POST.get("storeid")
    floorid = request.POST.get("floorid", '')
    success_msg = ''
    error_msg = ''
    html = ''

    si = StoreImages.objects.get(store__id=storeid)
    sysutils.delete_file("%s/%s" % (MyGlobals.STOREIMG_ROOT % { 'uid':uid }, si.path))

    try:
        if not (mallid and storeid):
            raise Exception("invalid mallid or storeid: %s; %s" % (mallid, storeid))
        store = Store.objects.get(pk=storeid, mall__id=mallid)
        store.delete()

        if viewmode == 'mall':
            html = _getmallHTML(request, mallid)
        elif viewmode == 'floor':
            ctx = _getfloor(request, mallid, floorid)
            html = render_to_string("floor_snippet.html", ctx, context_instance=RequestContext(request))
        
        status = 'ok'
        success_msg = "We've removed the store '%s' from your mall." % (store.name)
    except Exception, e:
        print "error removing store: %s" % str(e)
        status = 'error'
        error_msg = "We're sorry, we're unable to remove this store at this time."
def remove_wishlistitem(request):
    uid = request.user.id
    wlitemid = request.POST.get("wlitemid")
    success_msg = ''
    error_msg = ''
    wishlistHTML = ''

    wlimage = WishlistImages.objects.get(wishlistitem__id=wlitemid)
    sysutils.delete_file("%s/%s" % (MyGlobals.WISHLISTIMG_ROOT % { 'uid':uid }, wlimage.path))

    try:
        store = WishlistItem.objects.get(pk=wlitemid)
        store.delete()

        wishlistHTML = _getwishlistHTML(request)
        status = 'ok'
        success_msg = "Item has been removed from your wishlist."
    except Exception, e:
        print "error removing item: %s" % str(e)
        status = 'error'
        error_msg = "We're sorry, we're unable to remove this item at this time."