Beispiel #1
0
def enableDisableEmailLimits(request):
    try:
        val = request.session['userID']
        try:
            if request.method == 'POST':

                admin = Administrator.objects.get(pk=request.session['userID'])

                if admin.type != 1:
                    dic = {'status': 0, 'error_message': "Only administrator can view this page."}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)


                data = json.loads(request.body)
                operationVal = data['operationVal']
                domainName = data['domainName']

                domain = Domains.objects.get(domain=domainName)

                domainLimits = DomainLimits.objects.get(domain=domain)
                domainLimits.limitStatus = operationVal
                domainLimits.save()

                command = 'cyberpanelCleaner purgeLimitDomain ' + domainName + ' ' + str(operationVal)
                cacheClient.handleCachePurgeRequest(command)


                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)


    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #2
0
def enableDisableEmailLimits(request):
    try:
        userID = request.session['userID']
        currentACL = ACLManager.loadedACL(userID)

        if currentACL['admin'] == 1:
            pass
        else:
            return ACLManager.loadErrorJson()


        try:
            if request.method == 'POST':

                data = json.loads(request.body)
                operationVal = data['operationVal']
                domainName = data['domainName']

                domain = Domains.objects.get(domain=domainName)

                domainLimits = DomainLimits.objects.get(domain=domain)
                domainLimits.limitStatus = operationVal
                domainLimits.save()

                command = 'cyberpanelCleaner purgeLimitDomain ' + domainName + ' ' + str(operationVal)
                cacheClient.handleCachePurgeRequest(command)


                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)


    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #3
0
def changeDomainLimit(request):
    try:
        val = request.session['userID']
        try:
            if request.method == 'POST':

                admin = Administrator.objects.get(pk=request.session['userID'])

                if admin.type != 1:
                    dic = {'status': 0, 'error_message': "Only administrator can view this page."}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)

                data = json.loads(request.body)
                newLimit = data['newLimit']
                domainName = data['domainName']

                domain = Domains.objects.get(domain=domainName)

                domainLimits = DomainLimits.objects.get(domain=domain)
                domainLimits.monthlyLimit = newLimit
                domainLimits.save()

                command = 'cyberpanelCleaner updateDomainLimit ' + domainName + ' ' + str(newLimit)
                cacheClient.handleCachePurgeRequest(command)

                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)


    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #4
0
def changeDomainLimit(request):
    try:
        userID = request.session['userID']
        currentACL = ACLManager.loadedACL(userID)

        if currentACL['admin'] == 1:
            pass
        else:
            return ACLManager.loadErrorJson()
        try:
            if request.method == 'POST':

                data = json.loads(request.body)
                newLimit = data['newLimit']
                domainName = data['domainName']

                domain = Domains.objects.get(domain=domainName)

                domainLimits = DomainLimits.objects.get(domain=domain)
                domainLimits.monthlyLimit = newLimit
                domainLimits.save()

                command = 'cyberpanelCleaner updateDomainLimit ' + domainName + ' ' + str(newLimit)
                cacheClient.handleCachePurgeRequest(command)

                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)


    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #5
0
def enableDisableIndividualEmailLogs(request):
    try:
        val = request.session['userID']
        try:
            if request.method == 'POST':

                admin = Administrator.objects.get(pk=request.session['userID'])

                if admin.type != 1:
                    dic = {'status': 0, 'error_message': "Only administrator can view this page."}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)

                data = json.loads(request.body)
                operationVal = data['operationVal']
                emailAddress = data['emailAddress']

                email = EUsers.objects.get(email=emailAddress)
                emailtLts = EmailLimits.objects.get(email=email)
                emailtLts.emailLogs = operationVal
                emailtLts.save()

                command = 'cyberpanelCleaner purgeLog ' + emailAddress + ' ' + str(operationVal)
                cacheClient.handleCachePurgeRequest(command)

                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)

    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #6
0
def enableDisableIndividualEmailLogs(request):
    try:
        userID = request.session['userID']
        currentACL = ACLManager.loadedACL(userID)

        if currentACL['admin'] == 1:
            pass
        else:
            return ACLManager.loadErrorJson()
        try:
            if request.method == 'POST':

                data = json.loads(request.body)
                operationVal = data['operationVal']
                emailAddress = data['emailAddress']

                email = EUsers.objects.get(email=emailAddress)
                emailtLts = EmailLimits.objects.get(email=email)
                emailtLts.emailLogs = operationVal
                emailtLts.save()

                command = 'cyberpanelCleaner purgeLog ' + emailAddress + ' ' + str(
                    operationVal)
                cacheClient.handleCachePurgeRequest(command)

                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException, msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)

    except KeyError, msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)
Beispiel #7
0
def changeDomainEmailLimitsIndividual(request):
    try:
        val = request.session['userID']
        try:
            if request.method == 'POST':

                admin = Administrator.objects.get(pk=request.session['userID'])

                if admin.type != 1:
                    dic = {'status': 0, 'error_message': "Only administrator can view this page."}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)

                data = json.loads(request.body)
                emailAddress = data['emailAddress']
                monthlyLimit = data['monthlyLimit']
                hourlyLimit = data['hourlyLimit']

                ## Limits Check

                if monthlyLimit < hourlyLimit:
                    dic = {'status': 0, 'error_message': 'Monthly limit should be greater then hourly limit.'}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)

                domainName = emailAddress.split('@')[1]
                dbDomain = Domains.objects.get(domain=domainName)

                domainLimit = DomainLimits.objects.get(domain=dbDomain)

                allEmails = dbDomain.eusers_set.all()
                currentEmailConsumption = 0

                for email in allEmails:
                    emailLTS = EmailLimits.objects.get(email=email)
                    currentEmailConsumption = emailLTS.monthlyLimits + currentEmailConsumption


                allowedLimit = domainLimit.monthlyLimit - currentEmailConsumption

                if monthlyLimit > allowedLimit:
                    dic = {'status': 0, 'error_message': 'You can not set this monthly limit, first increase limits for this domain.'}
                    json_data = json.dumps(dic)
                    return HttpResponse(json_data)

                ## Limits Check End

                email = EUsers.objects.get(email=emailAddress)
                emailLTS = EmailLimits.objects.get(email=email)

                emailLTS.monthlyLimits = monthlyLimit
                emailLTS.hourlyLimit = hourlyLimit

                emailLTS.save()

                command = 'cyberpanelCleaner purgeLimitEmail ' + emailAddress + ' ' + str(monthlyLimit) + ' ' + str(hourlyLimit)
                cacheClient.handleCachePurgeRequest(command)

                dic = {'status': 1, 'error_message': 'None'}
                json_data = json.dumps(dic)
                return HttpResponse(json_data)

        except BaseException,msg:
            dic = {'status': 0, 'error_message': str(msg)}
            json_data = json.dumps(dic)
            return HttpResponse(json_data)


    except KeyError,msg:
        dic = {'statusa': 0, 'error_message': str(msg)}
        json_data = json.dumps(dic)
        return HttpResponse(json_data)