def add_sequencelisting(request): # print 'add_sequencelisting invoked' if request.method == 'POST': form = SequenceListingForm(request.POST) title_form = TitleForm(request.POST) if form.is_valid() and title_form.is_valid(): sl_instance = SequenceListing.objects.create( fileName = request.POST.get('fileName'), dtdVersion = '1', softwareName = 'prototype', softwareVersion = '0.1', productionDate = timezone.now(), #should be overwritten upon xml export applicantFileReference = request.POST.get('applicantFileReference'), IPOfficeCode = request.POST.get('IPOfficeCode'), applicationNumberText = request.POST.get('applicationNumberText'), filingDate = request.POST.get('filingDate'), earliestPriorityIPOfficeCode = request.POST.get('earliestPriorityIPOfficeCode'), earliestPriorityApplicationNumberText = request.POST.get('earliestPriorityApplicationNumberText'), earliestPriorityFilingDate = request.POST.get('earliestPriorityFilingDate'), applicantName = request.POST.get('applicantName'), applicantNameLanguageCode = request.POST.get('applicantNameLanguageCode'), applicantNameLatin = request.POST.get('applicantNameLatin'), inventorName = request.POST.get('inventorName'), inventorNameLanguageCode = request.POST.get('inventorNameLanguageCode'), inventorNameLatin = request.POST.get('inventorNameLatin'), ) sl_instance.save() tcd = title_form.cleaned_data title_instance = Title(sequenceListing = sl_instance, inventionTitle = tcd['inventionTitle'], inventionTitleLanguageCode = tcd['inventionTitleLanguageCode'] ) title_instance.save() return HttpResponseRedirect(reverse('sequencelistings:detail', args=(sl_instance.pk,))) else: form = SequenceListingForm() title_form = TitleForm() return render(request, 'sequencelistings/add_sequencelisting.html', {'form': form, 'title_form': title_form})
def add_title(request, pk): # print 'add_title invoked' if request.method == 'POST': form = TitleForm(request.POST) if form.is_valid(): sl = SequenceListing.objects.get(pk=pk) cd = form.cleaned_data title_instance = Title(sequenceListing = sl, inventionTitle = cd['inventionTitle'].encode('utf-8'), inventionTitleLanguageCode = cd['inventionTitleLanguageCode'] ) title_instance.save() return HttpResponseRedirect(reverse('sequencelistings:detail', args=(pk,))) else: form = TitleForm() return render(request, 'sequencelistings/add_title.html', {'form': form, 'pk': pk})