Skip to content

[django1.11] use FormatPresetSerializer as a PrimaryKeyRelatedField serializer#890

Closed
micahscopes wants to merge 2 commits intolearningequality:django1.11from
micahscopes:django1.11
Closed

[django1.11] use FormatPresetSerializer as a PrimaryKeyRelatedField serializer#890
micahscopes wants to merge 2 commits intolearningequality:django1.11from
micahscopes:django1.11

Conversation

@micahscopes
Copy link
Contributor

@micahscopes micahscopes commented Aug 16, 2018

(do not merge) 😜

Description

This is an attempt to make file uploading and metadata editing work with Django 1.11 and DRF 3.8.

Issue Addressed (if applicable)

see #874

Before/After Screenshots (if applicable)

Now we get this new issue:
image

Steps to Test

  • Upload some content to a channel (e.g. a video)
  • Check the console! Notice that the file size is 0 bytes!
  • Try to edit and save the metadata. You will receive an error.

Copy link
Collaborator

@aronasorman aronasorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions! And let's remove the pdb comments!

user = self.context['request'].user
with transaction.atomic():
for item in validated_data:
# import ipdb; ipdb.set_trace()

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

if request.method != 'POST':
return HttpResponseBadRequest("Only POST requests are allowed on this endpoint.")

# import ipdb; ipdb.set_trace()

This comment was marked as spam.

This comment was marked as spam.

checksum, _, path = write_raw_content_to_storage(contents, ext=ext)
with default_storage.open(path, 'rb') as new_file:
return File.objects.create(
# import ipdb; ipdb.set_trace()

This comment was marked as spam.

This comment was marked as spam.



class FormatPresetSerializer(serializers.ModelSerializer):
class FormatPresetSerializer(serializers.PrimaryKeyRelatedField):

This comment was marked as spam.

This comment was marked as spam.

id = serializers.CharField(required=False)
preset = FormatPresetSerializer(many=False)
preset = FormatPresetSerializer(many=False, read_only=True)
# preset = serializers.PrimaryKeyRelatedField(many=False, queryset=FormatPreset.objects.all())

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants