Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created June 25, 2013 13:37
Show Gist options
  • Save marcelcaraciolo/5858494 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/5858494 to your computer and use it in GitHub Desktop.
def _save_curso(id_in_supplier, name, description, periodo_acesso):
from shop.models import Course
from product.models import Price, Product
try:
return Course.objects.get(id_in_supplier=id_in_supplier, supplier=IOB)
except Course.DoesNotExist:
try:
p = Product.objects.get(name=name)
p.delete()
except Product.DoesNotExist:
pass
c = Course()
c.id_in_supplier = id_in_supplier
try:
c.duration_in_supplier = str(int(periodo_acesso)* 30)
except:
c.duration_in_supplier = "30" # Padrão: 30 dias
c.supplier = IOB
c.classification = 1 # 1 - Pré
#c.total_classes = total_classes
#c.demonstration = demo
#c.pdf = pdf
c.name = name
c.date_added = datetime.datetime.now()
c.description = description
c.short_description = name
c.share_facebook_discount = 10
c.site = Site.objects.get_current()
c.active = False
c.save()
return c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment