Exemplo n.º 1
0
def waiver_application(context):
    plugin = plugin_settings.get_self()
    request = context['request']
    article = context['article']

    waiver_text = setting_handler.get_plugin_setting(
        plugin,
        'waiver_text',
        request.journal,
        create=True,
        pretty='Waiver Text',
    )
    enable_waivers = setting_handler.get_plugin_setting(
        plugin,
        'enable_waivers',
        request.journal,
        create=True,
        pretty='Enable Waivers',
    )
    if enable_waivers.value == 'on':
        return render_to_string(
            'apc/article_waiver_app.html',
            {
                'request': request,
                'waiver_text': waiver_text.value,
                'article': article,
            },
        )
    else:
        return ''
Exemplo n.º 2
0
def publication_fees(context):
    plugin = plugin_settings.get_self()
    request = context['request']

    enable_apcs = setting_handler.get_plugin_setting(
        plugin,
        'enable_apcs',
        request.journal,
        create=True,
        pretty='Enable APCs',
    )
    track_apcs = setting_handler.get_plugin_setting(
        plugin,
        'track_apcs',
        request.journal,
        create=True,
        pretty='Track APCs',
    )

    sections = submission_models.Section.objects.filter(
        journal=request.journal,
        public_submissions=True,
    ).prefetch_related('sectionapc')

    if track_apcs.value == 'on':
        return ''
    elif enable_apcs.value == 'on':
        return render_to_string(
            'apc/publication_fees.html',
            {'sections': sections},
        )
    return ''
Exemplo n.º 3
0
def set_apc(**kwargs):
    request = kwargs.get('request', None)
    article = kwargs.get('article', None)
    plugin = plugin_settings.get_self()

    if request and article:

        try:
            enable_apcs = setting_handler.get_plugin_setting(
                plugin,
                'enable_apcs',
                request.journal,
            )

            track_apcs = setting_handler.get_plugin_setting(
                plugin,
                'track_apcs',
                request.journal,
            )

            if enable_apcs.processed_value or track_apcs.processed_value:

                try:
                    section_apc = models.SectionAPC.objects.get(
                        section=article.section, )
                except models.SectionAPC.DoesNotExist:
                    messages.add_message(
                        request, messages.WARNING,
                        'APC Management is enabled but this'
                        ' section has no APC.')
                    return

                models.ArticleAPC.objects.create(
                    article=article,
                    section_apc=section_apc,
                    value=section_apc.value,
                    currency=section_apc.currency,
                )
        except (ObjectDoesNotExist, IndexError):
            pass
Exemplo n.º 4
0
def settings(request):
    plugin = plugin_settings.get_self()
    enable_apcs = setting_handler.get_plugin_setting(
        plugin,
        'enable_apcs',
        request.journal,
        create=True,
        pretty='Enable APCs',
    )
    track_apcs = setting_handler.get_plugin_setting(
        plugin,
        'track_apcs',
        request.journal,
        create=True,
        pretty='Track APCs',
    )
    waiver_text = setting_handler.get_plugin_setting(
        plugin,
        'waiver_text',
        request.journal,
        create=True,
        pretty='Waiver Text',
    )
    enable_waivers = setting_handler.get_plugin_setting(
        plugin,
        'enable_waivers',
        request.journal,
        create=True,
        pretty='Enable Waivers',
    )

    if request.POST:
        apc_post = request.POST.get('enable_apcs')
        track_post = request.POST.get('track_apcs')
        text_post = request.POST.get('waiver_text')
        waivers_post = request.POST.get('enable_waivers')

        setting_handler.save_plugin_setting(
            plugin,
            'enable_apcs',
            apc_post,
            request.journal,
        )
        setting_handler.save_plugin_setting(
            plugin,
            'track_apcs',
            track_post,
            request.journal,
        )
        setting_handler.save_plugin_setting(
            plugin,
            'waiver_text',
            text_post,
            request.journal,
        )
        setting_handler.save_plugin_setting(
            plugin,
            'enable_waivers',
            waivers_post,
            request.journal,
        )

        messages.add_message(request, messages.SUCCESS, 'Setting updated.')
        return redirect(reverse('apc_settings'))

    template = 'apc/settings.html'
    context = {
        'enable_apc': enable_apcs.value if enable_apcs else '',
        'track_apcs': track_apcs.value if track_apcs else '',
        'enable_waivers': enable_waivers.value if enable_waivers else '',
        'waiver_text': waiver_text.value if waiver_text else '',
    }

    return render(request, template, context)