Exemplo n.º 1
0
    def get_sidebar_arguments(self):
        '''得到两侧栏的render变量'''

        user_id = self.current_user['_id']

        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(
            user_id, visitor_id=user_id)

        user_setting = yield UserSettingDocument.find_one({
            'user':
            DBRef(UserDocument.meta['collection'], ObjectId(user_id))
        })
        login_reward_fetched_today = yield UserActivityDocument.login_reward_fetched(
            user_id)
        continuous_login_days = yield UserDocument.get_continuous_login_days(
            user_id)

        kwargs = {
            'status_number': status_number,
            'topic_number': topic_number,
            'MessageTopic': MessageTopic,
            'user_setting': user_setting,
            'login_reward_fetched_today': login_reward_fetched_today,
            'continuous_login_days': continuous_login_days,
            'HOME_SETTINGS': HOME_SETTINGS
        }

        raise gen.Return(kwargs)
Exemplo n.º 2
0
    def get_sidebar_arguments(self):
        '''得到两侧栏的render变量'''

        user_id = self.current_user['_id']
        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(user_id)

        user_setting = yield UserSettingDocument.find_one({
            'user': DBRef(UserDocument.meta['collection'], ObjectId(user_id))
        })

        random_user_list = yield UserDocument.get_random_user_list(
            self.current_user['_id']
        )

        kwargs = {
            'status_number': status_number,
            'topic_number': topic_number,
            'MessageTopic': MessageTopic,
            'user_setting': user_setting,
            'random_user_list': random_user_list,
            'HOME_SETTINGS': HOME_SETTINGS
        }

        raise gen.Return(kwargs)
Exemplo n.º 3
0
    def get_sidebar_arguments(self):
        '''得到两侧栏的render变量'''

        user_id = self.current_user['_id']
        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(user_id)

        user_setting = yield UserSettingDocument.find_one({
            'user': DBRef(UserDocument.meta['collection'], ObjectId(user_id))
        })

        random_user_list = yield UserDocument.get_random_user_list(
            self.current_user['_id']
        )

        kwargs = {
            'status_number': status_number,
            'topic_number': topic_number,
            'MessageTopic': MessageTopic,
            'user_setting': user_setting,
            'random_user_list': random_user_list,
            'HOME_SETTINGS': HOME_SETTINGS
        }

        raise gen.Return(kwargs)
Exemplo n.º 4
0
    def get_sidebar_arguments(self):
        '''得到两侧栏的render变量'''

        user_id = self.current_user['_id']

        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(
            user_id, visitor_id=user_id
        )

        user_setting = yield UserSettingDocument.find_one({
            'user': DBRef(UserDocument.meta['collection'], ObjectId(user_id))
        })
        login_reward_fetched_today = yield UserActivityDocument.login_reward_fetched(
            user_id
        )
        continuous_login_days = yield UserDocument.get_continuous_login_days(
            user_id
        )

        kwargs = {
            'status_number': status_number,
            'topic_number': topic_number,
            'MessageTopic': MessageTopic,
            'user_setting': user_setting,
            'login_reward_fetched_today': login_reward_fetched_today,
            'continuous_login_days': continuous_login_days,
            'HOME_SETTINGS': HOME_SETTINGS
        }

        raise gen.Return(kwargs)
Exemplo n.º 5
0
    def get_header_arguments(self, user_id=None):
        user_id = user_id or self.current_user["_id"]

        user = yield UserDocument.find_one({
            '_id': ObjectId(user_id)
        })
        if not user:
            raise HTTPError(404)

        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(
            user_id, visitor_id=self.current_user['_id']
        )

        user = yield UserDocument.translate_dbref_in_document(user)

        can_seen = yield UserDocument.can_seen(
            user_id, self.current_user['_id']
        )
        is_friend = yield FriendDocument.is_friend(
            user_id, self.current_user['_id']
        )
        user_setting = yield UserSettingDocument.get_user_setting(
            user_id
        )
        profile_cover = yield UserSettingDocument.get_profile_cover(
            user_id
        )

        kwargs = {
            'user': user,
            'can_seen': can_seen,
            'is_friend': is_friend,
            'user_setting': user_setting,
            'status_number': status_number,
            'topic_number': topic_number,
            'profile_cover': profile_cover,
            'PROFILE_SETTINGS': PROFILE_SETTINGS
        }

        if not can_seen:
            messages_func = LeaveMessageDocument.get_leave_message_list
            leave_message_list = yield messages_func(
                user_id, self.current_user['_id'],
                limit=PROFILE_SETTINGS['leave_message_number_per_page']
            )

            kwargs.update({
                'leave_message_list': leave_message_list
            })

        raise gen.Return(kwargs)
Exemplo n.º 6
0
    def get_header_arguments(self, user_id=None):
        user_id = user_id or self.current_user["_id"]

        user = yield UserDocument.find_one({'_id': ObjectId(user_id)})
        if not user:
            raise HTTPError(404)

        status_number = yield StatusDocument.get_status_number(user_id)
        topic_number = yield TopicDocument.get_topic_number_by_someone(
            user_id, visitor_id=self.current_user['_id'])

        user = yield UserDocument.translate_dbref_in_document(user)

        can_seen = yield UserDocument.can_seen(user_id,
                                               self.current_user['_id'])
        is_friend = yield FriendDocument.is_friend(user_id,
                                                   self.current_user['_id'])
        user_setting = yield UserSettingDocument.get_user_setting(user_id)
        profile_cover = yield UserSettingDocument.get_profile_cover(user_id)

        kwargs = {
            'user': user,
            'can_seen': can_seen,
            'is_friend': is_friend,
            'user_setting': user_setting,
            'status_number': status_number,
            'topic_number': topic_number,
            'profile_cover': profile_cover,
            'PROFILE_SETTINGS': PROFILE_SETTINGS
        }

        if not can_seen:
            messages_func = LeaveMessageDocument.get_leave_message_list
            leave_message_list = yield messages_func(
                user_id,
                self.current_user['_id'],
                limit=PROFILE_SETTINGS['leave_message_number_per_page'])

            kwargs.update({'leave_message_list': leave_message_list})

        raise gen.Return(kwargs)