def POST(self): inputs = sh.inputs() assert inputs.has_key('model_name'), u'请指定需要裁剪的数据类型' assert inputs.has_key('model_id'), u'请指定需要裁剪的数据ID' assert inputs.has_key('column_name'), u'请指定裁剪的列名' assert int(float(inputs.get('region_width', '0'))) > 0 assert int(float(inputs.get('region_height', '0'))) > 0 model = sh.model(inputs.model_name) item = model.get(inputs.model_id) image = item.image real_width, real_height = sh.imageSize(image.url) # 图片的真实宽高 crop = inputs.crop region_width = int(float(inputs.region_width)) # 选择区域的宽度 region_height = int(float(inputs.region_height)) # 选择区域的高度 start_x = int(crop.split()[0]) # 选中的起始位置 start_y = int(crop.split()[1]) region_x = int(crop.split()[2])# 选中的宽度 region_y = int(crop.split()[3]) # 选中的高度 # convert 裁剪区域 region = '%dx%d+%d+%d' % (region_x * real_width / region_width, region_y * real_height / region_height, real_width * start_x / region_width, real_height * start_y / region_height) path = sh.urlToPath(image.url) os.system('convert %s -crop %s %s' % (path, region, path+'.crop')) model.update(inputs.model_id, {inputs.column_name: crop}) return sh.refresh()
def POST(self,inputs=None): if inputs is None: inputs = sh.inputs() assert(inputs.has_key('model_name')) assert(inputs.has_key('model_id')) assert(sh.session.is_admin) model = sh.model(inputs.model_name) model.delete(int(inputs.model_id)) return sh.refresh()
def POST(self, inputs=None): if inputs is None: inputs = sh.inputs() assert (inputs.has_key('model_name')) assert (inputs.has_key('model_id')) assert (sh.session.is_admin) model = sh.model(inputs.model_name) model.delete(int(inputs.model_id)) return sh.refresh()
def POST(self): inputs = sh.inputs() assert inputs.has_key('model_name'), u'请指定需要裁剪的数据类型' assert inputs.has_key('model_id'), u'请指定需要裁剪的数据ID' assert inputs.has_key('column_name'), u'请指定裁剪的列名' assert int(float(inputs.get('region_width', '0'))) > 0 assert int(float(inputs.get('region_height', '0'))) > 0 model = sh.model(inputs.model_name) item = model.get(inputs.model_id) image = item.image real_width, real_height = sh.imageSize(image.url) # 图片的真实宽高 crop = inputs.crop region_width = int(float(inputs.region_width)) # 选择区域的宽度 region_height = int(float(inputs.region_height)) # 选择区域的高度 start_x = int(crop.split()[0]) # 选中的起始位置 start_y = int(crop.split()[1]) region_x = int(crop.split()[2]) # 选中的宽度 region_y = int(crop.split()[3]) # 选中的高度 # convert 裁剪区域 region = '%dx%d+%d+%d' % (region_x * real_width / region_width, region_y * real_height / region_height, real_width * start_x / region_width, real_height * start_y / region_height) path = sh.urlToPath(image.url) os.system('convert %s -crop %s %s' % (path, region, path + '.crop')) model.update(inputs.model_id, {inputs.column_name: crop}) # 删除以前裁剪图片的各种尺寸副本 os.system('rm %s.crop_*' % path) return sh.refresh()
def POST(self, inputs=None): if not inputs: inputs = sh.inputs() self._update(inputs) return sh.refresh()
def POST(self, name): inputs = sh.inputs() assert inputs.has_key('value') key = self.prefix_key + name sh.setSiteConfig(key, inputs.value) return sh.refresh()
def POST(self,inputs=None): self._delete(inputs) return sh.refresh()
def POST(self, name): inputs = sh.inputs() assert inputs.has_key('value') key = self.prefix_key + name sh.setSiteConfig(key, inputs.value) return sh.refresh()
def POST(self,inputs=None): self._update(inputs) return sh.refresh()
def POST(self, inputs=None): if not inputs: inputs = sh.inputs() self._update(inputs) return sh.refresh()
def POST(self, inputs=None): self._insert(inputs) return sh.refresh()
def POST(self,inputs=None): self._insert(inputs) return sh.refresh()