Example #1
0
def home(request):
    """Dashboard home page view."""
    deans = get_deans()
    user = request.user
    hr = in_group(user, settings.HR_GROUP)
    # HR or VPFA can access all objects
    if hr or user.id == LEVEL2.id:
        requisitions = Requisition.objects.all().order_by('-created_at')[:30]
        transactions = Transaction.objects.all().order_by('-created_at')[:30]
    elif user.id == PROVOST.id:
        # PRF
        reqs1 = Requisition.objects.filter(level3_approver__pk__in=deans)
        reqs2 = Requisition.objects.filter(level3_approver__pk=PROVOST.id)
        reqs = reqs1 | reqs2
        requisitions = reqs.order_by('-created_at')[:30]
        # PAF
        trans1 = Transaction.objects.filter(level3_approver__pk__in=deans)
        trans2 = Transaction.objects.filter(level3_approver__pk=PROVOST.id)
        trans = trans1 | trans2
        transactions = trans.order_by('-created_at')[:30]
    else:
        requisitions = Requisition.objects.filter(
            Q(created_by=user) | Q(level3_approver=user)
        ).order_by('-created_at')[:30]
        transactions = Transaction.objects.filter(
            Q(created_by=user) | Q(level3_approver=user)
        ).order_by('-created_at')[:30]

    return render(
        request,
        'home.html',
        {'hr': hr, 'requisitions': requisitions, 'transactions': transactions},
    )
 def notify_provost(self):
     """
     Provost must be notified about submissions that are approved by a
     division dean at level 3
     """
     if self.level3_approver.id in get_deans():
         return True
     else:
         return False
Example #3
0
 def notify_provost(self):
     """
     Provost must approve submissions that are approved by a
     division dean at level 3
     """
     if self.level3_approver.id in get_deans(
     ) or self.level3_approver.id == PROVOST.id:
         return True
     else:
         return False
Example #4
0
def list(request, mod):
    """Display a complete list of all objects."""
    deans = get_deans()
    user = request.user
    hr = in_group(user, settings.HR_GROUP)
    # HR or VPFA can access all objects
    if hr or user.id == LEVEL2.id:
        if mod == 'requisition':
            objects = Requisition.objects.all()
        elif mod == 'transaction':
            objects = Transaction.objects.all()
        else:
            objects = None
    # Provost can view all objects created by Deans
    elif user.id == PROVOST.id:
        if mod == 'requisition':
            reqs1 = Requisition.objects.filter(level3_approver__pk__in=deans)
            reqs2 = Requisition.objects.filter(level3_approver__pk=PROVOST.id)
            reqs = reqs1 | reqs2
            objects = reqs.order_by('-created_at')
        elif mod == 'transaction':
            trans1 = Transaction.objects.filter(level3_approver__pk__in=deans)
            trans2 = Transaction.objects.filter(level3_approver__pk=PROVOST.id)
            trans = trans1 | trans2
            objects = trans.order_by('-created_at')
        else:
            objects = None
    else:
        if mod == 'requisition':
            objects = Requisition.objects.filter(
                Q(created_by=user) | Q(level3_approver=user)
            )
        elif mod == 'transaction':
            objects = Transaction.objects.filter(
                Q(created_by=user) | Q(level3_approver=user)
            )
        else:
            objects = None

    return render(
        request, 'list.html', {'hr': hr, 'objects': objects, 'mod': mod},
    )
Example #5
0
 def test_get_deans(self):
     deans = get_deans()
     print("deans = {}".format(deans))