示例#1
0
 def test_commit(self):
     prod = Production.objects.create(title="Tim Will Rock You",
                                      supertype="music")
     byline = Byline([Nick.objects.get(name='Gasman')],
                     [Nick.objects.get(name='Hooy-Program')])
     byline.commit(prod)
     self.assertTrue(prod.author_nicks.filter(name='Gasman').exists())
     self.assertTrue(
         prod.author_affiliation_nicks.filter(name='Hooy-Program').exists())
示例#2
0
def create(request):
    if request.method == "POST":
        production = Production(updated_at=datetime.datetime.now())
        form = CreateProductionForm(request.POST, instance=production)
        download_link_formset = ProductionDownloadLinkFormSet(request.POST, instance=production)
        if form.is_valid() and download_link_formset.is_valid():
            form.save()
            download_link_formset.save_ignoring_uniqueness()
            form.log_creation(request.user)
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = CreateProductionForm(initial={"byline": Byline.from_releaser_id(request.GET.get("releaser_id"))})
        download_link_formset = ProductionDownloadLinkFormSet()
    return render(request, "productions/create.html", {"form": form, "download_link_formset": download_link_formset})
示例#3
0
def create(request):
    if request.method == 'POST':
        production = Production(updated_at=datetime.datetime.now())
        form = CreateProductionForm(request.POST, instance=production)
        download_link_formset = ProductionDownloadLinkFormSet(request.POST, instance=production)
        if form.is_valid() and download_link_formset.is_valid():
            form.save()
            download_link_formset.save_ignoring_uniqueness()
            form.log_creation(request.user)
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = CreateProductionForm(initial={
            'byline': Byline.from_releaser_id(request.GET.get('releaser_id'))
        })
        download_link_formset = ProductionDownloadLinkFormSet()
    return render(request, 'productions/create.html', {
        'form': form,
        'download_link_formset': download_link_formset,
    })
示例#4
0
def create(request):
	if request.method == 'POST':
		production = Production(updated_at=datetime.datetime.now())
		form = CreateGraphicsForm(request.POST, instance=production)
		download_link_formset = ProductionDownloadLinkFormSet(request.POST, instance=production)
		if form.is_valid() and download_link_formset.is_valid():
			form.save()
			download_link_formset.save()
			form.log_creation(request.user)
			return HttpResponseRedirect(production.get_absolute_url())
	else:
		form = CreateGraphicsForm(initial={
			'byline': Byline.from_releaser_id(request.GET.get('releaser_id'))
		})
		download_link_formset = ProductionDownloadLinkFormSet()
	return render(request, 'graphics/create.html', {
		'form': form,
		'download_link_formset': download_link_formset,
	})
示例#5
0
    def clean(self, value):
        if not value:
            # pass on to Field to handle null value according to the 'blank' parameter
            return super(BylineField, self).clean(value)
        else:
            byline_lookup = BylineLookup.from_value(value)

            clean_author_nick_selections = []
            clean_affiliation_nick_selections = []
            if byline_lookup.autoaccept:
                validation_message = (
                    "Not all names could be matched to a scener or group; "
                    "please select the appropriate ones from the lists.")
            else:
                validation_message = "Please select the appropriate sceners / groups from the lists."

            for i, field in enumerate(
                    byline_lookup.author_matched_nick_fields):
                try:
                    value = byline_lookup.author_nick_selections[i]
                except IndexError:
                    raise ValidationError(validation_message)
                clean_value = field.clean(value)
                if not clean_value:
                    raise ValidationError(validation_message)
                clean_author_nick_selections.append(clean_value)

            for i, field in enumerate(
                    byline_lookup.affiliation_matched_nick_fields):
                try:
                    value = byline_lookup.affiliation_nick_selections[i]
                except IndexError:  # pragma: no cover
                    raise ValidationError(validation_message)
                clean_value = field.clean(value)
                if not clean_value:
                    raise ValidationError(validation_message)
                clean_affiliation_nick_selections.append(clean_value)

            return Byline(clean_author_nick_selections,
                          clean_affiliation_nick_selections)