Esempio n. 1
0
File: rules.py Progetto: rerb/stars
def user_can_preview_submission(user, submission):
    """
        Only rated submissions and the current submission data
    """
    if user_has_access_level(user, 'view', submission.institution):
        if (submission.status == 'r' or
                submission == submission.institution.current_submission):
            return True
    return False
Esempio n. 2
0
File: rules.py Progetto: rerb/stars
def user_can_migrate_version(user, institution):
    """
        Only institution admins can migrate a submission
    """
    if (institution.current_submission.creditset.version !=
            CreditSet.objects.get_latest().version):
        return user_has_access_level(user, 'admin', institution)
    else:
        return False
Esempio n. 3
0
File: rules.py Progetto: rerb/stars
def user_can_migrate_from_submission(user, submission):
    """
        Only institution admins can migrate a submission

        Participants can migrate from Reports or Snapshots
        Respondents can only migrate from Reports
    """
    if user_has_access_level(user, 'admin', submission.institution):
        if submission.status == 'r' or submission.status == 'f':
            return True
    return False
Esempio n. 4
0
File: rules.py Progetto: rerb/stars
def user_can_view_export(user, submission):
    """
        As long as a user can view an institution's submissions they
        can export their rated submissions

        Only Full-Access users can export their current submissions

        All users can export their own snapshots

        All participants can export rated submissions
    """
    if submission.status == 'r':
        if user_is_participant(user):
            return True

    if user_has_access_level(user, 'view', submission.institution):
        if submission.status == 'r':
            return True
            # all institutions have access to exports for their own reports
        elif submission.institution.current_submission == submission:
            return True
        elif submission.status == 'f':
            return True
    return False
Esempio n. 5
0
File: rules.py Progetto: rerb/stars
def user_can_migrate_data(user, institution):
    """
        Can this user do a data migration?
        Only institution admins can migrate a submission
    """
    return user_has_access_level(user, 'admin', institution)
Esempio n. 6
0
File: rules.py Progetto: rerb/stars
def user_can_see_internal_notes(user, submission):
    return user_has_access_level(user, 'view', submission.institution)
Esempio n. 7
0
File: rules.py Progetto: rerb/stars
def user_can_manage_submission(user, submission):
    return (submission_is_editable(submission) and
            user_has_access_level(user, 'admin', submission.institution))
Esempio n. 8
0
File: rules.py Progetto: rerb/stars
def user_can_edit_submission_or_is_admin(user, submission):
    return (user_can_edit_submission(submission=submission,
                                     user=user) or
            user_has_access_level(user=user,
                                  access_level='admin',
                                  institution=submission.institution))
Esempio n. 9
0
File: rules.py Progetto: rerb/stars
def user_can_edit_submission(user, submission):
    return (submission_is_editable(submission) and
            user_has_access_level(user, 'submit', submission.institution))