コード例 #1
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def getAllProtocolInfo(datasetID):
    '''
    Retrieve all info of a protocol
    :param datasetID: ID of the dataset (protocol) to get all information from
    :return: dictionary with all information of the dataset
    '''

    coreData = BasicDataset.objects.get(id=datasetID)
    formCore = BasicDatasetForm(instance=coreData, auto_id='id_basic_%s')

    # Load in data
    existingExperimentInfoDict = functions.getExperimentInfoDict(datasetID)
    existingPartnersList = functions.getPartnersList(datasetID)
    existingReqsList = functions.getListSteps(datasetID, DataReq)
    existingExpStepsList = functions.getListSteps(datasetID, ExpStep)
    existingReportingsList = functions.getListSteps(datasetID, Reporting)

    formPartner = PartnerForm(auto_id='id_partner_%s')
    formDataReq = DataReqForm(auto_id='id_req_%s')
    formExpStep = ExpStepForm(auto_id='id_exp_%s')
    formReporting = ReportingForm(auto_id='id_reporting_%s')

    formList = [
        ['Basic', formCore],
        ['Partner', formPartner],
        ['DataReq', formDataReq],
        ['ExpStep', formExpStep],
        ['Reporting', formReporting],
    ]

    context = {}

    context.update({
        'edit':
        True,
        'dataset_id':
        datasetID,
        'existingExperimentInfoJSON':
        json.dumps(existingExperimentInfoDict),
        'existingPartnersJSON':
        json.dumps(existingPartnersList),
        'existingReqsJSON':
        json.dumps(existingReqsList),
        'existingExpStepsJSON':
        json.dumps(existingExpStepsList),
        'existingReportingsJSON':
        json.dumps(existingReportingsList),
        'forms_list':
        formList
    })

    return context
コード例 #2
0
def decreaseReq(request):
    postDict = request.POST.dict()
    functions.decreaseTaskNr(postDict['datasetID'], postDict['reqID'], DataReq)

    # send back the new Reqs model as a list to use client side
    existingReqsList = functions.getListSteps(postDict['datasetID'], DataReq)
    return JsonResponse({'existingListJSON': json.dumps(existingReqsList)})
コード例 #3
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def decreaseReporting(request):
    postDict = request.POST.dict()
    functions.decreaseTaskNr(postDict['datasetID'], postDict['reportingID'], Reporting)

    # send back the new Reportings model as a list to use client side
    existingReportingsList = functions.getListSteps(postDict['datasetID'], Reporting)
    return JsonResponse({'existingListJSON': json.dumps(existingReportingsList)})
コード例 #4
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def decreaseExpStep(request):
    postDict = request.POST.dict()
    functions.decreaseTaskNr(postDict['datasetID'], postDict['expStepID'], ExpStep)

    # send back the new ExpSteps model as a list to use client side
    existingExpStepsList = functions.getListSteps(postDict['datasetID'], ExpStep)
    return JsonResponse({'existingListJSON': json.dumps(existingExpStepsList)})
コード例 #5
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def increaseReq(request):
    postDict = request.POST.dict()
    functions.increaseTaskNr(postDict['datasetID'], postDict['reqID'], DataReq)

    # send back the new Reqs model as a list to use client side
    existingReqsList = functions.getListSteps(postDict['datasetID'], DataReq)
    return JsonResponse({'existingListJSON': json.dumps(existingReqsList)})
コード例 #6
0
def decreaseExpStep(request):
    postDict = request.POST.dict()
    functions.decreaseTaskNr(postDict['datasetID'], postDict['expStepID'],
                             ExpStep)

    # send back the new ExpSteps model as a list to use client side
    existingExpStepsList = functions.getListSteps(postDict['datasetID'],
                                                  ExpStep)
    return JsonResponse({'existingListJSON': json.dumps(existingExpStepsList)})
コード例 #7
0
def updateReq(request):
    postDict = request.POST.dict()

    # update the Request model based on the post information from the client
    functions.createStepModelFromClient(postDict, True, DataReq)

    # send back the new Request model as a list to use client side
    existingReqsList = functions.getListSteps(postDict['datasetID'], DataReq)
    return JsonResponse({'existingListJSON': json.dumps(existingReqsList)})
コード例 #8
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def deleteReporting(request):
    postDict = request.POST.dict()

    functions.updateTaskNrs(postDict['datasetID'], postDict['stepID'], Reporting)
    Reporting.objects.filter(id=postDict['stepID']).delete()

    # send back the new Reportings model as a list to use client side
    existingReportingsList = functions.getListSteps(postDict['datasetID'], Reporting)
    return JsonResponse({'existingListJSON': json.dumps(existingReportingsList)})
コード例 #9
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def updateReporting(request):
    postDict = request.POST.dict()

    # update the Reporting model based on the post information from the client
    functions.createStepModelFromClient(postDict, True, Reporting)

    # send back the new Reportings model as a list to use client side
    existingReportingsList = functions.getListSteps(postDict['datasetID'], Reporting)
    return JsonResponse({'existingListJSON': json.dumps(existingReportingsList)})
コード例 #10
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def addExpStep(request):
    postDict = request.POST.dict()

    # add a new ExpStep model based on the post information from the client
    functions.createStepModelFromClient(postDict, False, ExpStep)

    # send back the new ExpSteps model as a list to use client side
    existingExpStepsList = functions.getListSteps(postDict['datasetID'], ExpStep)
    return JsonResponse({'existingListJSON': json.dumps(existingExpStepsList)})
コード例 #11
0
ファイル: views.py プロジェクト: beekhuiz/ProtocolTool
def getAllProtocolInfo(datasetID):
    '''
    Retrieve all info of a protocol
    :param datasetID: ID of the dataset (protocol) to get all information from
    :return: dictionary with all information of the dataset
    '''

    coreData = BasicDataset.objects.get(id=datasetID)
    formCore = BasicDatasetForm(instance=coreData, auto_id='id_basic_%s')

    # Load in data
    existingExperimentInfoDict = functions.getExperimentInfoDict(datasetID)
    existingPartnersList = functions.getPartnersList(datasetID)
    existingReqsList = functions.getListSteps(datasetID, DataReq)
    existingExpStepsList = functions.getListSteps(datasetID, ExpStep)
    existingReportingsList = functions.getListSteps(datasetID, Reporting)

    formPartner = PartnerForm(auto_id='id_partner_%s')
    formDataReq = DataReqForm(auto_id='id_req_%s')
    formExpStep = ExpStepForm(auto_id='id_exp_%s')
    formReporting = ReportingForm(auto_id='id_reporting_%s')

    formList = [
        ['Basic', formCore],
        ['Partner', formPartner],
        ['DataReq', formDataReq],
        ['ExpStep', formExpStep],
        ['Reporting', formReporting],
    ]

    context = {}

    context.update({
        'edit': True,
        'dataset_id': datasetID,
        'existingExperimentInfoJSON': json.dumps(existingExperimentInfoDict),
        'existingPartnersJSON': json.dumps(existingPartnersList),
        'existingReqsJSON': json.dumps(existingReqsList),
        'existingExpStepsJSON': json.dumps(existingExpStepsList),
        'existingReportingsJSON': json.dumps(existingReportingsList),
        'forms_list': formList
    })

    return context
コード例 #12
0
def increaseReporting(request):
    postDict = request.POST.dict()
    functions.increaseTaskNr(postDict['datasetID'], postDict['reportingID'],
                             Reporting)

    # send back the new Reportings model as a list to use client side
    existingReportingsList = functions.getListSteps(postDict['datasetID'],
                                                    Reporting)
    return JsonResponse(
        {'existingListJSON': json.dumps(existingReportingsList)})
コード例 #13
0
def addExpStep(request):
    postDict = request.POST.dict()

    # add a new ExpStep model based on the post information from the client
    functions.createStepModelFromClient(postDict, False, ExpStep)

    # send back the new ExpSteps model as a list to use client side
    existingExpStepsList = functions.getListSteps(postDict['datasetID'],
                                                  ExpStep)
    return JsonResponse({'existingListJSON': json.dumps(existingExpStepsList)})
コード例 #14
0
def deleteReq(request):
    postDict = request.POST.dict()

    functions.updateTaskNrs(postDict['datasetID'], postDict['stepID'], DataReq)

    DataReq.objects.filter(id=postDict['stepID']).delete()

    # send back the new Request model as a list to use client side
    existingReqsList = functions.getListSteps(postDict['datasetID'], DataReq)
    return JsonResponse({'existingListJSON': json.dumps(existingReqsList)})