示例#1
0
    def get_publish_info4discovery(publish, *params):
        result = {}
        longitude = params[0]
        latitude = params[1]
        user_id = params[2]
        try:
            if user_id == 0:
                result["attribute"] = -1
            else:
                result["attribute"] = UserPublishRelationMethods.get_attribute_by_user_and_publish(user_id, publish.id)

            result["publish_id"] = publish.id
            result["created_at"] = Datetimes.utc2east8(publish.created_at)
            result["win"] = UserPublishRelationMethods.get_win_attribute_count_by_publish(publish)
            result["lost"] = UserPublishRelationMethods.get_lost_attribute_count_by_publish(publish)

            if publish.user and publish.user.userextension:
                result["user_nickname"] = publish.user.userextension.nickname
            else:
                result["user_nickname"] = ""

            temp_image = Users.get_user_image(publish.user)
            result["user_small_image"] = temp_image["small_user_image"]

            temp_publish_images = Publishes.get_publish_images(publish)
            result["publish_image_url"] = temp_publish_images["publish_image_url"]
            result["publish_image_big_url"] = temp_publish_images["publish_image_big_url"]
            result["publish_image_medium_url"] = temp_publish_images["publish_image_medium_url"]
            result["publish_image_small_url"] = temp_publish_images["publish_image_small_url"]
            result["PM2_5"] = publish.PM2_5

            result["comment"] = Comments.get_by_publish(publish.id)
            result["content"] = publish.content

            result["bonus"] = RedEnvelopes.get_red_envelope_by_publish(publish.id)

            s = publish.shop
            big_category = ShopCategories.get_shop_big_category(publish.shop.category)

            if not big_category:
                big_category = ShopCategories.get_category_default()
            big_category_key = big_category.id
            result["big_category_name"] = big_category.name
            result["big_category_key"] = big_category.id

            if not big_category_key:
                result["category_operation"] = {}
            else:
                result["category_operation"] = PublishCategories.get_category_info_by_shop_category(big_category)
        except Exception as ex:
            Logs.print_current_function_name_and_line_number(ex)

        return result
示例#2
0
    def get_publish_info4hot(publish, longitude, latitude, user_id):
        result = dict()

        result["created_at"] = Datetimes.transfer_datetime(publish.created_at)
        if publish.user:
            if publish.user.userextension:
                result["user_nickname"] = publish.user.userextension.nickname
            else:
                result["user_nickname"] = ""
        else:
            result["user_nickname"] = ""

        temp_image = Users.get_user_image(publish.user)
        result["user_small_image"] = temp_image["small_user_image"]
        result["PM2_5"] = publish.PM2_5

        result["content"] = publish.content

        category = publish.shop.category
        big_category = ShopCategories.get_shop_big_category(category)

        if not big_category:
            big_category = ShopCategories.get_category_default()

        if big_category:
            result["big_category_name"] = big_category.name
            result["big_category_key"] = big_category.id
        else:
            result["big_category_name"] = ""
            result["big_category_key"] = ""

        if not big_category:
            result["category_operation"] = {}
        else:
            result["category_operation"] = PublishCategories.get_category_info_by_shop_category(big_category)

        return result