def sample20(request):

    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    resultFileId = request.POST.get('resultFileId')
    basePath = request.POST.get('server_type')

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(resultFileId) == False:
        return render_to_response('__main__:templates/sample20.pt',
            { 'error' : 'You do not enter all parameters' })

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create ComparisonApi object
    compare = ComparisonApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
    compare.basePath = basePath

    # get changes
    info = compare.GetChanges(clientId, resultFileId)

    # construct table results
    result = ""
    if info.status == "Ok":
        result = "<table class='border'>"
        result += "<tr><td><font color='green'>Change Name</font></td><td><font color='green'>Change</font></td></tr>"
        if info.result.changes is not None:
            for item in info.result.changes:
                for key in item.__dict__:
                    if key != 'swaggerTypes':
                        if type(item.__dict__[key]).__name__ == 'instance':
                            for value in item.__dict__[key].__dict__:
                                if value != "swaggerTypes":
                                    result += "<tr><td>" + value + "</td><td>" + unicode(item.__dict__[key].__dict__[value]) + "</td></tr>"
                        else:
                            result += "<tr><td>" + key + "</td><td>" + unicode(item.__dict__[key]) + "</td></tr>"

                result += "<tr bgcolor='#808080'><td></td><td></td></tr>"
        result += "</table>"

    # If request was successfull - set variables for template
    return render_to_response('__main__:templates/sample20.pt',
        {'userId' : clientId,
         'privateKey' : privateKey,
         'resultFileId' : resultFileId,
         'result' : result},
        request=request)
Exemple #2
0
        for the_file in os.listdir(currentDir + '/../downloads'):
            file_path = os.path.join(currentDir + '/../downloads', the_file)
            try:
                #Delete file from folder
                os.unlink(file_path)

            except Exception, e:
                print e
    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create ComparisonApi object
    compare = ComparisonApi(apiClient)
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    compare.basePath = basePath
    if url != "" or target_url != "":
        if url != "":
            try:
                # Upload file to current user storage using entere URl to the file
                upload = api.UploadWeb(clientId, url)
                sourceFileId = upload.result.guid

            except Exception, e:
                return render_to_response('__main__:templates/sample19.pt',