def production_article(request, article_id): """ Displays typesetting tasks, Galleys and allows new Galleys to be uploaded. :param request: HttpRequest object :param article_id: Article object PK :return: HttpResponse object """ article = get_object_or_404(submission_models.Article, pk=article_id) production_assignment = models.ProductionAssignment.objects.get(article=article) galleys = logic.get_all_galleys(production_assignment.article) if request.POST: if 'xml' in request.POST: for uploaded_file in request.FILES.getlist('xml-file'): logic.save_galley(article, request, uploaded_file, True, "XML", False) if 'pdf' in request.POST: for uploaded_file in request.FILES.getlist('pdf-file'): logic.save_galley(article, request, uploaded_file, True, "PDF", False) if 'other' in request.POST: for uploaded_file in request.FILES.getlist('other-file'): logic.save_galley(article, request, uploaded_file, True, "Other", True) if 'prod' in request.POST: for uploaded_file in request.FILES.getlist('prod-file'): logic.save_prod_file(article, request, uploaded_file, 'Production Ready File') if 'supp' in request.POST: label = request.POST.get('label', 'Supplementary File') for uploaded_file in request.FILES.getlist('supp-file'): logic.save_supp_file(article, request, uploaded_file, label) return redirect(reverse('production_article', kwargs={'article_id': article.pk})) manuscripts = article.manuscript_files.filter(is_galley=False) data_files = article.data_figure_files.filter(is_galley=False) copyedit_files = logic.get_copyedit_files(article) template = 'production/assigned_article.html' context = { 'article': article, 'manuscripts': manuscripts, 'data_files': data_files, 'production_assignment': production_assignment, 'copyedit_files': copyedit_files, 'typeset_tasks': production_assignment.typesettask_set.all().order_by('-id'), 'galleys': galleys, 'complete_message': logic.get_complete_template(request, article, production_assignment) } return render(request, template, context)
def production_article(request, article_id): """ Displays typesetting tasks, Galleys and allows new Galleys to be uploaded. :param request: HttpRequest object :param article_id: Article object PK :return: HttpResponse object """ article = get_object_or_404( submission_models.Article, pk=article_id, journal=request.journal, ) try: production_assignment = models.ProductionAssignment.objects.get( article=article) except models.ProductionAssignment.DoesNotExist: return redirect( reverse( 'production_non_workflow_assign', kwargs={'article_id': article.pk}, )) galleys = logic.get_all_galleys(production_assignment.article) if request.POST: try: if 'file' in request.FILES: label = request.POST.get('label', None) for uploaded_file in request.FILES.getlist('file'): logic.save_galley( article, request, uploaded_file, True, label=label, ) except TypeError as exc: messages.add_message(request, messages.ERROR, str(exc)) except UnicodeDecodeError: messages.add_message(request, messages.ERROR, "Uploaded file is not UTF-8 encoded") if 'prod' in request.POST: for uploaded_file in request.FILES.getlist('prod-file'): logic.save_prod_file( article, request, uploaded_file, 'Production Ready File', ) if 'supp' in request.POST: label = request.POST.get('label', 'Supplementary File') for uploaded_file in request.FILES.getlist('supp-file'): logic.save_supp_file(article, request, uploaded_file, label) if 'source' in request.POST: for uploaded_file in request.FILES.getlist('source-file'): logic.save_source_file( article, request, uploaded_file, ) if not request.FILES: messages.add_message(request, messages.WARNING, 'No files uploaded.') return redirect( reverse('production_article', kwargs={'article_id': article.pk})) manuscripts = article.manuscript_files.filter(is_galley=False) data_files = article.data_figure_files.filter(is_galley=False) copyedit_files = logic.get_copyedit_files(article) template = 'production/assigned_article.html' context = { 'article': article, 'manuscripts': manuscripts, 'data_files': data_files, 'production_assignment': production_assignment, 'copyedit_files': copyedit_files, 'typeset_tasks': production_assignment.typesettask_set.all().order_by('-id'), 'galleys': galleys, 'complete_message': logic.get_complete_template(request, article, production_assignment) } return render(request, template, context)