|
|
|
|
@ -32,23 +32,10 @@ class DispatchContentMixin(object): |
|
|
|
|
serializer = TextCreateSerializer(t, data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
serializer.save() |
|
|
|
|
# t.position = cdata['position'] |
|
|
|
|
# t.title = cdata['title'] |
|
|
|
|
# t.course = course |
|
|
|
|
# t.txt = cdata['txt'] |
|
|
|
|
# t.uuid = cdata['uuid'] |
|
|
|
|
# t.save() |
|
|
|
|
else: |
|
|
|
|
serializer = TextCreateSerializer(data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
serializer.save() |
|
|
|
|
# t = Text.objects.create( |
|
|
|
|
# position=cdata['position'], |
|
|
|
|
# title=cdata['title'], |
|
|
|
|
# course=course, |
|
|
|
|
# txt=cdata['txt'], |
|
|
|
|
# uuid=cdata['uuid'], |
|
|
|
|
# ) |
|
|
|
|
elif ctype == 'image': |
|
|
|
|
if 'id' in cdata and cdata['id']: |
|
|
|
|
image = Image.objects.get(id=cdata.pop('id')) |
|
|
|
|
@ -57,11 +44,6 @@ class DispatchContentMixin(object): |
|
|
|
|
image = serializer.save() |
|
|
|
|
else: |
|
|
|
|
continue |
|
|
|
|
# image.uuid = cdata['uuid'] |
|
|
|
|
# image.position = cdata['position'] |
|
|
|
|
# image.title = cdata['title'] |
|
|
|
|
# image.course = course |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
image_object = ImageObject.objects.get(id=cdata['img']) |
|
|
|
|
except ImageObject.DoesNotExist: |
|
|
|
|
@ -69,20 +51,12 @@ class DispatchContentMixin(object): |
|
|
|
|
else: |
|
|
|
|
image.img = image_object |
|
|
|
|
image.save() |
|
|
|
|
|
|
|
|
|
# image.save() |
|
|
|
|
else: |
|
|
|
|
serializer = ImageCreateSerializer(data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
image = serializer.save() |
|
|
|
|
else: |
|
|
|
|
continue |
|
|
|
|
# image = Image.objects.create( |
|
|
|
|
# position=cdata['position'], |
|
|
|
|
# title=cdata['title'], |
|
|
|
|
# course=course, |
|
|
|
|
# uuid=cdata['uuid'], |
|
|
|
|
# ) |
|
|
|
|
try: |
|
|
|
|
image_object = ImageObject.objects.get(id=cdata['img']) |
|
|
|
|
except ImageObject.DoesNotExist: |
|
|
|
|
@ -99,11 +73,6 @@ class DispatchContentMixin(object): |
|
|
|
|
it = serializer.save() |
|
|
|
|
else: |
|
|
|
|
continue |
|
|
|
|
# it.uuid = cdata['uuid'] |
|
|
|
|
# it.position = cdata['position'] |
|
|
|
|
# it.title = cdata['title'] |
|
|
|
|
# it.course = course |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
image_object = ImageObject.objects.get(id=cdata['img']) |
|
|
|
|
except ImageObject.DoesNotExist: |
|
|
|
|
@ -111,22 +80,12 @@ class DispatchContentMixin(object): |
|
|
|
|
else: |
|
|
|
|
it.img = image_object |
|
|
|
|
it.save() |
|
|
|
|
|
|
|
|
|
# it.txt = cdata['txt'] |
|
|
|
|
# it.save() |
|
|
|
|
else: |
|
|
|
|
serializer = ImageTextCreateSerializer(data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
it = serializer.save() |
|
|
|
|
else: |
|
|
|
|
continue |
|
|
|
|
# it = ImageText.objects.create( |
|
|
|
|
# position=cdata['position'], |
|
|
|
|
# title=cdata['title'], |
|
|
|
|
# course=course, |
|
|
|
|
# txt=cdata['txt'], |
|
|
|
|
# uuid=cdata['uuid'], |
|
|
|
|
# ) |
|
|
|
|
try: |
|
|
|
|
image_object = ImageObject.objects.get(id=cdata['img']) |
|
|
|
|
except ImageObject.DoesNotExist: |
|
|
|
|
@ -141,23 +100,10 @@ class DispatchContentMixin(object): |
|
|
|
|
serializer = VideoCreateSerializer(v, data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
serializer.save() |
|
|
|
|
# v.position = cdata['position'] |
|
|
|
|
# v.title = cdata['title'] |
|
|
|
|
# v.course = course |
|
|
|
|
# v.url = cdata['url'] |
|
|
|
|
# v.uuid = cdata['uuid'] |
|
|
|
|
# v.save() |
|
|
|
|
else: |
|
|
|
|
serializer = VideoCreateSerializer(data=cdata) |
|
|
|
|
if serializer.is_valid(): |
|
|
|
|
serializer.save() |
|
|
|
|
# v = Video.objects.create( |
|
|
|
|
# position=cdata['position'], |
|
|
|
|
# title=cdata['title'], |
|
|
|
|
# course=course, |
|
|
|
|
# url=cdata['url'], |
|
|
|
|
# uuid=cdata['uuid'], |
|
|
|
|
# ) |
|
|
|
|
elif ctype == 'images': |
|
|
|
|
if 'id' in cdata and cdata['id']: |
|
|
|
|
g = Gallery.objects.get(id=cdata['id']) |
|
|
|
|
|