def add_attachment(filename, b64content, **kwargs): """ .. function:: XML-RPC User.add_attachment(filename, b64content) Attach a file under the currently logged-in user! This method is meant to be used by SimpleMDE combined with post_save processing for various models like TestPlan and TestCase. While files uploaded by this method will be attached and available (if you know their URL), there is no UI to see all of the files uploaded by a certain user or manage them! :param filename: File name of attachment, e.g. 'logs.txt' :type filename: str :param b64content: Base64 encoded content :type b64content: str :param kwargs: Dict providing access to the current request, protocol entry point name and handler instance from the rpc method :return: Information about the attachment :rtype: dict """ user = kwargs.get(REQUEST_KEY).user utils.add_attachment(user.pk, settings.AUTH_USER_MODEL, kwargs.get(REQUEST_KEY).user, filename, b64content) # take the last attachment for this user and return information about it attachment = Attachment.objects.attachments_for_object(user).order_by( 'created').last() return { 'url': attachment.attachment_file.url, 'filename': attachment.filename, }
def add_attachment(case_id, filename, b64content, **kwargs): """ .. function:: XML-RPC TestCase.add_attachment(case_id, filename, b64content) Add attachment to the given TestCase. :param case_id: PK of TestCase :type case_id: int :param filename: File name of attachment, e.g. 'logs.txt' :type filename: str :param b64content: Base64 encoded content :type b64content: str :return: None """ utils.add_attachment(case_id, 'testcases.TestCase', kwargs.get(REQUEST_KEY).user, filename, b64content)
def add_attachment(case_id, filename, b64content, **kwargs): """ .. function:: RPC TestCase.add_attachment(case_id, filename, b64content) Add attachment to the given TestCase. :param case_id: PK of TestCase :type case_id: int :param filename: File name of attachment, e.g. 'logs.txt' :type filename: str :param b64content: Base64 encoded content :type b64content: str :param kwargs: Dict providing access to the current request, protocol entry point name and handler instance from the rpc method """ utils.add_attachment(case_id, 'testcases.TestCase', kwargs.get(REQUEST_KEY).user, filename, b64content)