Пример #1
0
def add_screenshot(request, production_id):
	production = get_object_or_404(Production, id=production_id)
	if request.method == 'POST':
		uploaded_files = request.FILES.getlist('screenshot')
		file_count = len(uploaded_files)
		for f in uploaded_files:
			screenshot = Screenshot.objects.create(production=production)
			capture_upload_for_processing(f, screenshot.id)

		if file_count:
			# at least one screenshot was uploaded
			production.updated_at = datetime.datetime.now()
			production.has_bonafide_edits = True
			production.save()

			if file_count == 1:
				Edit.objects.create(action_type='add_screenshot', focus=production,
					description=("Added screenshot"), user=request.user)
			else:
				Edit.objects.create(action_type='add_screenshot', focus=production,
					description=("Added %s screenshots" % file_count), user=request.user)

		return HttpResponseRedirect(production.get_absolute_url())
	return render(request, 'productions/add_screenshot.html', {
		'production': production,
	})
Пример #2
0
def add_screenshot(request, production_id):
	production = get_object_or_404(Production, id=production_id)
	if request.method == 'POST':
		uploaded_files = request.FILES.getlist('screenshot')
		file_count = len(uploaded_files)
		for f in uploaded_files:
			screenshot = Screenshot.objects.create(production=production)
			capture_upload_for_processing(f, screenshot.id)

		if file_count:
			# at least one screenshot was uploaded
			production.updated_at = datetime.datetime.now()
			production.has_bonafide_edits = True
			production.save()

			if file_count == 1:
				Edit.objects.create(action_type='add_screenshot', focus=production,
					description=("Added screenshot"), user=request.user)
			else:
				Edit.objects.create(action_type='add_screenshot', focus=production,
					description=("Added %s screenshots" % file_count), user=request.user)

		return HttpResponseRedirect(production.get_absolute_url())
	return render(request, 'productions/add_screenshot.html', {
		'production': production,
	})
Пример #3
0
def add_screenshot(request, production_id, is_artwork_view=False):
    production = get_object_or_404(Production, id=production_id)
    if not production.editable_by_user(request.user):
        raise PermissionDenied

    if request.method == 'POST':
        uploaded_files = request.FILES.getlist('screenshot')
        file_count = len(uploaded_files)
        for f in uploaded_files:
            screenshot = Screenshot.objects.create(production=production)
            capture_upload_for_processing(f, screenshot.id)

        if file_count:
            # at least one screenshot was uploaded
            production.updated_at = datetime.datetime.now()
            production.has_bonafide_edits = True
            production.save()

            if file_count == 1:
                if is_artwork_view:
                    Edit.objects.create(action_type='add_screenshot',
                                        focus=production,
                                        description=("Added artwork"),
                                        user=request.user)
                else:
                    Edit.objects.create(action_type='add_screenshot',
                                        focus=production,
                                        description=("Added screenshot"),
                                        user=request.user)
            else:
                if is_artwork_view:
                    Edit.objects.create(action_type='add_screenshot',
                                        focus=production,
                                        description=("Added %s artworks" %
                                                     file_count),
                                        user=request.user)
                else:
                    Edit.objects.create(action_type='add_screenshot',
                                        focus=production,
                                        description=("Added %s screenshots" %
                                                     file_count),
                                        user=request.user)

        return HttpResponseRedirect(production.get_absolute_url())
    else:
        if is_artwork_view and production.supertype != 'music':
            return redirect('production_add_screenshot', production_id)
        elif not is_artwork_view and production.supertype == 'music':
            return redirect('production_add_artwork', production_id)

    if is_artwork_view:
        return render(request, 'productions/add_artwork.html', {
            'production': production,
        })

    else:
        return render(request, 'productions/add_screenshot.html', {
            'production': production,
        })
Пример #4
0
def add_screenshot(request, production_id, is_artwork_view=False):
	production = get_object_or_404(Production, id=production_id)
	if not production.editable_by_user(request.user):
		raise PermissionDenied

	if request.method == 'POST':
		uploaded_files = request.FILES.getlist('screenshot')
		file_count = len(uploaded_files)
		for f in uploaded_files:
			screenshot = Screenshot.objects.create(production=production)
			capture_upload_for_processing(f, screenshot.id)

		if file_count:
			# at least one screenshot was uploaded
			production.updated_at = datetime.datetime.now()
			production.has_bonafide_edits = True
			production.save()

			if file_count == 1:
				if is_artwork_view:
					Edit.objects.create(action_type='add_screenshot', focus=production,
						description=("Added artwork"), user=request.user)
				else:
					Edit.objects.create(action_type='add_screenshot', focus=production,
						description=("Added screenshot"), user=request.user)
			else:
				if is_artwork_view:
					Edit.objects.create(action_type='add_screenshot', focus=production,
						description=("Added %s artworks" % file_count), user=request.user)
				else:
					Edit.objects.create(action_type='add_screenshot', focus=production,
						description=("Added %s screenshots" % file_count), user=request.user)

		return HttpResponseRedirect(production.get_absolute_url())
	else:
		if is_artwork_view and production.supertype != 'music':
			return redirect('production_add_screenshot', production_id)
		elif not is_artwork_view and production.supertype == 'music':
			return redirect('production_add_artwork', production_id)

	if is_artwork_view:
		return render(request, 'productions/add_artwork.html', {
			'production': production,
		})

	else:
		return render(request, 'productions/add_screenshot.html', {
			'production': production,
		})