0.0.1 init, main page prepare

This commit is contained in:
SDE
2023-11-16 14:38:44 +03:00
parent 894ee6d750
commit 74f7bbb24b
78 changed files with 6198 additions and 21 deletions

View File

@@ -0,0 +1,178 @@
# import json
#
# import project_sets
# from BaseModels.functions import add_domain
#
#
# def get_ld_shipping_data_for_product(shipping_terms):
# shipping_terms_list = []
# for item in shipping_terms:
# data = {
# "@type": "OfferShippingDetails",
# "shippingRate": {
# "@type": "MonetaryAmount",
# "value": item.price,
# "currency": project_sets.base_currency
# },
# "shippingDestination": {
# "@type": "DefinedRegion",
# "addressCountry": project_sets.shipping_region, # обязательно
# # "postalCodeRange": {
# # "postalCodeBegin": "98100",
# # "postalCodeEnd": "98199"
# # }
# },
# "deliveryTime": {
# "@type": "ShippingDeliveryTime",
# "cutOffTime": project_sets.cutOffTime, # "19:30-08:00",
#
# # Стандартное время от получения оплаты до отправки товаров со склада (или подготовки к самовывозу, если используется такой вариант)
# "handlingTime": {
# "@type": "QuantitativeValue",
# "minValue": "0", # дней
# "maxValue": "1" # дней
# },
# # Стандартное время от отправки заказа до его прибытия к конечному покупателю.
# "transitTime": {
# "@type": "QuantitativeValue",
# "minValue": "1", # дней
# "maxValue": "5" # дней
# },
# # Время, после которого новые заказы не обрабатываются в тот же день
#
# # Дни недели, по которым вы обрабатываете заказы
# "businessDays": {
# "@type": "OpeningHoursSpecification",
# "dayOfWeek": ["https://schema.org/Monday", "https://schema.org/Tuesday",
# "https://schema.org/Wednesday", "https://schema.org/Thursday"]
# }
# }
# }
#
# shipping_terms_list.append(data)
#
# data = {
# "shippingDetails": shipping_terms_list
# }
#
# return data
#
#
# def get_ld_offers_for_product(product, domain, shipping_terms):
# data = {
# "offers": {
# "@type": "Offer",
# "url": '{0}{1}'.format(domain, product.get_site_url()),
# "itemCondition": "https://schema.org/NewCondition",
# # "https://schema.org/NewCondition"
# # "https://schema.org/UsedCondition"
# "availability": "https://schema.org/InStock",
# # https://schema.org/BackOrder
# # https://schema.org/Discontinued
# # https://schema.org/InStock
# # https://schema.org/InStoreOnly
# # https://schema.org/LimitedAvailability
# # https://schema.org/OnlineOnly
# # https://schema.org/OutOfStock
# # https://schema.org/PreOrder
# # https://schema.org/PreSale
# # https://schema.org/SoldOut
# "price": str(product.price),
# "priceCurrency": project_sets.base_currency,
# # "priceValidUntil": "2020-11-20", #дата окончания действия цены
# # "shippingSettingsLink": '{0}{1}'.format(project_sets.domain, 'delivery/'),
#
# },
# }
#
# if shipping_terms:
# data["offers"].update(get_ld_shipping_data_for_product(shipping_terms))
#
# return data
#
#
# def get_aggregate_rating(product):
# data = {
# # "review": {
# # "@type": "Review",
# # "reviewRating": {
# # "@type": "Rating",
# # "ratingValue": "4",
# # "bestRating": "5"
# # },
# # "author": {
# # "@type": "Person",
# # "name": "Fred Benson"
# # }
# # },
# "aggregateRating": {
# "@type": "AggregateRating",
# "ratingValue": product.ratingValue,
# "reviewCount": product.reviewCount
# }
# }
#
# return data
#
#
# def get_ld_product(product, domain, shipping_terms):
# from GeneralApp.views import get_cur_domain
# serv_domain, local_domain = get_cur_domain()
#
# data = {
# "@context": "https://schema.org/",
# "@type": "Product",
# "name": product.name,
# "sku": '{0}-{1}'.format(str(product.brand), str(product.article)),
# "url": '{0}{1}'.format(domain, product.get_site_url()),
# }
#
# if product.description:
# data.update({
# "description": product.description,
# })
#
# barcode = getattr(product, 'barcode', None)
# if barcode:
# data.update({
# "gtin14": barcode,
# })
#
# gallery = getattr(product, 'gallery', None)
# if gallery:
# try:
# photos = gallery.get_photos()
# photos = list(map(lambda ph: '{0}{1}'.format(serv_domain, ph), photos))
# except Exception as e:
# photos = None
#
# if photos:
# data.update({
# "image": photos,
# })
#
# brand = getattr(product, 'brand', None)
# if brand:
# if type(brand) not in [str]:
# brand = brand.name
#
# data.update({
# "brand": {
# "@type": "Brand",
# "name": brand
# },
# })
#
# FAQ = {}
#
# from ...
#
# aggregate_rating = getattr(product, 'ratingValue', None)
# if aggregate_rating != None:
# data.update(get_aggregate_rating(product))
#
# price = getattr(product, 'price', None)
# if price:
# data.update(get_ld_offers_for_product(product, domain, shipping_terms))
#
# return json.dumps(data)