Skip to content
Snippets Groups Projects
Commit eb79fc15 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

file_url validation

parent bcbc0666
No related branches found
No related tags found
No related merge requests found
Pipeline #3182 passed
...@@ -44,6 +44,8 @@ class DocumentSerializer(serializers.ModelSerializer): ...@@ -44,6 +44,8 @@ class DocumentSerializer(serializers.ModelSerializer):
return obj.uploaded_by.full_name return obj.uploaded_by.full_name
def get_file_url(self, obj): def get_file_url(self, obj):
if not obj.file:
return ""
return f"/api/v1/documents/{obj.id}/download/" return f"/api/v1/documents/{obj.id}/download/"
def validate_solution(self, value): def validate_solution(self, value):
...@@ -54,5 +56,6 @@ class DocumentSerializer(serializers.ModelSerializer): ...@@ -54,5 +56,6 @@ class DocumentSerializer(serializers.ModelSerializer):
uploaded_by=profile, solution=value).count() uploaded_by=profile, solution=value).count()
if count >= _max_count: if count >= _max_count:
raise serializers.ValidationError( raise serializers.ValidationError(
f'You cant upload more than {_max_count} document to one solution!') f'You cant upload more than {_max_count}\
document to one solution!')
return value return value
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment