Ejemplo n.º 1
0
def production_assign_article(request, user_id, article_id):
    """
    Allows an editor to assign a production manager to an article.
    :param request: HttpRequest object
    :param user_id: Account object PK
    :param article_id: Article object PK
    :return: HttpRedirect
    """
    article = submission_models.Article.objects.get(id=article_id)
    user = core_models.Account.objects.get(id=user_id)

    if user.is_production(request):
        url = request.journal_base_url + reverse(
            'production_article', kwargs={'article_id': article.id})
        html = logic.get_production_assign_content(user, request, article, url)

        prod = models.ProductionAssignment(article=article,
                                           production_manager=user,
                                           editor=request.user)
        prod.save()

        cron_task.CronTask.add_email_task(user.email, 'Production assignment',
                                          html, request, article)
    else:
        messages.add_message(request, messages.WARNING,
                             'User is not a production manager.')

    return redirect('production_list')
Ejemplo n.º 2
0
    def setUp(self):
        """
        Setup the test environment.
        :return: None
        """
        self.journal_one, self.journal_two = self.create_journals()
        self.create_roles([
            "editor", "author", "reviewer", "proofreader", "production",
            "copyeditor", "typesetter", "proofing_manager", "section-editor"
        ])

        self.regular_user = self.create_user("*****@*****.**")
        self.regular_user.is_active = True
        self.regular_user.save()

        self.second_user = self.create_user("*****@*****.**",
                                            ["reviewer"],
                                            journal=self.journal_one)
        self.second_user.is_active = True
        self.second_user.save()

        self.admin_user = self.create_user("*****@*****.**")
        self.admin_user.is_staff = True
        self.admin_user.is_active = True
        self.admin_user.save()

        self.inactive_user = self.create_user(
            "*****@*****.**",
            ["editor", "author", "proofreader", "production"],
            journal=self.journal_one)
        self.inactive_user.is_active = False
        self.inactive_user.save()

        self.editor = self.create_user("*****@*****.**", ["editor"],
                                       journal=self.journal_one)
        self.editor.is_active = True
        self.editor.save()

        self.author = self.create_user("*****@*****.**", ["author"],
                                       journal=self.journal_one)
        self.author.is_active = True
        self.author.save()

        self.proofreader = self.create_user("*****@*****.**",
                                            ["proofreader"],
                                            journal=self.journal_one)
        self.proofreader.is_active = True
        self.proofreader.save()

        self.proofreader_two = self.create_user("*****@*****.**",
                                                ["proofreader"],
                                                journal=self.journal_one)
        self.proofreader_two.is_active = True
        self.proofreader_two.save()

        self.production = self.create_user("*****@*****.**",
                                           ["production"],
                                           journal=self.journal_one)
        self.production.is_active = True
        self.production.save()

        self.copyeditor = self.create_user("*****@*****.**",
                                           ["copyeditor"],
                                           journal=self.journal_one)
        self.copyeditor.is_active = True
        self.copyeditor.save()

        self.typesetter = self.create_user("*****@*****.**",
                                           ["typesetter"],
                                           journal=self.journal_one)
        self.typesetter.is_active = True
        self.typesetter.save()

        self.other_typesetter = self.create_user(
            "*****@*****.**", ["typesetter"],
            journal=self.journal_one)
        self.other_typesetter.is_active = True
        self.other_typesetter.save()

        self.proofing_manager = self.create_user(
            "*****@*****.**", ["proofing_manager"],
            journal=self.journal_one)
        self.proofing_manager.is_active = True
        self.proofing_manager.save()

        self.other_typesetter.is_active = True
        self.other_typesetter.save()

        self.section_editor = self.create_user("*****@*****.**",
                                               ['section-editor'],
                                               journal=self.journal_one)
        self.section_editor.is_active = True
        self.section_editor.save()

        self.second_reviewer = self.create_user(
            "*****@*****.**", ['reviewer'],
            journal=self.journal_one)
        self.second_reviewer.is_active = True
        self.second_reviewer.save()

        self.public_file = core_models.File(mime_type="A/FILE",
                                            original_filename="blah.txt",
                                            uuid_filename="UUID.txt",
                                            label="A file that is public",
                                            description="Oh yes, it's a file",
                                            owner=self.regular_user,
                                            is_galley=False,
                                            privacy="public")

        self.public_file.save()

        self.private_file = core_models.File(mime_type="A/FILE",
                                             original_filename="blah.txt",
                                             uuid_filename="UUID.txt",
                                             label="A file that is private",
                                             description="Oh yes, it's a file",
                                             owner=self.regular_user,
                                             is_galley=False,
                                             privacy="owner")

        self.private_file.save()

        self.article_in_production = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_TYPESETTING,
            journal_id=self.journal_one.id)
        self.article_in_production.save()
        self.article_in_production.data_figure_files.add(self.public_file)

        self.article_unsubmitted = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_UNSUBMITTED,
            journal_id=self.journal_one.id)
        self.article_unsubmitted.save()

        self.article_unassigned = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_UNASSIGNED,
            journal_id=self.journal_one.id)
        self.article_unassigned.save()

        self.article_assigned = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_ASSIGNED,
            journal_id=self.journal_one.id)
        self.article_assigned.save()

        self.article_under_review = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_UNDER_REVIEW,
            journal_id=self.journal_one.id)
        self.article_under_review.save()

        self.article_review_completed = submission_models.Article.objects.create(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_ACCEPTED,
            journal_id=self.journal_one.id,
            date_accepted=timezone.now())

        self.article_author_is_owner = submission_models.Article.objects.create(
            owner=self.author,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_ACCEPTED,
            journal_id=self.journal_one.id,
            date_accepted=timezone.now())

        self.article_author_is_owner.authors.add(self.editor)
        self.article_author_is_owner.authors.add(self.author)

        self.review_form = review_models.ReviewForm(name="A Form",
                                                    slug="A Slug",
                                                    intro="i",
                                                    thanks="t",
                                                    journal=self.journal_one)
        self.review_form.save()

        self.review_assignment_complete = review_models.ReviewAssignment(
            article=self.article_review_completed,
            reviewer=self.regular_user,
            editor=self.editor,
            date_due=datetime.datetime.now(),
            form=self.review_form,
            is_complete=True,
            date_complete=timezone.now())

        self.review_assignment_complete.save()

        self.review_assignment = review_models.ReviewAssignment(
            article=self.article_under_review,
            reviewer=self.second_user,
            editor=self.editor,
            date_due=datetime.datetime.now(),
            form=self.review_form)

        self.review_assignment.save()

        self.review_assignment_not_in_scope = review_models.ReviewAssignment(
            article=self.article_in_production,
            reviewer=self.regular_user,
            editor=self.editor,
            date_due=datetime.datetime.now(),
            form=self.review_form)
        self.review_assignment_not_in_scope.save()

        self.article_under_revision = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_UNDER_REVISION,
            journal_id=self.journal_one.id)
        self.article_under_revision.save()

        self.article_rejected = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_REJECTED,
            journal_id=self.journal_one.id)
        self.article_rejected.save()

        self.article_accepted = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_ACCEPTED,
            journal_id=self.journal_one.id)
        self.article_accepted.save()

        self.section_editor_assignment = review_models.EditorAssignment(
            article=self.article_assigned,
            editor=self.section_editor,
            editor_type='section-editor',
            notified=True)
        self.section_editor_assignment.save()

        self.article_editor_copyediting = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_EDITOR_COPYEDITING,
            journal_id=self.journal_one.id)
        self.article_editor_copyediting.save()

        self.article_author_copyediting = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_AUTHOR_COPYEDITING,
            journal_id=self.journal_one.id)
        self.article_author_copyediting.save()

        self.article_final_copyediting = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_FINAL_COPYEDITING,
            journal_id=self.journal_one.id)
        self.article_final_copyediting.save()

        self.article_proofing = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_PROOFING,
            journal_id=self.journal_one.id)
        self.article_proofing.save()

        assigned = production_models.ProductionAssignment(
            article=self.article_in_production,
            production_manager=self.production)
        assigned.save()

        self.article_published = submission_models.Article(
            owner=self.regular_user,
            title="A Second Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_PUBLISHED,
            journal_id=self.journal_one.id)
        self.article_published.save()

        assigned = production_models.ProductionAssignment(
            article=self.article_published, production_manager=self.production)
        assigned.save()

        self.article_in_production_inactive = submission_models.Article(
            owner=self.regular_user,
            title="A Test Article",
            abstract="An abstract",
            stage=submission_models.STAGE_TYPESETTING,
            journal_id=self.journal_one.id)
        self.article_in_production_inactive.save()

        self.assigned = production_models.ProductionAssignment(
            article=self.article_in_production_inactive,
            production_manager=self.inactive_user)
        self.assigned.save()

        self.copyedit_assignment = copyediting_models.CopyeditAssignment(
            article=self.article_editor_copyediting,
            editor=self.editor,
            copyeditor=self.copyeditor,
            due=timezone.now(),
            assigned=timezone.now(),
            notified=timezone.now(),
            decision='accepted',
            date_decided=timezone.now())
        self.copyedit_assignment.save()

        self.typeset_task = production_models.TypesetTask(
            assignment=self.assigned,
            typesetter=self.typesetter,
            notified=True,
            accepted=timezone.now())
        self.typeset_task.save()

        self.other_typeset_task = production_models.TypesetTask(
            assignment=self.assigned,
            typesetter=self.other_typesetter,
            notified=True,
            accepted=timezone.now())
        self.other_typeset_task.save()

        self.proofing_assignment = proofing_models.ProofingAssignment(
            article=self.article_proofing,
            proofing_manager=self.proofing_manager,
            notified=True)
        self.proofing_assignment.save()
        self.proofing_assignment.add_new_proofing_round()

        self.proofing_task = proofing_models.ProofingTask(
            round=self.proofing_assignment.current_proofing_round(),
            proofreader=self.proofreader,
            notified=True,
            due=timezone.now(),
            accepted=timezone.now(),
            task='sdfsdffs')
        self.proofing_task.save()

        self.correction_task = proofing_models.TypesetterProofingTask(
            proofing_task=self.proofing_task,
            typesetter=self.typesetter,
            notified=True,
            due=timezone.now(),
            accepted=timezone.now(),
            task='fsddsff')
        self.correction_task.save()

        self.journal_one.name = 'Journal One'
        self.journal_two.name = 'Journal Two'
        self.press = press_models.Press.objects.create(name='Press',
                                                       domain='localhost',
                                                       main_contact='*****@*****.**')
        self.press.save()
        call_command('sync_journals_to_sites')