Beispiel #1
0
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)
Beispiel #2
0
def production_article(request, article_id):
    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)

        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)
Beispiel #3
0
def article(request, article_id):
    article = get_object_or_404(models.Article,
                                pk=article_id,
                                journal=request.journal)
    article_form = forms.ArticleInfo(instance=article)
    author_form = forms.AuthorForm()
    pub_form = bc_forms.PublicationInfo(instance=article)
    remote_form = bc_forms.RemoteArticle(instance=article)
    modal = None

    if request.POST:
        if 'save_section_1' in request.POST:
            article_form = forms.ArticleInfo(request.POST, instance=article)

            if article_form.is_valid():
                article_form.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_2' in request.POST:
            correspondence_author = request.POST.get('main-author', None)

            if correspondence_author:
                author = core_models.Account.objects.get(
                    pk=correspondence_author)
                article.correspondence_author = author
                article.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_4' in request.POST:
            pub_form = bc_forms.PublicationInfo(request.POST, instance=article)

            if pub_form.is_valid():
                pub_form.save()
                if article.primary_issue:
                    article.primary_issue.articles.add(article)

                if article.date_published:
                    article.stage = models.STAGE_READY_FOR_PUBLICATION
                    article.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_5' in request.POST:
            remote_form = bc_forms.RemoteArticle(request.POST,
                                                 instance=article)

            if remote_form.is_valid():
                remote_form.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'xml' in request.POST:
            for uploaded_file in request.FILES.getlist('xml-file'):
                prod_logic.save_galley(article, request, uploaded_file, True,
                                       "XML", False)

        if 'pdf' in request.POST:
            for uploaded_file in request.FILES.getlist('pdf-file'):
                prod_logic.save_galley(article, request, uploaded_file, True,
                                       "PDF", False)

        if 'other' in request.POST:
            for uploaded_file in request.FILES.getlist('other-file'):
                prod_logic.save_galley(article, request, uploaded_file, True,
                                       "Other", True)

        if 'add_author' in request.POST:
            author_form = forms.AuthorForm(request.POST)
            modal = 'author'

            author_exists = logic.check_author_exists(
                request.POST.get('email'))
            if author_exists:
                article.authors.add(author_exists)
                messages.add_message(
                    request, messages.SUCCESS,
                    '%s added to the article' % author_exists.full_name())
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article_id}))
            else:
                if author_form.is_valid():
                    new_author = author_form.save(commit=False)
                    new_author.username = new_author.email
                    new_author.set_password(shared.generate_password())
                    new_author.save()
                    new_author.add_account_role(role_slug='author',
                                                journal=request.journal)
                    article.authors.add(new_author)
                    messages.add_message(
                        request, messages.SUCCESS,
                        '%s added to the article' % new_author.full_name())

                    return redirect(
                        reverse('bc_article',
                                kwargs={'article_id': article_id}))

        if 'publish' in request.POST:
            if not article.stage == models.STAGE_PUBLISHED:
                id_logic.generate_crossref_doi_with_pattern(article)
                article.stage = models.STAGE_PUBLISHED
                article.snapshot_authors(article)
                article.save()

            if plugin_settings.IS_WORKFLOW_PLUGIN:
                workflow_kwargs = {
                    'handshake_url': 'bc_article',
                    'request': request,
                    'article': article,
                    'switch_stage': True
                }
                return event_logic.Events.raise_event(
                    event_logic.Events.ON_WORKFLOW_ELEMENT_COMPLETE,
                    task_object=article,
                    **workflow_kwargs)
            else:
                return redirect(reverse('bc_index'))

    template = 'back_content/article.html'
    context = {
        'article': article,
        'article_form': article_form,
        'form': author_form,
        'pub_form': pub_form,
        'galleys': prod_logic.get_all_galleys(article),
        'remote_form': remote_form,
        'modal': modal
    }

    return render(request, template, context)
Beispiel #4
0
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)
Beispiel #5
0
def manage_archive_article(request, article_id):
    from production import logic as production_logic
    from identifiers import models as identifier_models
    from submission import forms as submission_forms
    article = get_object_or_404(submission_models.Article, pk=article_id)
    galleys = production_logic.get_all_galleys(article)
    identifiers = identifier_models.Identifier.objects.filter(article=article)

    if request.POST:

        if 'xml' in request.POST:
            for uploaded_file in request.FILES.getlist('xml-file'):
                production_logic.save_galley(article, request, uploaded_file,
                                             True, "XML", False)

        if 'pdf' in request.POST:
            for uploaded_file in request.FILES.getlist('pdf-file'):
                production_logic.save_galley(article, request, uploaded_file,
                                             True, "PDF", False)

        if 'delete_note' in request.POST:
            note_id = int(request.POST['delete_note'])
            publisher_note = submission_models.PublisherNote.objects.get(
                pk=note_id)
            publisher_note.delete()

        if 'add_publisher_note' in request.POST:
            pn = submission_models.PublisherNote()
            pn.creator = request.user
            pn.sequence = 0
            pn_form = submission_forms.PublisherNoteForm(data=request.POST,
                                                         instance=pn)
            pn_form.save()

            article.publisher_notes.add(pn)
            article.save()

        if 'save_publisher_note' in request.POST:
            note_id = int(request.POST['save_publisher_note'])
            pn = submission_models.PublisherNote.objects.get(pk=note_id)
            pn_form = submission_forms.PublisherNoteForm(data=request.POST,
                                                         instance=pn)
            pn_form.save()

        if 'other' in request.POST:
            for uploaded_file in request.FILES.getlist('other-file'):
                production_logic.save_galley(article, request, uploaded_file,
                                             True, "Other", True)

        return redirect(
            reverse('manage_archive_article',
                    kwargs={'article_id': article.pk}))

    newnote_form = submission_forms.PublisherNoteForm()

    note_forms = []

    for publisher_note in article.publisher_notes.all():
        note_form = submission_forms.PublisherNoteForm(instance=publisher_note)
        note_forms.append(note_form)

    template = 'journal/manage/archive_article.html'
    context = {
        'article': article,
        'galleys': galleys,
        'identifiers': identifiers,
        'newnote_form': newnote_form,
        'note_forms': note_forms
    }

    return render(request, template, context)
Beispiel #6
0
def article(request, article_id):
    article = get_object_or_404(models.Article,
                                pk=article_id,
                                journal=request.journal)
    article_form = bc_forms.ArticleInfo(instance=article)
    author_form = forms.AuthorForm()
    pub_form = bc_forms.PublicationInfo(instance=article)
    remote_form = bc_forms.RemoteArticle(instance=article)
    existing_author_form = bc_forms.ExistingAuthor()
    modal = None

    if request.POST:
        if 'save_section_1' in request.POST:
            article_form = bc_forms.ArticleInfo(request.POST, instance=article)

            if article_form.is_valid():
                article_form.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_2' in request.POST:
            correspondence_author = request.POST.get('main-author', None)

            if correspondence_author:
                author = core_models.Account.objects.get(
                    pk=correspondence_author)
                article.correspondence_author = author
                article.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_4' in request.POST:
            pub_form = bc_forms.PublicationInfo(request.POST, instance=article)

            if pub_form.is_valid():
                pub_form.save()
                if article.primary_issue:
                    article.primary_issue.articles.add(article)

                if article.date_published:
                    article.stage = models.STAGE_READY_FOR_PUBLICATION
                    article.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'save_section_5' in request.POST:
            remote_form = bc_forms.RemoteArticle(request.POST,
                                                 instance=article)

            if remote_form.is_valid():
                remote_form.save()
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article.pk}))

        if 'file' in request.FILES:
            label = request.POST.get('label')
            for uploaded_file in request.FILES.getlist('file'):
                prod_logic.save_galley(
                    article,
                    request,
                    uploaded_file,
                    is_galley=True,
                    label=label,
                )

        if 'existing_author' in request.POST:
            existing_author_form = bc_forms.ExistingAuthor(request.POST)
            if existing_author_form.is_valid():
                author = existing_author_form.cleaned_data.get('author')
                article.authors.add(author)
                messages.add_message(
                    request,
                    messages.SUCCESS,
                    'Author added to the article.',
                )
                models.ArticleAuthorOrder.objects.get_or_create(
                    article=article,
                    author=author,
                    defaults={
                        'order': article.next_author_sort(),
                    })
                return redirect(
                    reverse('bc_article', kwargs={'article_id': article_id}))

        if 'add_author' in request.POST:
            author_form = forms.AuthorForm(request.POST)
            modal = 'author'

            author = logic.check_author_exists(request.POST.get('email'))
            if author:
                article.authors.add(author)
                messages.add_message(
                    request,
                    messages.SUCCESS,
                    '%s added to the article' % author.full_name(),
                )
            else:
                if author_form.is_valid():
                    author = author_form.save(commit=False)
                    author.username = author.email
                    author.set_password(shared.generate_password())
                    author.save()
                    author.add_account_role(
                        role_slug='author',
                        journal=request.journal,
                    )
                    article.authors.add(author)
                    messages.add_message(
                        request,
                        messages.SUCCESS,
                        '%s added to the article' % author.full_name(),
                    )

            models.ArticleAuthorOrder.objects.get_or_create(
                article=article,
                author=author,
                defaults={
                    'order': article.next_author_sort(),
                })

            return redirect(
                reverse('bc_article', kwargs={'article_id': article_id}))

        if 'publish' in request.POST:
            crossref_enabled = request.journal.get_setting(
                'Identifiers',
                'use_crossref',
            )
            if not article.stage == models.STAGE_PUBLISHED:
                if crossref_enabled:
                    id_logic.generate_crossref_doi_with_pattern(article)
                article.stage = models.STAGE_PUBLISHED
                article.snapshot_authors(article)
                article.save()

            if plugin_settings.IS_WORKFLOW_PLUGIN:
                workflow_kwargs = {
                    'handshake_url': 'bc_article',
                    'request': request,
                    'article': article,
                    'switch_stage': True
                }
                return event_logic.Events.raise_event(
                    event_logic.Events.ON_WORKFLOW_ELEMENT_COMPLETE,
                    task_object=article,
                    **workflow_kwargs)
            else:
                return redirect(reverse('bc_index'))

    template = 'back_content/article.html'
    context = {
        'article': article,
        'article_form': article_form,
        'form': author_form,
        'pub_form': pub_form,
        'galleys': prod_logic.get_all_galleys(article),
        'remote_form': remote_form,
        'existing_author_form': existing_author_form,
        'modal': modal
    }

    return render(request, template, context)