Beispiel #1
0
 async def info(self):
     self.finish(
         RETCODE.SUCCESS,
         {
             'retcode': list(RETCODE.items()),
             #'retinfo': RETCODE.txt,
         })
Beispiel #2
0
    async def info(self):
        """
        一些后端信息,一般是首次打开页面时获得
        :return:
        """
        extra = {
            'midnight_time': get_today_start_timestamp()
        }

        # 每日首次访问奖励
        if self.current_user:
            daily_reward = self.current_user.daily_access_reward()
            if daily_reward:
                extra['daily_reward'] = {
                    'exp': daily_reward
                }

        self.finish(RETCODE.SUCCESS, {
            'extra': extra,

            'POST_TYPES': POST_TYPES.to_dict(),
            'POST_TYPES_TXT': POST_TYPES.txt,
            'POST_STATE': POST_STATE.to_dict(),
            'POST_STATE_TXT': POST_STATE.txt,
            'POST_VISIBLE': POST_VISIBLE.to_dict(),
            'POST_VISIBLE_TXT': POST_VISIBLE.txt,

            'MANAGE_OPERATION': MANAGE_OPERATION.to_dict(),
            'MANAGE_OPERATION_TXT': MANAGE_OPERATION.txt,

            'USER_GROUP': USER_GROUP.to_dict(),
            'USER_GROUP_TXT': USER_GROUP.txt,
            'USER_GROUP_TO_ROLE': USER_GROUP.GROUP_TO_ROLE,

            'NOTIF_TYPE': NOTIF_TYPE.to_dict(),

            'BACKEND_CONFIG': {
                'USER_SECURE_AUTH_ENABLE': config.USER_SECURE_AUTH_ENABLE,
                'USER_SECURE_AUTH_FRONTEND_SALT': config.USER_SECURE_AUTH_FRONTEND_SALT,

                'USER_NICKNAME_MIN': config.USER_NICKNAME_MIN,
                'USER_NICKNAME_MAX': config.USER_NICKNAME_MAX,
                'USER_NICKNAME_CN_FOR_REG_MIN': config.USER_NICKNAME_CN_FOR_REG_MIN,
                'USER_NICKNAME_FOR_REG_MIN': config.USER_NICKNAME_FOR_REG_MIN,
                'USER_NICKNAME_FOR_REG_MAX': config.USER_NICKNAME_FOR_REG_MAX,
                'USER_PASSWORD_MIN': config.USER_PASSWORD_MIN,
                'USER_PASSWORD_MAX': config.USER_PASSWORD_MAX,

                'TOPIC_TITLE_LENGTH_MIN': config.TOPIC_TITLE_LENGTH_MIN,
                'TOPIC_TITLE_LENGTH_MAX': config.TOPIC_TITLE_LENGTH_MAX,
                'TOPIC_CONTENT_LENGTH_MAX': config.TOPIC_CONTENT_LENGTH_MAX,

                'UPLOAD_STATIC_HOST': config.UPLOAD_STATIC_HOST,
                'UPLOAD_QINIU_DEADLINE_OFFSET': config.UPLOAD_QINIU_DEADLINE_OFFSET,
            },

            'retcode': RETCODE.to_dict(),
            'retinfo_cn': RETCODE.txt_cn,
        })
Beispiel #3
0
 async def info(self):
     """
     提供给前端使用的后端配置信息
     """
     self.finish(RETCODE.SUCCESS, {
         'retcode': RETCODE.to_dict(),
         'retinfo': RETCODE.txt_cn,
     })
Beispiel #4
0
 async def info(self):
     self.finish(RETCODE.SUCCESS, {
         'retcode': RETCODE.to_dict(),
         'retinfo': RETCODE.txt_cn,
     })
Beispiel #5
0
    async def info(self):
        """
        一些后端信息,一般是首次打开页面时获得
        :return:
        """
        results = {
            'POST_TYPES': POST_TYPES.to_dict(),
            'POST_TYPES_TXT': POST_TYPES.txt,
            'POST_STATE': POST_STATE.to_dict(),
            'POST_STATE_TXT': POST_STATE.txt,
            'POST_VISIBLE': POST_VISIBLE.to_dict(),
            'POST_VISIBLE_TXT': POST_VISIBLE.txt,
            'MANAGE_OPERATION': MANAGE_OPERATION.to_dict(),
            'MANAGE_OPERATION_TXT': MANAGE_OPERATION.txt,
            'USER_GROUP': USER_GROUP.to_dict(),
            'USER_GROUP_TXT': USER_GROUP.txt,
            'USER_GROUP_TO_ROLE': USER_GROUP.GROUP_TO_ROLE,
            'NOTIF_TYPE': NOTIF_TYPE.to_dict(),
            'BACKEND_CONFIG': {
                'SITE_NAME':
                config.SITE_NAME,
                'SITE_LOGO_TEXT':
                config.SITE_LOGO_TEXT,
                'SITE_TITLE_TEXT':
                config.SITE_TITLE_TEXT,
                'SITE_URL':
                config.SITE_URL,
                'SITE_CONTACT_EMAIL':
                config.SITE_CONTACT_EMAIL,
                'ABOUT_PAGE_ENABLE':
                config.ABOUT_PAGE_ENABLE,
                'ABOUT_CUSTOM_HTML':
                config.ABOUT_CUSTOM_HTML,
                'SIGNUP_LICENSE_HTML':
                config.SIGNUP_LICENSE_HTML,
                'FOOTER_EXTRA_HTML':
                config.FOOTER_EXTRA_HTML,
                'USER_SECURE_AUTH_FRONTEND_SALT':
                config.USER_SECURE_AUTH_FRONTEND_SALT,
                'WIKI_ENABLE':
                config.WIKI_ENABLE,
                'SEARCH_ENABLE':
                config.SEARCH_ENABLE,
                'USER_NICKNAME_MIN':
                config.USER_NICKNAME_MIN,
                'USER_NICKNAME_MAX':
                config.USER_NICKNAME_MAX,
                'USER_NICKNAME_CN_FOR_REG_MIN':
                config.USER_NICKNAME_CN_FOR_REG_MIN,
                'USER_NICKNAME_FOR_REG_MIN':
                config.USER_NICKNAME_FOR_REG_MIN,
                'USER_NICKNAME_FOR_REG_MAX':
                config.USER_NICKNAME_FOR_REG_MAX,
                'USER_PASSWORD_MIN':
                config.USER_PASSWORD_MIN,
                'USER_PASSWORD_MAX':
                config.USER_PASSWORD_MAX,
                'TOPIC_TITLE_LENGTH_MIN':
                config.TOPIC_TITLE_LENGTH_MIN,
                'TOPIC_TITLE_LENGTH_MAX':
                config.TOPIC_TITLE_LENGTH_MAX,
                'TOPIC_CONTENT_LENGTH_MAX':
                config.TOPIC_CONTENT_LENGTH_MAX,
                'EMAIL_ACTIVATION_ENABLE':
                config.EMAIL_ACTIVATION_ENABLE,
                'UPLOAD_ENABLE':
                config.UPLOAD_ENABLE,
                'UPLOAD_BACKEND':
                config.UPLOAD_BACKEND,
                'UPLOAD_STATIC_HOST':
                config.UPLOAD_STATIC_HOST,
                'UPLOAD_QINIU_DEADLINE_OFFSET':
                config.UPLOAD_QINIU_DEADLINE_OFFSET,
                'UPLOAD_QINIU_IMAGE_STYLE_TOPIC':
                config.UPLOAD_QINIU_IMAGE_STYLE_TOPIC,
            },
            'retcode': RETCODE.to_dict(),
            'retinfo_cn': RETCODE.txt_cn,
            'extra': {
                'midnight_time': get_today_start_timestamp()
            }
        }

        # 每日首次访问奖励
        if self.current_user:
            user = self.current_user

            results['user'] = {
                'id': to_hex(user.id),
                'daily_reward': user.daily_access_reward()
            }

        self.finish(RETCODE.SUCCESS, results)