Exemple #1
0
def start_submission(request, book_id=None):

    direct_submissions =  core_models.Setting.objects.get(group__name='general', name='direct_submissions').value
    default_review_type = core_models.Setting.objects.get(group__name='general', name='default_review_type').value
    review_type_selection = core_models.Setting.objects.get(group__name='general', name='review_type_selection').value

    ci_required = core_models.Setting.objects.get(group__name='general', name='ci_required')
    checklist_items = submission_models.SubmissionChecklistItem.objects.all()

    if book_id:
        book = get_object_or_404(core_models.Book, pk=book_id, owner=request.user)
        if not book.proposal and not direct_submissions:
            return redirect(reverse('proposal_start'))
        book_form = forms.SubmitBookStageOne(instance=book, ci_required=ci_required.value)
        checklist_form = forms.SubmissionChecklist(checklist_items=checklist_items, book=book)
    else:
        if not direct_submissions:
            return redirect(reverse('proposal_start'))
        book = None
        book_form = forms.SubmitBookStageOne()
        checklist_form = forms.SubmissionChecklist(checklist_items=checklist_items)

    if request.method == 'POST':
        if book:
            book_form = forms.SubmitBookStageOne(request.POST, instance=book, ci_required=ci_required.value, review_type_required = review_type_selection)
        else:
            book_form = forms.SubmitBookStageOne(request.POST, ci_required=ci_required.value, review_type_required = review_type_selection)

        checklist_form = forms.SubmissionChecklist(request.POST, checklist_items=checklist_items)

        if book_form.is_valid() and checklist_form.is_valid():
            book = book_form.save(commit=False)
            book.owner = request.user
            if not review_type_selection:
                book.review_type = default_review_type
            if not book.submission_stage > 2:
                book.submission_stage = 2
                book.save()
                log.add_log_entry(book, request.user, 'submission', 'Submission Started', 'Submission Started')
            book.save()

            if not book_id and book:
                if book.book_type == 'monograph':
                    logic.copy_author_to_submission(request.user, book)
                elif book.book_type == 'edited_volume':
                    logic.copy_editor_to_submission(request.user, book)
            return redirect(reverse('submission_two', kwargs={'book_id': book.id}))

    template = "submission/start_submission.html"
    context = {
        'book_form': book_form,
        'checklist_form': checklist_form,
        'book': book,
        'active': 1,
    }

    return render(request, template, context)
Exemple #2
0
def create_submission_from_proposal(proposal, proposal_type):
    book = models.Book(title=proposal.title, subtitle=proposal.subtitle,
        owner=proposal.owner, book_type=proposal_type, submission_stage=1)

    book.save()

    if book.book_type == 'monograph':
        submission_logic.copy_author_to_submission(proposal.owner, book)
    elif book.book_type == 'edited_volume':
        submission_logic.copy_editor_to_submission(proposal.owner, book)

    book.save()

    return book
Exemple #3
0
def start_submission(request, book_id=None):
    direct_submissions = core_models.Setting.objects.get(
        group__name='general', name='direct_submissions').value
    default_review_type = core_models.Setting.objects.get(
        group__name='general', name='default_review_type').value
    review_type_selection = core_models.Setting.objects.get(
        group__name='general', name='review_type_selection').value
    ci_required = core_models.Setting.objects.get(
        group__name='general',
        name='ci_required',
    )
    checklist_items = submission_models.SubmissionChecklistItem.objects.all()

    if book_id:
        book = get_object_or_404(
            core_models.Book,
            pk=book_id,
            owner=request.user,
        )
        if not book.proposal and not direct_submissions:
            return redirect(reverse('proposal_start'))

        book_form = forms.SubmitBookStageOne(
            instance=book,
            ci_required=ci_required.value,
        )
        checklist_form = forms.SubmissionChecklist(
            checklist_items=checklist_items,
            book=book,
        )
    else:
        if not direct_submissions:
            return redirect(reverse('proposal_start'))

        book = None
        book_form = forms.SubmitBookStageOne()
        checklist_form = forms.SubmissionChecklist(
            checklist_items=checklist_items, )

    if request.method == 'POST':
        if book:
            book_form = forms.SubmitBookStageOne(
                request.POST,
                instance=book,
                ci_required=ci_required.value,
                review_type_required=review_type_selection,
            )
        else:
            book_form = forms.SubmitBookStageOne(
                request.POST,
                ci_required=ci_required.value,
                review_type_required=review_type_selection,
            )

        checklist_form = forms.SubmissionChecklist(
            request.POST,
            checklist_items=checklist_items,
        )

        if book_form.is_valid() and checklist_form.is_valid():
            book = book_form.save(commit=False)
            book.owner = request.user

            if not review_type_selection:
                book.review_type = default_review_type

            if not book.submission_stage > 2:
                book.submission_stage = 2
                book.save()
                log.add_log_entry(
                    book,
                    request.user,
                    'submission',
                    'Submission Started',
                    'Submission Started',
                )
            book.save()

            if not book_id and book:
                if book.book_type == 'monograph':
                    logic.copy_author_to_submission(request.user, book)
                elif book.book_type == 'edited_volume':
                    logic.copy_editor_to_submission(request.user, book)

            return redirect(
                reverse('submission_two', kwargs={'book_id': book.id}))

    template = "submission/start_submission.html"
    context = {
        'book_form': book_form,
        'checklist_form': checklist_form,
        'book': book,
        'active': 1,
    }

    return render(request, template, context)