Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contentcuration/contentcuration/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Meta:
fields = ("__all__")


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

This comment was marked as spam.

This comment was marked as spam.

# files = FileSerializer(many=True, read_only=True)
associated_mimetypes = serializers.SerializerMethodField('retrieve_mimetypes')
# Handles multi-language content (Backbone won't allow duplicate ids in collection, so name retains id)
Expand All @@ -76,6 +76,7 @@ def update(self, instance, validated_data):
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.

item.update({
'preset_id': item['preset']['id'],
'language_id': item.get('language')['id'] if item.get('language') else None
Expand Down Expand Up @@ -148,7 +149,8 @@ class FileSerializer(BulkSerializerMixin, serializers.ModelSerializer):
language = LanguageSerializer(many=False, required=False, allow_null=True)
display_name = serializers.SerializerMethodField('retrieve_display_name')
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.


def get(*args, **kwargs):
return super.get(*args, **kwargs)
Expand Down
4 changes: 3 additions & 1 deletion contentcuration/contentcuration/utils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
def create_file_from_contents(contents, ext=None, node=None, preset_id=None, uploaded_by=None):
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.

result = File.objects.create(
file_on_disk=DjFile(new_file),
file_format_id=ext,
file_size=default_storage.size(path),
Expand All @@ -32,6 +33,7 @@ def create_file_from_contents(contents, ext=None, node=None, preset_id=None, upl
contentnode=node,
uploaded_by=uploaded_by
)
return result


def get_file_diff(files):
Expand Down
1 change: 1 addition & 0 deletions contentcuration/contentcuration/views/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def file_create(request):
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.

original_filename, ext = os.path.splitext(request.FILES.values()[0]._name)
size = request.FILES.values()[0]._size
contentfile = DjFile(request.FILES.values()[0])
Expand Down