Exemple #1
0
def creatUSSMNoPrev(hasChildNode, id, SSMModel):
    newChild = UserSecuritySelectionModel()
    newChild.hasChildNode = hasChildNode
    newChild.tgtWeight = 0.0
    newChild.currWeight = 0.0

    classification = ClassificationNames.objects.get(id=id)

    newChild.classificationName = classification
    newChild.ext_model_id = classification.id
    newChild.SSM = SecuritySelectionModels.objects.get(id=SSMModel)

    newChild.isSSMNameNode = False

    return newChild
Exemple #2
0
def UpdateSSM(topNode, SSMModel):
    if isinstance(topNode, list) == True:
        topNode = topNode.pop()

        try:
            # Get the rootNode in the datasource
            childOfRootNodes = UserSecuritySelectionModel.objects.get(ext_model_id=topNode['ext_model_id'])

            if childOfRootNodes.is_root():
                tempNode = childOfRootNodes.get_root()
                previousNode=childOfRootNodes

            if topNode['child']:

                if 'ext_model_id' in topNode:
                    previousNode = get(topNode['ext_model_id'], SSMModel)

                if 'child' in topNode:
                    for eachChildinTopNode in topNode['child']:
                        # if there is a node that is added but doesn't have an ext_model_id handle differently


                        if 'ext_model_id' in eachChildinTopNode:
                            ParentOfPreviousNode = UserSecuritySelectionModel.objects.get(
                                ext_model_id=eachChildinTopNode['ext_model_id'], SSM_id=SSMModel)
                        else:
                            # if you have an existing node => and an added Node we need to handle because this code moves on doesn't handle the
                            # next node
                            # ParentofPreviousNode should already be defined

                            ParentOfPreviousNode = tempNode  # Assumes that there is no ParentOfPreviousNode so this must be the root node
                            classification = ClassificationNames.objects.get(
                                classificationName=eachChildinTopNode['classificationName'])
                            newNodeCreated = UserSecuritySelectionModel.create(False,
                                                                               SecuritySelectionModels.objects.get(
                                                                                   id=SSMModel), classification, 0, 0,
                                                                               False, classification.id)

                            tempNode.add_child(instance=newNodeCreated)  # tempNode is typically the root

                        # check to see if it is an actual child, if so and the hasChildNode is false set to True
                        allChildrenOfParentPreviousNode = returnChild(ParentOfPreviousNode, eachChildinTopNode, SSMModel)


        except MultipleObjectsReturned:
            raise Http404("More than one Security Selection Model was returned. Is there only one?")
Exemple #3
0
def createUserSecuritySelectionModel(childOfPreviousNode, SSMModel):

    if isinstance(childOfPreviousNode, list)==True:
        childOfPreviousNode = childOfPreviousNode.pop()

        newChild = UserSecuritySelectionModel()

        newChild.hasChildNode = childOfPreviousNode['hasChildNode']

        newChild.tgtWeight = 0.0
        newChild.currWeight = 0.0

        classification = ClassificationNames.objects.get(classificationName=childOfPreviousNode['classificationName'])

        newChild.classificationName = classification
        newChild.ext_model_id = classification.id
        newChild.SSM = SecuritySelectionModels.objects.get(id=SSMModel)

        newChild.isSSMNameNode = False

    return newChild
Exemple #4
0
from equity.models import SecuritySelectionModels, UserSecuritySelectionModel, ClassificationNames
Exemple #5
0
from django.http import HttpResponse, Http404, JsonResponse