Skip to content

Commit

Permalink
Added logo model
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamín Mravec committed Nov 11, 2023
1 parent a5a84c7 commit 61b360e
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions cms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,11 @@ def perform_create(self, serializer):
raise exceptions.PermissionDenied(
'Nedostatočné práva na vytvorenie tohoto objektu')

@action(methods=['get'], detail=True, url_path='download')
def download_logo(self, request):
"""Stiahne logo"""
logo = self.get_object()
response = HttpResponse(
logo.file, content_type=mime_type(logo.file))
response['Content-Disposition'] = f'attachment; filename="{logo.name}"'
return response

@action(methods=['post'], detail=False, url_path='upload')
def upload_publication(self, request):
"""Nahrá súbor publikácie"""
def check_file(self, request):
if 'file' not in request.data:
raise exceptions.ParseError(detail='Request neobsahoval súbor')

file = request.data['file']
if mime_type(file) not in ['application/jpg', 'application/png']:
raise exceptions.ParseError(detail='Nesprávny formát')

return Response(status=status.HTTP_201_CREATED)


Expand Down

0 comments on commit 61b360e

Please sign in to comment.