tcms.rpc.utils module

tcms.rpc.utils.add_attachment(obj_id, app_model, user, filename, b64content)[source]

High-level function which performs the attachment process by constructing an HttpRequest object and passing it to attachments.views.add_attachment() as if it came from the browser.

tcms.rpc.utils.distinct_filter(cls, values)[source]
tcms.rpc.utils.distinct_m2m_rows(cls, values, op_type)[source]

By django model field looking up syntax, loop values and check the condition if there is a multi-tables query.

@param cls: table model class @type cls: subclass of django.db.models.Model @param values: fields in where condition. @type values: dict @param op_type: @type op_type: int @return: QuerySet @rtype: django.db.models.query.QuerySet @raises TypeError:

tcms.rpc.utils.encode_multipart(csrf_token, filename, b64content)[source]

Build a multipart/form-data body with generated random boundary suitable for parsing by django.http.request.HttpRequest and the parser classes related to it!


\r\n are expected! Do not change!

tcms.rpc.utils.get_attachments_for(request, obj)[source]
tcms.rpc.utils.request_for_upload(user, filename, b64content)[source]

Return a request object containing all fields necessary for file upload as if it was sent by the browser.