예제 #1
0
def inexact_match_form_condition(wizard):
    """Checks if inexact match form is necessary.

    If not, it means that all sites have been matched exactly; hide this step.
    """
    sites = session_utils.get(wizard.request.session, 'sites')
    all_exact_matched = (sites and all(
        site.is_matched() and site.get_match().is_exact() for site in sites))
    return not all_exact_matched
예제 #2
0
def inexact_match_form_condition(wizard):
    """Checks if inexact match form is necessary.

    If not, it means that all sites have been matched exactly; hide this step.
    """
    sites = session_utils.get(wizard.request.session, 'sites')
    all_exact_matched = (sites and
                         all(site.is_matched() and site.get_match().is_exact()
                             for site in sites))
    return not all_exact_matched
예제 #3
0
    def render(self, form=None, **kwargs):
        """Gets called after the GET or POST request has been handled.

        The only reason to override this method is to check "no data" button in
        publication selection form step. If the curator selects a publication
        and checks the button "This paper contains no data.", the proper action
        is to terminate curation process as ther is no data to be curated. The
        problem is to process that information and redirect to the home
        page. This is achieved by overloading render method. Before this
        function is called, publication object is modified as having no
        data. Afterwards, this function is called and it redirects to the
        homepage with the message about the action that was performed.
        """
        form = form or self.get_form()
        context = self.get_context_data(form=form, **kwargs)

        session = self.request.session
        if session_utils.get(session, 'paper_contains_no_data'):
            msg = "The publication was marked as having no data."
            messages.info(self.request, msg)
            session_utils.clear(session)     # clear session data
            return redirect('homepage_home')

        return self.render_to_response(context)
예제 #4
0
    def render(self, form=None, **kwargs):
        """Gets called after the GET or POST request has been handled.

        The only reason to override this method is to check "no data" button in
        publication selection form step. If the curator selects a publication
        and checks the button "This paper contains no data.", the proper action
        is to terminate curation process as ther is no data to be curated. The
        problem is to process that information and redirect to the home
        page. This is achieved by overloading render method. Before this
        function is called, publication object is modified as having no
        data. Afterwards, this function is called and it redirects to the
        homepage with the message about the action that was performed.
        """
        form = form or self.get_form()
        context = self.get_context_data(form=form, **kwargs)

        session = self.request.session
        if session_utils.get(session, 'paper_contains_no_data'):
            msg = "The publication was marked as having no data."
            messages.info(self.request, msg)
            session_utils.clear(session)  # clear session data
            return redirect('homepage_home')

        return self.render_to_response(context)