コード例 #1
0
ファイル: rules.py プロジェクト: wangbailin/kuzhanggui
def micro_site(rule, info):
    try:
        wx_account = WXAccount.objects.get(id=info.wx)
        WeixinDailyData.today_subscribe_one(info.wx)
        homepage = HomePage.objects.get(wx=wx_account)
        data = {}
        data['title'] = homepage.name
        if homepage.message_description:
            data['description'] = homepage.message_description
        else:
            data['description'] = consts.DEFAULT_HOMEPAGE_MSG % wx_account.name
        if homepage.message_cover:
            data['pic_url'] = homepage.message_cover.url
        else:
            data['pic_url'] = settings.SITE_URL + settings.STATIC_URL + consts.DEFAULT_HOMEPAGE_COVER
        data['url'] = get_page_url(homepage) + "?user=%s&wx=%s" % (info.user, info.wx)
        return BuildConfig(MessageBuilder.TYPE_WEB_APP, None, data)
    except:
        logger.error(traceback.format_exc())
        return BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, u'非常抱歉')