示例#1
0
def build_activity_for_flow(activity, user_id, lon, lat):
    club = activity.club
    return {
        'flow_id': activity.id, 'flow_type': FlowType.ACTIVITY, 'avatar': club.avatar.url,
        'name': club.name, 'distance': geodesic((lat, lon), (activity.lat, activity.lon)).meters,
        'location': activity.address,
        'post_time': datetime_to_str(activity.created_time), 'content': activity.introduction,
        'image_list': activity.image_list,
        'favored': is_user_favored(user_id, activity.id, FlowType.ACTIVITY),
        'favor_num': activity.favor_num,
    }
示例#2
0
def build_footprint_for_flow(footprint, user_id, lon, lat):
    return {
        'flow_id': footprint.id, 'flow_type': FlowType.FOOTPRINT, 'avatar': footprint.avatar,
        'name': footprint.name, 'distance': geodesic((lat, lon), (footprint.lat, footprint.lon)).meters,
        'location': footprint.location,
        'post_time': datetime_to_str(footprint.created_time), 'content': footprint.content,
        'image_list': footprint.image_list,
        'user_id': footprint.user_id,
        'favored': is_user_favored(user_id, footprint.id, FlowType.FOOTPRINT),
        'favor_num': footprint.favor_num,
    }
示例#3
0
def build_activity_brief_info(activity, user_id, lon, lat):
    distance = geodesic((activity.lat, activity.lon), (lat, lon)).meters if lat and lon else 0
    return {
        'time_detail': activity.time_detail,
        'post_time': get_time_show(activity.created_time),
        'name': activity.name,
        'image_list': activity.image_list,
        'distance': distance,
        'activity_id': activity.id,
        'favored': is_user_favored(user_id, activity.id, FlowType.ACTIVITY),
        'favor_num': activity.favor_num
    }
示例#4
0
def build_activity_detail(activity, user_id):
    """
    构建活动详情页信息
            top_image,
        title,
        club_name,
        avatar,
        telephone,
        introduction,
        image_list,
        detail,
        address,
        time_detail,
        description,
        total_quota,
        participants: [{user_id, avatar}]
    """
    club = activity.club
    result = {
        'top_image': activity.top_image.url,
        'title': activity.name,
        'club_name': club.name,
        'avatar': club.avatar.url,
        'telephone': club.telephone,
        'introduction': activity.introduction,
        'detail': activity.detail,
        'address': activity.address,
        'time_detail': activity.time_detail,
        'description': activity.description,
        'total_quota': activity.total_quota,
        'image_list': activity.image_list,
        'favored': is_user_favored(user_id, activity.id, FlowType.ACTIVITY),
        'favor_num': activity.favor_num,
    }
    participants = get_activity_participants(activity.id)
    result.update({
        'participants': [{
            'user_id': item.user_info.user_id,
            'avatar': item.user_info.avatar
        } for item in participants]
    })
    return result