mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-17 02:45:08 +00:00
25 lines
584 B
Python
25 lines
584 B
Python
"""
|
|
web_utils file
|
|
"""
|
|
from base.constants import ARTICLE_CARD_IMAGE_FOLDER
|
|
from guardian.utils import upload_image_to_alibaba
|
|
|
|
|
|
def pop_id(data):
|
|
"""
|
|
to pop id, not in use
|
|
:param data:
|
|
:return: data
|
|
"""
|
|
data.pop('id') if 'id' in data else data
|
|
return data
|
|
|
|
|
|
def get_image_url(data):
|
|
if 'image' in data and data['image'] is not None:
|
|
image = data.pop('image')
|
|
filename = f"{ARTICLE_CARD_IMAGE_FOLDER}/{image.name}"
|
|
# upload image on ali baba
|
|
image_url = upload_image_to_alibaba(image, filename)
|
|
return image_url
|