def common_design_update(request, success="/", nick=None): if not nick: nick = request.user.nick view = api.actor_get(api.ROOT, nick) if request.POST: try: validate.nonce(request, 'update_design') color = request.POST.get('bg_color') repeat = request.POST.get('bg_repeat', 'no-repeat') if not repeat: repeat = '' img = request.FILES.get('bg_image') img_url = None if img: img_url = api.background_upload(request.user, nick, img.read()) api.background_set_actor(request.user, nick, img_url, color, repeat) return util.RedirectFlash(success, 'Thiết lập về màu nền/ảnh nền đã được cập nhật lại.') except: exception.handle_exception(request) if request.GET and 'restore' in request.GET: api.background_clear_actor(request.user, nick) return util.RedirectFlash(success, 'Thiết lập ảnh nền/màu nền đã được khôi phục về trạng thái mặc định.') return None
def common_design_update(request, nick): view = api.actor_get(api.ROOT, nick) if request.POST: try: validate.nonce(request, 'update_design') color = request.POST.get('bg_color') repeat = request.POST.get('bg_repeat', 'no-repeat') if not repeat: repeat = '' img = request.FILES.get('bg_image') img_url = None if img: img_url = api.background_upload(request.user, nick, img.read()) api.background_set_actor(request.user, nick, img_url, color, repeat) return util.RedirectFlash(view.url() + '/settings/design', 'design updated') except: exception.handle_exception(request) if request.GET and 'restore' in request.GET: api.background_clear_actor(request.user, nick) return util.RedirectFlash(view.url() + '/settings/design', 'design updated') return None
def common_listings(request, nick, listings, template_name): view = api.actor_get(api.ROOT, nick) if request.POST: logging.info("Post Request: %s" % request.POST) try: # Add Listing Action logging.info("Action: %s" % request.POST.get("action")) if request.POST.get("action") == "add_listing": author = view.nick logging.info("Calling Create Listing - Params: %s, Author: %s" % (request.POST, author)) address = request.POST.get("address") price = request.POST.get("price") baths = request.POST.get("baths") beds = request.POST.get("beds") size = request.POST.get("size") description = request.POST.get("description") property_type = request.POST.get("property_type") amenities = request.POST.get("amenities") tag = request.POST.get("tag") galleryUrl = request.POST.get("galleryUrl") handled = api.add_listing(address, price, baths, beds, size, description, property_type, amenities, author, tag, galleryUrl) # Edit Listings Page if request.POST.get("action") == "edit_listing": author = view.nick logging.info("Calling Edit Listing - Params: %s, Author: %s, Key: %s" % (request.POST, author, request.POST.get("id"))) id = request.POST.get("id") address = request.POST.get("address") price = request.POST.get("price") baths = request.POST.get("baths") beds = request.POST.get("beds") size = request.POST.get("size") description = request.POST.get("description") property_type = request.POST.get("property_type") amenities = request.POST.get("amenities") tag = request.POST.get("tag") galleryUrl = request.POST.get("galleryUrl") handled = api.edit_listing(id, address, price, baths, beds, size, description, property_type, amenities, author, tag, galleryUrl) return util.RedirectFlash(view.url() + '/settings/listings', 'listings updated') except: exception.handle_exception(request) if request.GET and 'restore' in request.GET: api.background_clear_actor(request.user, nick) return util.RedirectFlash(view.url() + '/settings/listings', 'listings updated') model = {} if request.GET.get("action") == "edit" and request.GET.get("id"): editListingId = request.GET.get("id") if editListingId: key = Key(editListingId) logging.info("ID: %s" % key) obj = db.get(key) model['edit'] = obj model['listings'] = listings logging.info("Model: %s" % model) t = loader.get_template(template_name) return http.HttpResponse(t.render(template.RequestContext(request, model)))
def common_listings(request, nick, listings, template_name): view = api.actor_get(api.ROOT, nick) if request.POST: logging.info("Post Request: %s" % request.POST) try: # Add Listing Action logging.info("Action: %s" % request.POST.get("action")) if request.POST.get("action") == "add_listing": author = view.nick logging.info( "Calling Create Listing - Params: %s, Author: %s" % (request.POST, author)) address = request.POST.get("address") price = request.POST.get("price") baths = request.POST.get("baths") beds = request.POST.get("beds") size = request.POST.get("size") description = request.POST.get("description") property_type = request.POST.get("property_type") amenities = request.POST.get("amenities") tag = request.POST.get("tag") galleryUrl = request.POST.get("galleryUrl") handled = api.add_listing(address, price, baths, beds, size, description, property_type, amenities, author, tag, galleryUrl) # Edit Listings Page if request.POST.get("action") == "edit_listing": author = view.nick logging.info( "Calling Edit Listing - Params: %s, Author: %s, Key: %s" % (request.POST, author, request.POST.get("id"))) id = request.POST.get("id") address = request.POST.get("address") price = request.POST.get("price") baths = request.POST.get("baths") beds = request.POST.get("beds") size = request.POST.get("size") description = request.POST.get("description") property_type = request.POST.get("property_type") amenities = request.POST.get("amenities") tag = request.POST.get("tag") galleryUrl = request.POST.get("galleryUrl") handled = api.edit_listing(id, address, price, baths, beds, size, description, property_type, amenities, author, tag, galleryUrl) return util.RedirectFlash(view.url() + '/settings/listings', 'listings updated') except: exception.handle_exception(request) if request.GET and 'restore' in request.GET: api.background_clear_actor(request.user, nick) return util.RedirectFlash(view.url() + '/settings/listings', 'listings updated') model = {} if request.GET.get("action") == "edit" and request.GET.get("id"): editListingId = request.GET.get("id") if editListingId: key = Key(editListingId) logging.info("ID: %s" % key) obj = db.get(key) model['edit'] = obj model['listings'] = listings logging.info("Model: %s" % model) t = loader.get_template(template_name) return http.HttpResponse(t.render(template.RequestContext(request, model)))