Mercurial > libervia-backend
comparison sat/plugins/plugin_comp_file_sharing_management.py @ 3531:a8259a1f89b2
component file sharing (management): add values of `quota` and `used` size on result form
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 May 2021 15:37:33 +0200 |
parents | 698579bedd6f |
children | 888109774673 |
comparison
equal
deleted
inserted
replaced
3530:fad3b3ffa8fe | 3531:a8259a1f89b2 |
---|---|
1 #!/usr/bin/env python3 | 1 #!/usr/bin/env python3 |
2 | 2 |
3 | 3 # Libervia plugin to manage file sharing component through ad-hoc commands |
4 # SAT plugin to detect language (experimental) | |
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
6 | 5 |
7 # This program is free software: you can redistribute it and/or modify | 6 # This program is free software: you can redistribute it and/or modify |
8 # it under the terms of the GNU Affero General Public License as published by | 7 # it under the terms of the GNU Affero General Public License as published by |
9 # the Free Software Foundation, either version 3 of the License, or | 8 # the Free Software Foundation, either version 3 of the License, or |
17 # You should have received a copy of the GNU Affero General Public License | 16 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 18 |
20 import os.path | 19 import os.path |
21 from functools import partial | 20 from functools import partial |
21 from wokkel import data_form | |
22 from twisted.internet import defer | |
23 from twisted.words.protocols.jabber import jid | |
22 from sat.core.i18n import _, D_ | 24 from sat.core.i18n import _, D_ |
23 from sat.core import exceptions | 25 from sat.core import exceptions |
24 from sat.core.constants import Const as C | 26 from sat.core.constants import Const as C |
25 from sat.core.log import getLogger | 27 from sat.core.log import getLogger |
26 from sat.tools.common import utils | 28 from sat.tools.common import utils |
27 from wokkel import data_form | |
28 from twisted.internet import defer | |
29 from twisted.words.protocols.jabber import jid | |
30 | 29 |
31 log = getLogger(__name__) | 30 log = getLogger(__name__) |
32 | 31 |
33 | 32 |
34 PLUGIN_INFO = { | 33 PLUGIN_INFO = { |
472 try: | 471 try: |
473 size_used = await self.host.memory.fileGetUsedSpace(client, requestor) | 472 size_used = await self.host.memory.fileGetUsedSpace(client, requestor) |
474 except exceptions.PermissionError: | 473 except exceptions.PermissionError: |
475 raise WorkflowError(self._err(_("forbidden"))) | 474 raise WorkflowError(self._err(_("forbidden"))) |
476 status = self._c.STATUS.COMPLETED | 475 status = self._c.STATUS.COMPLETED |
477 payload = None | 476 form = data_form.Form("result") |
477 form.makeFields({"quota": quota, "user": size_used}) | |
478 payload = form.toElement() | |
478 note = ( | 479 note = ( |
479 self._c.NOTE.INFO, | 480 self._c.NOTE.INFO, |
480 _("You are currently using {size_used} on {size_quota}").format( | 481 _("You are currently using {size_used} on {size_quota}").format( |
481 size_used = utils.getHumanSize(size_used), | 482 size_used = utils.getHumanSize(size_used), |
482 size_quota = ( | 483 size_quota = ( |