Exemple #1
0
def policy_group_details(request, group_uuid=None):
    username = request.user.username
    can_access_dashboard = PermissionManager.user_can_access_dashboard(
        request.user)
    if not can_access_dashboard:
        logger.warning("Payment : PermissionDenied to user %s for path %s",
                       username, request.path)
        raise PermissionDenied

    can_view_policy = PermissionManager.user_can_view_policy(request.user)
    if not can_view_policy:
        logger.warning("PermissionDenied to user %s for path %s", username,
                       request.path)
        raise PermissionDenied

    context = {'content_title': CORE_STRINGS.DASHBOARD_POLICY_GROUP_TITLE}
    group = get_object_or_404(PaymentPolicyGroup, policy_group_uuid=group_uuid)
    template_name = "payment/policy_group_detail.html"
    page_title = "Policy Group Details - " + settings.SITE_NAME
    context['page_title'] = page_title
    context['group'] = group
    context['members'] = group.members.all()
    context['users'] = User.objects.filter(is_active=True, is_superuser=False)
    context.update(get_view_permissions(request.user))
    return render(request, template_name, context)
Exemple #2
0
def policy_groups(request):
    username = request.user.username
    can_access_dashboard = PermissionManager.user_can_access_dashboard(
        request.user)
    if not can_access_dashboard:
        logger.warning("Payment : PermissionDenied to user %s for path %s",
                       username, request.path)
        raise PermissionDenied

    can_view_policy = PermissionManager.user_can_view_policy(request.user)
    can_add_policy = PermissionManager.user_can_add_policy(request.user)
    if not can_view_policy:
        logger.warning("PermissionDenied to user %s for path %s", username,
                       request.path)
        raise PermissionDenied

    context = {'content_title': CORE_STRINGS.DASHBOARD_POLICY_GROUPS_TITLE}
    queryset = PaymentPolicyGroup.objects.all()
    template_name = "payment/policy_group_list.html"
    page_title = "Policy Group - " + settings.SITE_NAME
    page = request.GET.get('page', 1)
    paginator = Paginator(queryset, utils.PAGINATED_BY)
    try:
        list_set = paginator.page(page)
    except PageNotAnInteger:
        list_set = paginator.page(1)
    except EmptyPage:
        list_set = None
    context['page_title'] = page_title
    context['groups'] = list_set
    context.update(get_view_permissions(request.user))
    return render(request, template_name, context)
Exemple #3
0
def pay_vendor(request, vendor_pk):
    username = request.user.username

    can_view_payment = PermissionManager.user_can_view_policy(request.user)
    if not can_view_payment:
        logger.warning("PermissionDenied to user %s for path %s", username,
                       request.path)
        raise PermissionDenied
    vendor = get_object_or_404(User, pk=vendor_pk)
    payment = payment_service.process_vendor_payment(vendor)
    if payment:
        messages.success(request,
                         f"Payment for vendor {vendor.username} processed")
    else:
        messages.warning(
            request, f"Payment for vendor {vendor.username} not processed")

    return redirect('dashboard:users')
Exemple #4
0
def policy_details(request, policy_uuid=None):
    username = request.user.username
    can_access_dashboard = PermissionManager.user_can_access_dashboard(
        request.user)
    if not can_access_dashboard:
        logger.warning("Payment : PermissionDenied to user %s for path %s",
                       username, request.path)
        raise PermissionDenied

    can_view_policy = PermissionManager.user_can_view_policy(request.user)
    if not can_view_policy:
        logger.warning("PermissionDenied to user %s for path %s", username,
                       request.path)
        raise PermissionDenied

    context = {'content_title': CORE_STRINGS.DASHBOARD_POLICY_TITLE}
    policy = get_object_or_404(PaymentPolicy, policy_uuid=policy_uuid)
    template_name = "payment/policy_detail.html"
    page_title = "Policy Details - " + settings.SITE_NAME
    context['page_title'] = page_title
    context['policy'] = policy
    context.update(get_view_permissions(request.user))
    return render(request, template_name, context)