def api_create_shopping(request, *, name, summary, content, price): check_admin(request) if not name or not name.strip(): raise APIValueError('name', 'name cannot be empty.') if not summary or not summary.strip(): raise APIValueError('summary', 'summary cannot be empty.') if not content or not content.strip(): raise APIValueError('content', 'content cannot be empty.') if not price or not price.strip(): raise APIValueError('price', 'price cannot be empty.') shopping = Shopping(user_id=request.__user__.id, user_name=request.__user__.name, user_image=request.__user__.image, name=name.strip(), summary=summary.strip(), content=content.strip(), price=price.strip()) yield from shopping.save() return shopping
def _create_shopping(cls, name='Shopping teste', slug='shopping-teste'): mall = Shopping() mall.nome = name mall.slug = slug mall.save() return mall