mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-06 11:13:21 +02:00
Fix JS check, revise authentication check
This commit is contained in:
parent
996a6944a3
commit
fc52d98f21
3 changed files with 333 additions and 331 deletions
|
@ -912,9 +912,11 @@ function ScrollToElement(attributeName, attributeValue) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
let domainsWrapper = document.querySelector('.domains-wrapper');
|
||||||
|
|
||||||
|
if (domainsWrapper) {
|
||||||
let currentSortBy = 'id';
|
let currentSortBy = 'id';
|
||||||
let currentOrder = 'asc';
|
let currentOrder = 'asc';
|
||||||
let domainsWrapper = document.querySelector('.domains-wrapper');
|
|
||||||
let noDomainsWrapper = document.querySelector('.no-domains-wrapper');
|
let noDomainsWrapper = document.querySelector('.no-domains-wrapper');
|
||||||
let hasLoaded = false;
|
let hasLoaded = false;
|
||||||
|
|
||||||
|
@ -1086,6 +1088,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
// Load the first page initially
|
// Load the first page initially
|
||||||
loadDomains(1);
|
loadDomains(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1094,9 +1097,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
let domainRequestsWrapper = document.querySelector('.domain-requests-wrapper');
|
||||||
|
|
||||||
|
if (domainRequestsWrapper) {
|
||||||
let currentSortBy = 'id';
|
let currentSortBy = 'id';
|
||||||
let currentOrder = 'asc';
|
let currentOrder = 'asc';
|
||||||
let domainRequestsWrapper = document.querySelector('.domain-requests-wrapper');
|
|
||||||
let noDomainRequestsWrapper = document.querySelector('.no-domain-requests-wrapper');
|
let noDomainRequestsWrapper = document.querySelector('.no-domain-requests-wrapper');
|
||||||
let hasLoaded = false;
|
let hasLoaded = false;
|
||||||
|
|
||||||
|
@ -1275,4 +1280,5 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
// Load the first page initially
|
// Load the first page initially
|
||||||
loadDomainRequests(1);
|
loadDomainRequests(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,15 +2,13 @@ from django.http import JsonResponse
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from registrar.models import DomainRequest
|
from registrar.models import DomainRequest
|
||||||
from django.utils.dateformat import format
|
from django.utils.dateformat import format
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
@login_required
|
||||||
def get_domain_requests_json(request):
|
def get_domain_requests_json(request):
|
||||||
"""Given the current request,
|
"""Given the current request,
|
||||||
get all domain requests that are associated with the request user and exclude the APPROVED ones"""
|
get all domain requests that are associated with the request user and exclude the APPROVED ones"""
|
||||||
|
|
||||||
if not request.user.is_authenticated:
|
|
||||||
return JsonResponse({"error": "User not authenticated"}, status=401)
|
|
||||||
|
|
||||||
domain_requests = DomainRequest.objects.filter(creator=request.user).exclude(
|
domain_requests = DomainRequest.objects.filter(creator=request.user).exclude(
|
||||||
status=DomainRequest.DomainRequestStatus.APPROVED
|
status=DomainRequest.DomainRequestStatus.APPROVED
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from registrar.models import UserDomainRole, Domain
|
from registrar.models import UserDomainRole, Domain
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
@login_required
|
||||||
def get_domains_json(request):
|
def get_domains_json(request):
|
||||||
"""Given the current request,
|
"""Given the current request,
|
||||||
get all domains that are associated with the UserDomainRole object"""
|
get all domains that are associated with the UserDomainRole object"""
|
||||||
|
|
||||||
if not request.user.is_authenticated:
|
|
||||||
return JsonResponse({"error": "User not authenticated"}, status=401)
|
|
||||||
|
|
||||||
user_domain_roles = UserDomainRole.objects.filter(user=request.user)
|
user_domain_roles = UserDomainRole.objects.filter(user=request.user)
|
||||||
domain_ids = user_domain_roles.values_list("domain_id", flat=True)
|
domain_ids = user_domain_roles.values_list("domain_id", flat=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue