def sample12(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') fileGuId = request.POST.get('fileId') # Checking required parameters if IsNotNull(clientId) == False or IsNotNull( privateKey) == False or IsNotNull(fileGuId) == False: return render_to_response('__main__:templates/sample12.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 Annotation object ant = AntApi(apiClient) try: # Make a request to Annotation API using clientId and fileGuId response = ant.ListAnnotations(clientId, fileGuId) except Exception, e: return render_to_response('__main__:templates/sample12.pt', {'error': str(e)})
def sample11(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') inputFile = request.POST.get('file') url = request.POST.get('url') basePath = request.POST.get('server_type') fileId = request.POST.get('fileId') guid = "" iframe = "" annotationType = request.POST.get('annotation_type') # Checking required parameters if IsNotNull(clientId) == False or IsNotNull( privateKey) == False or IsNotNull(annotationType) == False: return render_to_response('__main__:templates/sample11.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 Annotation object ant = AntApi(apiClient) api = StorageApi(apiClient) if basePath == "": basePath = 'https://api.groupdocs.com/v2.0' #Set base path ant.basePath = basePath api.basePath = basePath if url != "": try: # Upload file to current user storage using entere URl to the file upload = api.UploadWeb(clientId, url) guid = upload.result.guid fileId = "" except Exception, e: return render_to_response('__main__:templates/sample11.pt', {'error': str(e)})
def annotation(request): session = request.session signer = GroupDocsRequestSigner(session['private_key']) apiClient = ApiClient(signer) api = AntApi(apiClient) try: response = api.ListAnnotations(session['client_id'], session['guid']) #~ import pdb; pdb.set_trace() if not response.result.annotations: return 'No annotations found.' output = '' for annotation in response.result.annotations: replies = [] if annotation.replies: for reply in annotation.replies: replies.append(reply.userName + ": " + reply.text) output += "Annotation Type: " + str( annotation.type) + " -- Replies: " + str(replies) + "<br/>" except Exception as e: return "Server error: " + str(e) return output
def sample28(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') fileGuId = request.POST.get('fileId') basePath = request.POST.get('server_type') #Check is base path entered if basePath == "": #If base path empty set base path to the dev server basePath = 'https://api.groupdocs.com/v2.0' url = "" message = "" # Checking required parameters if IsNotNull(clientId) == False or IsNotNull( privateKey) == False or IsNotNull(fileGuId) == False: return render_to_response('__main__:templates/sample28.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 Annotation object ant = AntApi(apiClient) ant.basePath = basePath try: # Make a request to Annotation API using clientId and fileGuId response = ant.ListAnnotations(clientId, fileGuId) if response.status == "Ok": if response.result.annotations: i = 0 for annotation in response.result.annotations: try: #Delete annotation by it's guid deleteAnnot = ant.DeleteAnnotation( clientId, response.result.annotations[i].guid) if deleteAnnot.status == "Ok": message = '<span style="color: red">There are no annotations</span>' ### If request was successfull #Generation of iframe URL using $pageImage->result->guid #iframe to prodaction server if basePath == "https://api.groupdocs.com/v2.0": url = 'https://apps.groupdocs.com/document-viewer/embed/' + fileGuId #iframe to dev server elif basePath == "https://dev-api.groupdocs.com/v2.0": url = 'https://dev-apps.groupdocs.com/document-viewer/embed/' + fileGuId #iframe to test server elif basePath == "https://stage-api.groupdocs.com/v2.0": url = 'https://stage-apps.groupdocs.com/document-viewer/embed/' + fileGuId elif basePath == "http://realtime-api.groupdocs.com": url = 'http://realtime-apps.groupdocs.com/document-viewer/embed/' + fileGuId url = signer.signUrl(url) except Exception, e: return render_to_response( '__main__:templates/sample28.pt', {'error': str(e)}) i = i + 1 else: message = '<span style="color: red">There are no annotations in this document</span>' except Exception, e: return render_to_response('__main__:templates/sample28.pt', {'error': str(e)})
# Set last name as entered last name user.lastname = lastName # Set email as entered email user.primary_email = email # user.roles = roles iframe = '' # Creating of new user newUser = mgmt.UpdateAccountUser(clientId, email, user) # Check the result of the request if newUser.status == "Ok": # Create AntApi object ant = AntApi(apiClient) ant.basePath = basePath # Make request to Ant api for set new user as annotation collaborator addCollaborator = ant.SetAnnotationCollaborators(clientId, guid, "2.0", body=[email]) # Make request to Annotation api to receive all collaborators for entered file id getCollaborators = ant.GetAnnotationCollaborators(clientId, guid) #Set reviewers rights for new user setReviewer = ant.SetReviewerRights( clientId, guid, getCollaborators.result.collaborators) # Generating iframe for template