Conditions | 2 |
Total Lines | 18 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
13 | @permissions_required('attachments.delete_attachment') |
||
14 | @rpc_method(name='Attachment.remove_attachment') |
||
15 | def remove_attachment(attachment_id, **kwargs): |
||
16 | """ |
||
17 | .. function:: XML-RPC Attachment.remove_attachment(attachment_id) |
||
18 | |||
19 | Remove the given attachment file. |
||
20 | |||
21 | :param attachment_id: PK of attachment to remove |
||
22 | :type attachment_id: int |
||
23 | :return: None |
||
24 | :raises: Exception if attachment doesn't exist, |
||
25 | InternalError or removal fails |
||
26 | """ |
||
27 | request = kwargs.get(REQUEST_KEY) |
||
28 | response = delete_attachment(request, attachment_id) |
||
29 | if response.status_code == 404: |
||
30 | raise Exception("Removing attachment %d failed" % attachment_id) |
||
31 |