def generateParticipatingSessionsGridsData(self, sessionObj, iteration_, responseGridRelation):
        """ This function will generate the data that is needed for the participatingSessionsContentGrids.html template
        returns a dictionary that MAY contain the following keys:  previousResponseGrid, sessionGridTable, currentResponseGridTable
        """
        data = {}
        currentResponseGridRelation = responseGridRelation.filter(iteration=iteration_)

        # a session grid must always be present, if something goes wrong here the calling function should deal with it
        data["sessionGridTable"] = generateGridTable(sessionObj.sessiongrid_set.all()[iteration_].grid)

        # check to see if a previous response grid should be displayed or not
        if iteration_ >= 2 and iteration_ > 1:
            previousResponseGridRelation = responseGridRelation.filter(iteration=iteration_ - 1)
            if len(previousResponseGridRelation) >= 1:
                previousResponseGrid = previousResponseGridRelation[0].grid
                if previousResponseGrid is not None and sessionObj.state.is_equal_to_grid_state(previousResponseGrid):
                    # generate the data for the previous response grid
                    data["previousResponseGrid"] = generateGridTable(previousResponseGridRelation[0].grid)

        # generate response grid data
        # check to see if the user has already send a response grid
        if len(currentResponseGridRelation) >= 1:
            # if he has sent an response generate the data for the grid
            data["currentResponseGridTable"] = generateGridTable(currentResponseGridRelation[0].grid)

        return data
Пример #2
0
def getCreateMyGridPage(request):
    if not request.user.is_authenticated():
        return redirect_to(request, '/auth/login/')
    try:
        tableOnly= False
        if request.REQUEST.has_key('tableOnly'):
            if request.REQUEST['tableOnly'] == 'true':
                tableOnly= True
    
        gridTableTemplate= GridTableData(generateGridTable(None))
        gridTableTemplate.changeRatingsWeights= True
        gridTableTemplate.changeCornAlt= True
        gridTableTemplate.tableId= randomStringGenerator()
             
        context= None 
        #RequestContext(request, {'data': gridTableTemplate })
        if tableOnly:
            template= loader.get_template('gridMng/createMyGridBase.html')
            templateData= CreateMyGridBaseData(gridTableTemplate)
            context= RequestContext(request, {'data': templateData })
            htmlData= template.render(context)
            return HttpResponse(createXmlSuccessResponse(htmlData), content_type='application/xml')
        else:
            templateData= CreateMyGridData(CreateMyGridBaseData(gridTableTemplate))
            context= RequestContext(request, {'data': templateData })
            return render(request, 'gridMng/createMyGrid.html', context_instance=context)

    except:
        #do nothing
        print "Exception in user code:"
        print '-'*60
        traceback.print_exc(file=sys.stdout)
        print '-'*60
        return HttpResponse(createXmlErrorResponse('unknown error'), content_type='application/xml')
Пример #3
0
    def __init__(self, grid=None):
        table_data = generateGridTable(grid)
        super(WritableGridTableData, self).__init__(tableData=table_data)

        if grid is not None:
            self.usid = grid.usid

        self.changeCornAlt = True
        self.checkForTableIsSave = True
        self.showRatingWhileFalseChangeRatingsWeights = True
        self.changeRatingsWeights = True
Пример #4
0
    def __init__(self, session=None):
        if session is not None:
            self.session = session
            sessionGrid = session.get_session_grid()
            grid_template_data = GridTableData(generateGridTable(sessionGrid))
            grid_template_data.showRatingWhileFalseChangeRatingsWeights = session.state.name != SessionState.CHECK
            grid_template_data.tableId = generateRandomString()
            grid_template_data.usid = sessionGrid.usid
            self.tableData = grid_template_data
            self.participantTableData = ParticipantsData(session=session)
            self.iterations_with_results = session.get_iterations_with_results()

            if session.state.name == SessionState.CHECK:
                self.showRequestButtons = True
                self.showCloseSessionButton = True
                self.saveGridSession = True
                grid_template_data.changeRatingsWeights = True
                grid_template_data.changeCornAlt = True
                grid_template_data.checkForTableIsSave = True
Пример #5
0
def ajaxGetGrid(request):
    if not request.user.is_authenticated():
        return redirect_to(request, '/auth/login/')
    user1= request.user
    
    #####view mode values########################################################################
    # all: show the concerns/alternatives and ratings/weights                                   #
    # ac: show only alternatives and concerns (only works with write mode read)                 #
    #############################################################################################
    
    #####write mode values#######################################
    # read: can only see the values                             #
    # write: can see and change the values                      #
    #############################################################
    
    #####check table values#######################################
    # true: will call the javascript function isTableSaved()     #
    # false: will not call the javascript function isTableSaved()#
    ##############################################################
    
    checkForTableIsSave= False
    changeRatingsWeights= False
    changeCornAlt= False
    showRatingWhileFalseChangeRatingsWeights= True
    error= None;
    
    #validate the options
    gridUSID = None
    viewMode = None
    writeMode = None
    try:
        gridUSID= request.REQUEST['gridUSID']
        viewMode= request.REQUEST['viewMode']
        writeMode= request.REQUEST['writeMode']
    except KeyError:
        error = 'Invalid arguments.'
    
    #variable check
    try:
        if not gridUSID:
            error= 'name of the grid was not specified'
        if not viewMode:
            viewMode= 'all'
        if not writeMode:
            writeMode= 'write'
            
        if writeMode == 'write':
            changeCornAlt= True
            changeRatingsWeights= True
            if viewMode == 'ac':
                showRatingWhileFalseChangeRatingsWeights= False
        
        if request.REQUEST.has_key('checkTable'):
            if request.REQUEST['checkTable'] == 'true':
                checkForTableIsSave= True
    except:
        print "Exception in user code:"
        print '-'*60
        traceback.print_exc(file=sys.stdout)
        print '-'*60
        error= 'one or more variables were not found'
    
    if not error:
        # create the table for the template
        grids= user1.grid_set
        gridObj= grids.filter(usid= gridUSID) #gridObj is first a list 
        if len(gridObj) > 0:
            gridObj= gridObj[0]
            try:
                templateData= GridTableData(generateGridTable(gridObj))
                templateData.tableId= randomStringGenerator()
                templateData.changeRatingsWeights= changeRatingsWeights
                templateData.changeCornAlt= changeCornAlt
                templateData.showRatingWhileFalseChangeRatingsWeights= showRatingWhileFalseChangeRatingsWeights
                templateData.checkForTableIsSave= checkForTableIsSave
                #dic= __generateGridTable__(gridObj)
                template= loader.get_template('gridMng/gridTable.html')
                context= RequestContext(request, {'data': templateData})
                htmlData= template.render(context)
                return HttpResponse(createXmlSuccessResponse(htmlData), content_type='application/xml')
                #return render_to_response('gridMng/gridTable.html', {'table' : table, 'tableHeader': header, 'hiddenFields': hidden, 'weights':concernWeights, 'showRatings':showRatings, 'readOnly':readOnly, 'checkForTableIsSave':checkForTableIsSave }, context_instance=RequestContext(request))
            except:
                print "Exception in user code:"
                print '-'*60
                traceback.print_exc(file=sys.stdout)
                print '-'*60
                return HttpResponse(createXmlErrorResponse('unknown error'), content_type='application/xml')                
        else:
            return HttpResponse(createXmlErrorResponse('Grid was not found'), content_type='application/xml')
    else:
        return HttpResponse(createXmlErrorResponse(error), content_type='application/xml')