Пример #1
0
    def is_job_editable(data):
        """Check if the given job is editable

        A job is editable if one of the following is true:
        * current user is superadmin or cataloger
        * the job 'status' is not 'closed' and the job's author is logged-in.

        Args:
            data (dict): the jobs metadata.

        Returns:
            bool: True if the job can be edited, False otherwise.
        """
        if is_superuser_or_cataloger_logged_in():
            return True

        submitter_orcid = get_value(data, "acquisition_source.orcid")
        if submitter_orcid != get_current_user_orcid():
            return False

        status = get_value(data, "status")
        if status != "closed":
            return True

        deadline = get_value(data, "deadline_date")
        if status == "closed" and not has_30_days_passed_after_deadline(
                deadline):
            return True
        return False
Пример #2
0
def _get_current_user_author_profile():
    current_user_orcid = get_current_user_orcid()
    try:
        current_author_profile = AuthorsRecord.get_record_by_pid_value(
            current_user_orcid, "orcid")
        return current_author_profile
    except PIDDoesNotExistError:
        return
Пример #3
0
 def get_user_orcid(self):
     return get_current_user_orcid()
Пример #4
0
def does_current_user_own_author_record(author):
    author_orcids = get_values_for_schema(author.get("ids", []), "ORCID")
    if author_orcids:
        author_orcid = author_orcids.pop()
        return get_current_user_orcid() == author_orcid
    return False