Пример #1
0
 def get_website_archived_setting2(self):
     setting = self.session.query(Setting).filter_by(
         name='website_archived_shown_fields').first()
     if not setting:
         raise RecordNotFound('无此配置')
     print(setting.value)
     return {setting.name: json.loads(setting.value)}
Пример #2
0
    def get_domain_archived_setting(self):
        setting = self.session.query(Setting).filter_by(
            name='domain_archived_shown_fields').first()
        if not setting:
            raise RecordNotFound('无此配置')

        data = {}
        for value in json.loads(setting.value):
            data[value] = self.domain_value_dict[value]
        return data
Пример #3
0
    def resource_not_found(error):
        """
        Custom error handler for 404 http exception.
        Returns a JSON object with a message that accessed URL was not found.
        """

        tb = traceback.format_exc()
        message = "HTTP请求异常(找不到请求地址)"
        current_app.logger.error(
            "{}:{}\n{}".format(NotFound.__name__, error.description, tb))
        response = jsonify(RecordNotFound(message=message).to_dict())
        response.status_code = NotFound.code
        return response
Пример #4
0
 def get_domain_recycler_setting(self):
     setting = self.session.query(Setting).filter_by(
         name='domain_recycler_shown_fields').first()
     if not setting:
         raise RecordNotFound('无此配置')
     return {setting.name: json.loads(setting.value)}
Пример #5
0
def id_in_db(id):
    if not db.session.query(WebsiteNews).filter_by(id=id).first():
        raise RecordNotFound('无此数据')
Пример #6
0
def id_in_db(id):
    if not db.session.query(BanKeyword).filter_by(id=id).first():
        raise RecordNotFound('无此记录')
Пример #7
0
def id_in_groups(id):
    if not db.session.query(BanGroup).filter_by(id=id).first():
        raise RecordNotFound('无此分组')
Пример #8
0
def domain_id_in_db(domain_id):
    if not db.session.query(DomainRecycler).get(domain_id):
        raise RecordNotFound('无此主域名')
Пример #9
0
def word_id_in_db(word_id):
    if not db.session.query(StopWord).get(word_id):
        raise RecordNotFound('无此停用词')
Пример #10
0
def region_code_in_db(code):
    if not db.session.query(Region).filter_by(name=code).first():
        raise RecordNotFound('无此二级归属地')
Пример #11
0
def city_code_in_db(code):
    if not db.session.query(City).filter_by(name=code).first():
        raise RecordNotFound('无此一级归属地')
Пример #12
0
def tags_in_db(sponsor_type):
    if sponsor_type not in ['医院', '上市单位']:
        raise RecordNotFound('无此标签')
Пример #13
0
def sponsor_type_in_db(sponsor_type):
    if sponsor_type not in [
            '个人', '政府机关', '企业', '事业单位', '社会团体', '其他', '民办非企业单位'
    ]:
        raise RecordNotFound('无此单位性质')