mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Earlier I removed some flexibility from XMPP/Owncloud config forms to get things working. Restoring code that will make it easier to add new parameters in the future.
This commit is contained in:
parent
6c15728426
commit
ea0f5b8102
@ -50,21 +50,24 @@ class configure(FormPlugin, PagePlugin):
|
|||||||
form.submit(_("Update setup"))
|
form.submit(_("Update setup"))
|
||||||
return form.render()
|
return form.render()
|
||||||
|
|
||||||
def process_form(self, owncloud_enable=None, **kwargs):
|
def process_form(self, **kwargs):
|
||||||
msg = Message()
|
checkedinfo = {
|
||||||
|
'enable' : False,
|
||||||
|
}
|
||||||
|
|
||||||
if owncloud_enable == u'on':
|
opts = []
|
||||||
output, error = privilegedaction_run("owncloud-setup", "enable")
|
for k in kwargs.keys():
|
||||||
if error:
|
if 'on' == kwargs[k]:
|
||||||
raise Exception("something is wrong: " + error)
|
shortk = k.split("owncloud_").pop()
|
||||||
msg.add = _("Enabled Owncloud.")
|
checkedinfo[shortk] = True
|
||||||
else:
|
|
||||||
output, error = privilegedaction_run("owncloud-setup", "noenable")
|
|
||||||
if error:
|
|
||||||
raise Exception("something is wrong: " + error)
|
|
||||||
msg.add = _("Disabled Owncloud.")
|
|
||||||
|
|
||||||
cfg.log(msg.text)
|
for key in checkedinfo.keys():
|
||||||
main = self.main(owncloud_enable, msg=msg.text)
|
if checkedinfo[key]:
|
||||||
|
opts.append(key)
|
||||||
|
else:
|
||||||
|
opts.append('no'+key)
|
||||||
|
privilegedaction_run("owncloud-setup", " ".join(opts))
|
||||||
|
|
||||||
|
main = self.main(checkedinfo['enable'])
|
||||||
return self.fill_template(title="Owncloud Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
return self.fill_template(title="Owncloud Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||||
|
|
||||||
|
|||||||
@ -29,41 +29,44 @@ class configure(FormPlugin, PagePlugin):
|
|||||||
sidebar_left = ''
|
sidebar_left = ''
|
||||||
sidebar_right = _("<strong>Configure XMPP Server</strong>")
|
sidebar_right = _("<strong>Configure XMPP Server</strong>")
|
||||||
|
|
||||||
def main(self, inband_enable=False, message=None, *args, **kwargs):
|
def main(self, xmpp_inband_enable=False, message=None, *args, **kwargs):
|
||||||
output, error = privilegedaction_run("xmpp-setup", 'status')
|
output, error = privilegedaction_run("xmpp-setup", 'status')
|
||||||
if error:
|
if error:
|
||||||
raise Exception("something is wrong: " + error)
|
raise Exception("something is wrong: " + error)
|
||||||
if "inband_enable" in output.split():
|
if "inband_enable" in output.split():
|
||||||
inband_enable = True
|
xmpp_inband_enable = True
|
||||||
|
|
||||||
form = Form(title="Configure XMPP Server",
|
form = Form(title="Configure XMPP Server",
|
||||||
action=cfg.server_dir + "/services/xmpp/configure/index",
|
action=cfg.server_dir + "/services/xmpp/configure/index",
|
||||||
name="configure_xmpp_form",
|
name="configure_xmpp_form",
|
||||||
message=message)
|
message=message)
|
||||||
form.checkbox(_("Allow In-Band Registration"), name="inband_enable",
|
form.checkbox(_("Allow In-Band Registration"), name="xmpp_inband_enable",
|
||||||
id="inband_enable", checked=inband_enable)
|
id="xmpp_inband_enable", checked=xmpp_inband_enable)
|
||||||
# hidden field is needed because checkbox doesn't post if not checked
|
# hidden field is needed because checkbox doesn't post if not checked
|
||||||
form.hidden(name="submitted", value="True")
|
form.hidden(name="submitted", value="True")
|
||||||
form.html(_("<p>When enabled, anyone who can reach this server will be allowed to register an account through an XMPP client.</p>"))
|
form.html(_("<p>When enabled, anyone who can reach this server will be allowed to register an account through an XMPP client.</p>"))
|
||||||
form.submit(_("Update setup"))
|
form.submit(_("Update setup"))
|
||||||
return form.render()
|
return form.render()
|
||||||
|
|
||||||
def process_form(self, inband_enable=None, **kwargs):
|
def process_form(self, **kwargs):
|
||||||
msg = Message()
|
checkedinfo = {
|
||||||
|
'inband_enable' : False,
|
||||||
|
}
|
||||||
|
|
||||||
if inband_enable == u'on':
|
opts = []
|
||||||
output, error = privilegedaction_run("xmpp-setup", "inband_enable")
|
for k in kwargs.keys():
|
||||||
if error:
|
if 'on' == kwargs[k]:
|
||||||
raise Exception("something is wrong: " + error)
|
shortk = k.split("xmpp_").pop()
|
||||||
msg.add = _("Enabled in-band registration.")
|
checkedinfo[shortk] = True
|
||||||
else:
|
|
||||||
output, error = privilegedaction_run("xmpp-setup", "noinband_enable")
|
|
||||||
if error:
|
|
||||||
raise Exception("something is wrong: " + error)
|
|
||||||
msg.add = _("Disabled in-band registration.")
|
|
||||||
|
|
||||||
cfg.log(msg.text)
|
for key in checkedinfo.keys():
|
||||||
main = self.main(inband_enable, msg=msg.text)
|
if checkedinfo[key]:
|
||||||
|
opts.append(key)
|
||||||
|
else:
|
||||||
|
opts.append('no'+key)
|
||||||
|
privilegedaction_run("xmpp-setup", " ".join(opts))
|
||||||
|
|
||||||
|
main = self.main(checkedinfo['inband_enable'])
|
||||||
return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
return self.fill_template(title="XMPP Server Configuration", main=main, sidebar_left=self.sidebar_left, sidebar_right=self.sidebar_right)
|
||||||
|
|
||||||
class register(FormPlugin, PagePlugin):
|
class register(FormPlugin, PagePlugin):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user