def ApplyNewFeedSubmit(self): max_id = Session.query(func.max(ApplyNewFeed.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] stype_desc = request.params['stype_desc'] a = ApplyNewFeed(max_id + 1, pm_names=pm_names, pm_emails=pm_emails, dev_names=request.params['dev_names'], dev_emails=request.params['dev_emails'], stype_desc=stype_desc, stype_text=request.params['stype_text'], push_news=int(request.params['push_news']), push_mini=int(request.params['push_mini']), news_merge_desc=request.params['news_merge_desc'], mini_merge_desc=request.params['mini_merge_desc'], lifetime=int(request.params['lifetime']), status=0, apply_time=int(time.time())) Session.add(a) Session.commit() self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def TplApplyHandled(self): a = self.apply_tpls_.filter_by(apply_id = int(request.params['apply_id'])).first() if a: a.status = 1 Session.commit() return ''
def ApplyNewFeedSubmit(self): max_id = Session.query(func.max(ApplyNewFeed.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] stype_desc = request.params['stype_desc'] a = ApplyNewFeed(max_id + 1, pm_names = pm_names, pm_emails = pm_emails, dev_names = request.params['dev_names'], dev_emails = request.params['dev_emails'], stype_desc = stype_desc, stype_text = request.params['stype_text'], push_news = int(request.params['push_news']), push_mini = int(request.params['push_mini']), news_merge_desc = request.params['news_merge_desc'], mini_merge_desc = request.params['mini_merge_desc'], lifetime = int(request.params['lifetime']), status = 0, apply_time = int(time.time()) ) Session.add(a) Session.commit() self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def AddStypeVersion(self): stype = int(request.params['stype']) max_ver = Session.query(func.max(DataVersion.version)).filter_by(stype = stype).scalar() or 0 vc = DataVersion(stype, max_ver + 1, 0, 0) Session.add(vc) Session.commit() return str(max_ver + 1)
def AddStypeVersion(self): stype = int(request.params['stype']) max_ver = Session.query(func.max( DataVersion.version)).filter_by(stype=stype).scalar() or 0 vc = DataVersion(stype, max_ver + 1, 0, 0) Session.add(vc) Session.commit() return str(max_ver + 1)
def SaveTemplate(self): sk = TplView(request.params['tpl_id'], view = request.params['view'], status = 0, template = urllib2.unquote(str(request.params['tpl']))) Session.merge(sk) Session.commit() return '保存模板成功'
def VersionApplyHandled(self): a = self.apply_versions_.filter_by( apply_id=int(request.params['apply_id'])).first() if a: a.status = 1 Session.commit() return ''
def SaveTemplate(self): sk = TplView(request.params['tpl_id'], view=request.params['view'], status=0, template=urllib2.unquote(str(request.params['tpl']))) Session.merge(sk) Session.commit() return '保存模板成功'
def AddVersionTpl(self): max_id = Session.query(func.max(VersionTplMapping.tpl_id)).scalar() or 1 tpl_id = max_id + 1 feed_key = VersionTplMapping(tpl_id = tpl_id, stype = request.params['stype'], version = request.params['version']) Session.add(feed_key) Session.commit() return str(tpl_id)
def RemoveDataVersion(self): stype = int(request.params['stype']) version = int(request.params['version']) if stype <= 0 or version <= 0: return "参数错误" o = self.data_version_.filter_by(stype=stype, version=version).first() Session.delete(o) Session.commit() return '成功删除版本' + str(version)
def AddVersionTpl(self): max_id = Session.query(func.max( VersionTplMapping.tpl_id)).scalar() or 1 tpl_id = max_id + 1 feed_key = VersionTplMapping(tpl_id=tpl_id, stype=request.params['stype'], version=request.params['version']) Session.add(feed_key) Session.commit() return str(tpl_id)
def UserApplySubmit(self): pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] feed_desc = request.params['feed_desc'] apply_id = 0 if "apply_id" in request.params: apply_id = int(request.params['apply_id']) print "apply_id", apply_id if "apply_id" in request.params: a = self.user_applies_.filter_by(apply_id = apply_id).first() if a: a.pm_names = pm_names a.pm_emails = pm_emails a.dev_names = request.params['dev_names'] a.dev_emails = request.params['dev_emails'] a.feed_stype = int(request.params['feed_stype']) a.feed_desc = feed_desc a.apply_type = int(request.params['apply_type']) a.apply_desc = request.params['apply_desc'] a.push_news = int(request.params['push_news']) a.push_mini = int(request.params['push_mini']) a.news_merge_desc = request.params['news_merge_desc'] a.mini_merge_desc = request.params['mini_merge_desc'] a.status = 0 a.apply_time = int(time.time()) else: return '申请id不群在' else: max_id = Session.query(func.max(UserApply.apply_id)).scalar() or 0 a = UserApply(max_id + 1, pm_names = pm_names, pm_emails = pm_emails, dev_names = request.params['dev_names'], dev_emails = request.params['dev_emails'], feed_stype = int(request.params['feed_stype']), feed_desc = feed_desc, apply_type = int(request.params['apply_type']), apply_desc = request.params['apply_desc'], push_news = int(request.params['push_news']), push_mini = int(request.params['push_mini']), news_merge_desc = request.params['news_merge_desc'], mini_merge_desc = request.params['mini_merge_desc'], status = 0, apply_time = int(time.time()) ) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def UserApplySubmit(self): pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] feed_desc = request.params['feed_desc'] apply_id = 0 if "apply_id" in request.params: apply_id = int(request.params['apply_id']) print "apply_id", apply_id if "apply_id" in request.params: a = self.user_applies_.filter_by(apply_id=apply_id).first() if a: a.pm_names = pm_names a.pm_emails = pm_emails a.dev_names = request.params['dev_names'] a.dev_emails = request.params['dev_emails'] a.feed_stype = int(request.params['feed_stype']) a.feed_desc = feed_desc a.apply_type = int(request.params['apply_type']) a.apply_desc = request.params['apply_desc'] a.push_news = int(request.params['push_news']) a.push_mini = int(request.params['push_mini']) a.news_merge_desc = request.params['news_merge_desc'] a.mini_merge_desc = request.params['mini_merge_desc'] a.status = 0 a.apply_time = int(time.time()) else: return '申请id不群在' else: max_id = Session.query(func.max(UserApply.apply_id)).scalar() or 0 a = UserApply(max_id + 1, pm_names=pm_names, pm_emails=pm_emails, dev_names=request.params['dev_names'], dev_emails=request.params['dev_emails'], feed_stype=int(request.params['feed_stype']), feed_desc=feed_desc, apply_type=int(request.params['apply_type']), apply_desc=request.params['apply_desc'], push_news=int(request.params['push_news']), push_mini=int(request.params['push_mini']), news_merge_desc=request.params['news_merge_desc'], mini_merge_desc=request.params['mini_merge_desc'], status=0, apply_time=int(time.time())) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def UpdateStypeVersionTestId(self): stype = int(request.params['stype']) version = int(request.params['version']) tpl_id = int(request.params['tpl_id']) if stype > 0 and version > 0 and tpl_id >= 0: ver = self.data_version_.filter_by(stype = stype, version = version).first() if ver: ver.test_tpl_id = tpl_id else: ver = DataVersion(stype, version, tpl_id, 0) Session.add(ver) Session.commit() return '保存成功' + str(ver.test_tpl_id) return '参数有错误'
def SetUserApplyHandled(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' apply_id = int(request.params['apply_id']) if apply_id > 0: apply = self.user_applies_.filter_by(apply_id = apply_id).first() if apply: apply.status = 1 Session.commit() return "设置成功" else: return '该申请不存在' return "apply_id参数错误"
def SetUserApplyHandled(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' apply_id = int(request.params['apply_id']) if apply_id > 0: apply = self.user_applies_.filter_by(apply_id=apply_id).first() if apply: apply.status = 1 Session.commit() return "设置成功" else: return '该申请不存在' return "apply_id参数错误"
def SaveStypeConfig(self): if self.UserRight(request, response) < 2: return '{"status":1, "desc":"没有操作权限, 请确保管理员帐号登录"}' cfg = self.stype_config_.filter_by( stype=int(request.params['stype'])).first() if not cfg: cfg = StypeConfig( stype=int(request.params['stype']), weight=int(request.params['weight']), type=int(request.params['type']), ptype=int(request.params['ptype']), description=request.params['title'], push_feed_flags=int(request.params['push_flags']), news_merge_type=int(request.params['news_merge_type']), mini_merge_type=int(request.params['mini_merge_type']), is_update_time_on_merge=int( request.params['update_time_on_merge']), is_custom_expr=int(request.params['custom_expr']), persist_body=int(request.params['save_content']), persist_feeddb=int(request.params['save_feed_db']), lifetime=int(request.params['lifetime']), daily_quota=int(request.params['daily_quota'])) Session.add(cfg) if 'apply_id' in request.params: apply_id = int(request.params['apply_id']) self.FeedApplyHandled(apply_id) else: if int(request.params['is_new']) > 0: return '{"status":1, "desc":"新建子类型保存失败(已经存在)"}' print cfg.is_update_time, cfg.is_custom_expr cfg.is_persist_content = int(request.params['save_content']) cfg.ptype = int(request.params['ptype']) cfg.description = request.params['title'] cfg.push_flag = int(request.params['push_flags']) cfg.news_merge_type = int(request.params['news_merge_type']) cfg.mini_merge_type = int(request.params['mini_merge_type']) cfg.is_update_time = int(request.params['update_time_on_merge']) cfg.is_custom_expr = int(request.params['custom_expr']) cfg.is_persist_content = int(request.params['save_content']) cfg.is_persist_feeddb = int(request.params['save_feed_db']) cfg.lifetime = int(request.params['lifetime']) cfg.daily_quota = int(request.params['daily_quota']) cfg.weight = request.params['weight'] Session.commit() return '{"status":0, "desc":"保存成功"}'
def RemoveTemplate(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' tpl_id = int(request.params['tpl_id']) view = int(request.params['view']) if tpl_id <= 0 or view < 0: return '参数错误' tpl = self.tpl_views_.filter_by(tpl_id=tpl_id, view=view).first() Session.delete(tpl) Session.commit() return '删除模板成功'
def RemoveTemplate(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' tpl_id = int(request.params['tpl_id']) view = int(request.params['view']) if tpl_id <= 0 or view < 0: return '参数错误' tpl = self.tpl_views_.filter_by(tpl_id = tpl_id, view = view).first() Session.delete(tpl) Session.commit() return '删除模板成功'
def UpdateStypeVersionTestId(self): stype = int(request.params['stype']) version = int(request.params['version']) tpl_id = int(request.params['tpl_id']) if stype > 0 and version > 0 and tpl_id >= 0: ver = self.data_version_.filter_by(stype=stype, version=version).first() if ver: ver.test_tpl_id = tpl_id else: ver = DataVersion(stype, version, tpl_id, 0) Session.add(ver) Session.commit() return '保存成功' + str(ver.test_tpl_id) return '参数有错误'
def UpdateTplViewStatus(self): if self.UserRight(request, response) < 2: return '没有操作权限, 请确保管理员帐号登录' tpl_id = int(request.params['tpl_id']) view = int(request.params['view']) status = int(request.params['status']) if tpl_id > 0: tpl = self.tpl_views_.filter_by(tpl_id = tpl_id, view = view).first() if tpl: tpl.status = status Session.commit() return '成功保存状态为 : ' + str(tpl.status) else: return '视图 ' + str(view) + '不存在' return '参数有错误'
def UpdateTplViewStatus(self): if self.UserRight(request, response) < 2: return '没有操作权限, 请确保管理员帐号登录' tpl_id = int(request.params['tpl_id']) view = int(request.params['view']) status = int(request.params['status']) if tpl_id > 0: tpl = self.tpl_views_.filter_by(tpl_id=tpl_id, view=view).first() if tpl: tpl.status = status Session.commit() return '成功保存状态为 : ' + str(tpl.status) else: return '视图 ' + str(view) + '不存在' return '参数有错误'
def SaveStypeConfig(self): if self.UserRight(request, response) < 2: return '{"status":1, "desc":"没有操作权限, 请确保管理员帐号登录"}' cfg = self.stype_config_.filter_by(stype=int(request.params['stype'])).first() if not cfg: cfg = StypeConfig(stype = int(request.params['stype']), weight = int(request.params['weight']), type = int(request.params['type']), ptype = int(request.params['ptype']), description = request.params['title'], push_feed_flags = int(request.params['push_flags']), news_merge_type = int(request.params['news_merge_type']), mini_merge_type = int(request.params['mini_merge_type']), is_update_time_on_merge = int(request.params['update_time_on_merge']), is_custom_expr = int(request.params['custom_expr']), persist_body = int(request.params['save_content']), persist_feeddb = int(request.params['save_feed_db']), lifetime = int(request.params['lifetime']), daily_quota = int(request.params['daily_quota'])) Session.add(cfg) if 'apply_id' in request.params: apply_id = int(request.params['apply_id']) self.FeedApplyHandled(apply_id) else: if int(request.params['is_new']) > 0: return '{"status":1, "desc":"新建子类型保存失败(已经存在)"}' print cfg.is_update_time, cfg.is_custom_expr cfg.is_persist_content = int(request.params['save_content']) cfg.ptype = int(request.params['ptype']) cfg.description = request.params['title'] cfg.push_flag = int(request.params['push_flags']) cfg.news_merge_type = int(request.params['news_merge_type']) cfg.mini_merge_type = int(request.params['mini_merge_type']) cfg.is_update_time = int(request.params['update_time_on_merge']) cfg.is_custom_expr = int(request.params['custom_expr']) cfg.is_persist_content = int(request.params['save_content']) cfg.is_persist_feeddb = int(request.params['save_feed_db']) cfg.lifetime = int(request.params['lifetime']) cfg.daily_quota = int(request.params['daily_quota']) cfg.weight = request.params['weight'] Session.commit() return '{"status":0, "desc":"保存成功"}'
def UpdateStypeVersionUsingId(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype = int(request.params['stype']) version = int(request.params['version']) tpl_id = int(request.params['tpl_id']) if stype > 0 and version > 0 and tpl_id >= 0: ver = self.data_version_.filter_by(stype = stype, version = version).first() if ver: ver.using_tpl_id = tpl_id else: ver = DataVersion(stype, version, 0, tpl_id, 0) Session.add(ver) Session.commit() return '保存成功' + str(ver.using_tpl_id) return '参数有错误'
def UpdateStypeVersionUsingId(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype = int(request.params['stype']) version = int(request.params['version']) tpl_id = int(request.params['tpl_id']) if stype > 0 and version > 0 and tpl_id >= 0: ver = self.data_version_.filter_by(stype=stype, version=version).first() if ver: ver.using_tpl_id = tpl_id else: ver = DataVersion(stype, version, 0, tpl_id, 0) Session.add(ver) Session.commit() return '保存成功' + str(ver.using_tpl_id) return '参数有错误'
def SaveVersionKeys(self): stype = int(request.params['stype']) version = int(request.params['version']) if stype <= 0 or version <= 0: return "参数错误" o = self.data_version_.filter_by(stype=stype, version=version).first() if o: o.keys_xml = request.params['kl'] o.news_merge_by = request.params['news_merge_by'] o.mini_merge_by = request.params['mini_merge_by'] o.source_by = request.params['source_by'] o.psource_by = request.params['psource_by'] o.actor_by = request.params['actor_by'] o.togroup_by = request.params['togroup_by'] o.dispatch_expr = urllib2.unquote(str(request.params['dispatch_expr'])) Session.commit() return '保存成功' else: return '该版本不存在'
def UpdateStypeVersionStatus(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype = int(request.params['stype']) version = int(request.params['version']) status = int(request.params['status']) if status >= 2 and self.UserRight(request, response) < 3: return '您没有上线权限' if stype > 0 and version > 0: ver = self.data_version_.filter_by(stype = stype, version = version).first() if ver: ver.status = status Session.commit() return '保存成功' + str(ver.status) else: return '版本 ' + str(version) + '不存在' return '参数有错误'
def RemoveStype(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype_id = int(request.params['stype_id']) if stype_id <= 0: return '参数错误' # 删除stype stype_cfg = self.stype_config_.filter_by(stype = stype_id).first() Session.delete(stype_cfg) # 删除数据格式定义 schemas = self.data_version_.filter_by(stype = stype_id).first() Session.delete(schemas) # TODO : 删除模板 Session.commit() return '成功删除新鲜事类型' + str(stype_id)
def RemoveStype(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype_id = int(request.params['stype_id']) if stype_id <= 0: return '参数错误' # 删除stype stype_cfg = self.stype_config_.filter_by(stype=stype_id).first() Session.delete(stype_cfg) # 删除数据格式定义 schemas = self.data_version_.filter_by(stype=stype_id).first() Session.delete(schemas) # TODO : 删除模板 Session.commit() return '成功删除新鲜事类型' + str(stype_id)
def SaveVersionKeys(self): stype = int(request.params['stype']) version = int(request.params['version']) if stype <= 0 or version <= 0: return "参数错误" o = self.data_version_.filter_by(stype=stype, version=version).first() if o: o.keys_xml = request.params['kl'] o.news_merge_by = request.params['news_merge_by'] o.mini_merge_by = request.params['mini_merge_by'] o.source_by = request.params['source_by'] o.psource_by = request.params['psource_by'] o.actor_by = request.params['actor_by'] o.togroup_by = request.params['togroup_by'] o.dispatch_expr = urllib2.unquote( str(request.params['dispatch_expr'])) Session.commit() return '保存成功' else: return '该版本不存在'
def UpdateStypeVersionStatus(self): if self.UserRight(request, response) < 2: return '"没有操作权限, 请确保管理员帐号登录"' stype = int(request.params['stype']) version = int(request.params['version']) status = int(request.params['status']) if status >= 2 and self.UserRight(request, response) < 3: return '您没有上线权限' if stype > 0 and version > 0: ver = self.data_version_.filter_by(stype=stype, version=version).first() if ver: ver.status = status Session.commit() return '保存成功' + str(ver.status) else: return '版本 ' + str(version) + '不存在' return '参数有错误'
def ApplyPublishSubmit(self): max_id = Session.query(func.max(ApplyPublish.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] publish_desc = request.params['publish_desc'] a = ApplyPublish(max_id + 1, stype_id=int(request.params['stype_id']), version=int(request.params['version']), tpl_id=int(request.params['tpl_id']), pm_names=pm_names, pm_emails=pm_emails, dev_names=request.params['dev_names'], dev_emails=request.params['dev_emails'], publish_desc=publish_desc, status=0, apply_time=int(time.time())) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def ApplyNewVersionSubmit(self): max_id = Session.query(func.max(ApplyNewVersion.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] version_desc = request.params['version_desc'] a = ApplyNewVersion(max_id + 1, stype_id = int(request.params['stype_id']), from_version_id = int(request.params['from_version_id']), pm_names = pm_names, pm_emails = pm_emails, dev_names = request.params['dev_names'], dev_emails = request.params['dev_emails'], version_desc = version_desc, version_text = request.params['version_text'], status = 0, apply_time = int(time.time()) ) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def ApplyPublishSubmit(self): max_id = Session.query(func.max(ApplyPublish.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] publish_desc = request.params['publish_desc'] a = ApplyPublish(max_id + 1, stype_id = int(request.params['stype_id']), version = int(request.params['version']), tpl_id = int(request.params['tpl_id']), pm_names = pm_names, pm_emails = pm_emails, dev_names = request.params['dev_names'], dev_emails = request.params['dev_emails'], publish_desc = publish_desc, status = 0, apply_time = int(time.time()) ) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def ApplyNewVersionSubmit(self): max_id = Session.query(func.max( ApplyNewVersion.apply_id)).scalar() or 0 pm_emails = request.params['pm_emails'] pm_names = request.params['pm_names'] version_desc = request.params['version_desc'] a = ApplyNewVersion(max_id + 1, stype_id=int(request.params['stype_id']), from_version_id=int( request.params['from_version_id']), pm_names=pm_names, pm_emails=pm_emails, dev_names=request.params['dev_names'], dev_emails=request.params['dev_emails'], version_desc=version_desc, version_text=request.params['version_text'], status=0, apply_time=int(time.time())) Session.add(a) Session.commit() # self.SendMail('*****@*****.**', pm_emails, '申请创建新鲜事类型', pm_names + ':' + stype_desc) return '申请保存成功'
def FeedApplyHandled(self, apply_id): a = self.apply_feeds_.filter_by(apply_id = apply_id).first() if a: a.status = 1 Session.commit()
def RemoveUserApply(self): apply_id = request.params['apply_id'] a = self.user_applies_.filter_by(apply_id=apply_id).first() Session.delete(a) Session.commit() return '删除成功'
def FeedApplyHandled(self, apply_id): a = self.apply_feeds_.filter_by(apply_id=apply_id).first() if a: a.status = 1 Session.commit()
def RemoveUserApply(self): apply_id = request.params['apply_id'] a = self.user_applies_.filter_by(apply_id = apply_id).first() Session.delete(a) Session.commit() return '删除成功'