Changeset View
Changeset View
Standalone View
Standalone View
films/views/api/asset.py
| Show All 34 Lines | try: | ||||
| Asset.objects.filter(pk=asset_pk, is_published=True) | Asset.objects.filter(pk=asset_pk, is_published=True) | ||||
| .select_related( | .select_related( | ||||
| 'film', | 'film', | ||||
| 'collection', | 'collection', | ||||
| 'static_asset', | 'static_asset', | ||||
| 'static_asset__license', | 'static_asset__license', | ||||
| 'static_asset__author', | 'static_asset__author', | ||||
| 'static_asset__user', | 'static_asset__user', | ||||
| 'static_asset__storage_location', | |||||
| 'entry_asset__production_log_entry', | 'entry_asset__production_log_entry', | ||||
| ) | ) | ||||
| .get() | .get() | ||||
| ) | ) | ||||
| except Asset.DoesNotExist: | except Asset.DoesNotExist: | ||||
| raise Http404('No asset matches the given query.') | raise Http404('No asset matches the given query.') | ||||
| context = get_asset_context(asset, request) | context = get_asset_context(asset, request) | ||||
| return render(request, 'common/components/modal_asset.html', context) | return render(request, 'common/components/modal_asset.html', context) | ||||
| @require_safe | @require_safe | ||||
| def asset_zoom(request: HttpRequest, asset_pk: int) -> HttpResponse: | def asset_zoom(request: HttpRequest, asset_pk: int) -> HttpResponse: | ||||
| try: | try: | ||||
| asset = ( | asset = ( | ||||
| Asset.objects.filter(pk=asset_pk, is_published=True) | Asset.objects.filter(pk=asset_pk, is_published=True) | ||||
| .select_related('static_asset__storage_location') | |||||
| .get() | .get() | ||||
| ) | ) | ||||
| except Asset.DoesNotExist: | except Asset.DoesNotExist: | ||||
| raise Http404('No asset matches the given query.') | raise Http404('No asset matches the given query.') | ||||
| return render(request, 'common/components/modal_asset_zoom.html', {'asset': asset}) | return render(request, 'common/components/modal_asset_zoom.html', {'asset': asset}) | ||||