From df75fbaa1b9e6f1e590b14f5775658e49f77671c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Tue, 26 Jan 2021 15:36:23 +0100 Subject: [PATCH] Add support for circles with MUCs --- snikket_web/prosodyclient.py | 4 ++ snikket_web/templates/admin_edit_circle.html | 17 +++++++- snikket_web/translations/messages.pot | 43 ++++++++++++-------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/snikket_web/prosodyclient.py b/snikket_web/prosodyclient.py index 2c76838..fbcccc6 100644 --- a/snikket_web/prosodyclient.py +++ b/snikket_web/prosodyclient.py @@ -100,6 +100,7 @@ class AdminInviteInfo: class AdminGroupInfo: id_: str name: str + muc_jid: typing.Optional[str] members: typing.Collection[str] @classmethod @@ -110,6 +111,7 @@ class AdminGroupInfo: return cls( id_=data["id"], name=data["name"], + muc_jid=data.get("muc_jid") or None, members=data.get("members", []), ) @@ -944,10 +946,12 @@ class ProsodyClient: self, name: str, *, + create_muc: bool = True, session: aiohttp.ClientSession, ) -> AdminGroupInfo: payload = { "name": name, + "create_muc": create_muc, } async with session.post( diff --git a/snikket_web/templates/admin_edit_circle.html b/snikket_web/templates/admin_edit_circle.html index 93e0d7f..c6dac22 100644 --- a/snikket_web/templates/admin_edit_circle.html +++ b/snikket_web/templates/admin_edit_circle.html @@ -1,5 +1,9 @@ {% extends "admin_app.html" %} -{% from "library.j2" import form_button, standard_button, value_or_hint, custom_form_button %} +{% from "library.j2" import form_button, standard_button, value_or_hint, custom_form_button, clipboard_button %} +{% block head_lead %} +{{ super() }} +{% include "copy-snippet.html" %} +{% endblock %} {% block content %}

{% trans circle_name=(target_circle | circle_name) %}Edit circle {{ circle_name }}{% endtrans %}

@@ -10,6 +14,17 @@ {{ form.name.label }} {{ form.name }} +
+ {%- if target_circle.muc_jid -%} + + + {%- call clipboard_button(target_circle.muc_jid, show_label=True) -%} + {%- trans -%}Copy address{%- endtrans -%} + {%- endcall -%} + {%- else -%} +

{% trans %}This circle has no group chat associated.{% endtrans %}

+ {%- endif -%} +

{%- call standard_button("back", url_for(".circles"), class="secondary") -%} {% trans %}Back{% endtrans %} diff --git a/snikket_web/translations/messages.pot b/snikket_web/translations/messages.pot index 18be529..2c4d0fd 100644 --- a/snikket_web/translations/messages.pot +++ b/snikket_web/translations/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-01-26 16:11+0100\n" +"POT-Creation-Date: 2021-01-26 16:12+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -381,7 +381,7 @@ msgid "" msgstr "" #: snikket_web/templates/admin_delete_user.html:23 -#: snikket_web/templates/admin_edit_circle.html:15 +#: snikket_web/templates/admin_edit_circle.html:30 #: snikket_web/templates/admin_edit_invite.html:45 #: snikket_web/templates/admin_reset_user_password.html:25 #: snikket_web/templates/user_logout.html:13 @@ -390,49 +390,62 @@ msgstr "" msgid "Back" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:4 +#: snikket_web/templates/admin_edit_circle.html:8 #, python-format msgid "Edit circle %(circle_name)s" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:8 +#: snikket_web/templates/admin_edit_circle.html:12 msgid "Circle information" msgstr "" #: snikket_web/templates/admin_edit_circle.html:19 -msgid "Delete circle" +msgid "Group chat address" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:20 -msgid "Deleting a circle does not delete any users in the circle." +#: snikket_web/templates/admin_edit_circle.html:22 +#: snikket_web/templates/invite_success.html:15 +msgid "Copy address" msgstr "" #: snikket_web/templates/admin_edit_circle.html:25 -msgid "Circle members" +msgid "This circle has no group chat associated." +msgstr "" + +#: snikket_web/templates/admin_edit_circle.html:34 +msgid "Delete circle" +msgstr "" + +#: snikket_web/templates/admin_edit_circle.html:35 +msgid "Deleting a circle does not delete any users in the circle." msgstr "" #: snikket_web/templates/admin_edit_circle.html:40 +msgid "Circle members" +msgstr "" + +#: snikket_web/templates/admin_edit_circle.html:55 #, python-format msgid "Remove user %(username)s from circle" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:48 +#: snikket_web/templates/admin_edit_circle.html:63 msgid "This circle currently has no members." msgstr "" -#: snikket_web/templates/admin_edit_circle.html:50 +#: snikket_web/templates/admin_edit_circle.html:65 msgid "Invite more members" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:53 +#: snikket_web/templates/admin_edit_circle.html:68 msgid "Add existing user" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:64 +#: snikket_web/templates/admin_edit_circle.html:79 msgid "No users left" msgstr "" -#: snikket_web/templates/admin_edit_circle.html:65 +#: snikket_web/templates/admin_edit_circle.html:80 msgid "All users on this service are already in this circle." msgstr "" @@ -734,10 +747,6 @@ msgstr "" msgid "Congratulations! You successfully registered on %(site_name)s as %(jid)s." msgstr "" -#: snikket_web/templates/invite_success.html:15 -msgid "Copy address" -msgstr "" - #: snikket_web/templates/invite_success.html:17 msgid "" "You can not set up your legacy XMPP client with the above address and the"