def on_admin_toggle_pin(self, request): if request.cookies.get('cookie_name') is None: return redirect('/') img_id = request.args.get('id') if img_id is not None: cvtools.toggle_pinned(img_id) return redirect(request.referrer)
def on_admin_toggle_multiple_pin(self, request): if request.cookies.get('cookie_name') is None: return redirect('/') checked = request.args.getlist('checked[]') for img_id in checked: if img_id is not None: cvtools.toggle_pinned(img_id) return redirect(request.referrer)
def on_admin_multiple_image_action(self, request): if request.cookies.get('cookie_name') is None: return redirect('/') action = request.args.get('action') checked = request.args.getlist('checked[]') error = 0 if action == "pin": for img_id in checked: if img_id is not None: if cvtools.is_pinned(img_id) is False: cvtools.toggle_pinned(img_id) else: continue elif action == "unpin": for img_id in checked: if img_id is not None: if cvtools.is_pinned(img_id) is True: cvtools.toggle_pinned(img_id) else: continue elif action == "remove": for img_id in checked: if img_id is not None: image, count = cvtools.get_list(None, None, img_id) if len(image) > 0: image = image[0] if image['target_type'] == conf.TAR_TYPE_IMAGE: tar = conf.UPLOAD_DIR_TAR_IMG + '/' + image['target'] elif image['target_type'] == conf.TAR_TYPE_VIDEO: tar = conf.UPLOAD_DIR_TAR_VIDEO + '/' + image['target'] else: tar = None if not cvtools.remove_image(img_id, conf.UPLOAD_DIR_SRC + '/' + image['src_name'], tar): error = 1 return redirect(request.referrer)