diff libervia/pages/_browser/invitation.py @ 1509:106bae41f5c8

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:11 +0200
parents 5a132b85e1ac
children 5ea06e8b06ed
line wrap: on
line diff
--- a/libervia/pages/_browser/invitation.py	Fri Apr 07 15:20:40 2023 +0200
+++ b/libervia/pages/_browser/invitation.py	Sat Apr 08 13:44:11 2023 +0200
@@ -1,11 +1,11 @@
 from browser import document, window, timer
-from bridge import Bridge
+from bridge import bridge
 from template import Template
 import dialog
 from cache import cache
 import javascript
 
-bridge = Bridge()
+bridge = bridge()
 # we use JS RegExp because Python's re is really long to import in Brython
 # FIXME: this is a naive JID regex, a more accurate should be used instead
 jid_re = javascript.RegExp.new(r"^\w+@\w+\.\w+")
@@ -78,7 +78,7 @@
             path = self.invitation_data["path"]
             album_name = path.rsplit('/')[-1]
             print(f"inviting {entity_jid}")
-            bridge.FISInvite(
+            bridge.fis_invite(
                 entity_jid,
                 service,
                 "photos",
@@ -98,7 +98,7 @@
             if namespace:
                 extra["namespace"] = namespace
             print(f"inviting {entity_jid}")
-            bridge.psInvite(
+            bridge.ps_invite(
                 entity_jid,
                 service,
                 node,
@@ -241,7 +241,7 @@
             level="success",
         )
 
-    def invitationSimpleCreateCb(self, invitation_data, email, name):
+    def invitation_simple_create_cb(self, invitation_data, email, name):
         invitee_jid = invitation_data['jid']
         self._invite_jid(
             invitee_jid,
@@ -259,12 +259,12 @@
 
     def invite_by_email(self, email, name):
         guest_url_tpl = f'{window.URL.new("/g", document.baseURI).href}/{{uuid}}'
-        bridge.invitationSimpleCreate(
+        bridge.invitation_simple_create(
             email,
             name,
             guest_url_tpl,
             '',
-            callback=lambda data: self.invitationSimpleCreateCb(data, email, name),
+            callback=lambda data: self.invitation_simple_create_cb(data, email, name),
             errback=lambda e: window.alert(f"can't send email invitation: {e}")
         )
 
@@ -306,7 +306,7 @@
 
     ## affiliations
 
-    def _addAffiliationBindings(self, entity_jid, affiliation_elt):
+    def _add_affiliation_bindings(self, entity_jid, affiliation_elt):
         for elt in affiliation_elt.select(".click_to_delete"):
             elt.bind(
                 "click",
@@ -353,7 +353,7 @@
             "identities": cache.identities,
         })
         document['affiliations'] <= affiliation_elt
-        self._addAffiliationBindings(entity_jid, affiliation_elt)
+        self._add_affiliation_bindings(entity_jid, affiliation_elt)
 
     def _on_affiliation_remove_success(self, affiliation_elt, entity_jid):
         affiliation_elt.remove()
@@ -363,7 +363,7 @@
         if self.invitation_type == 'photos':
             path = self.invitation_data["path"]
             service = self.invitation_data["service"]
-            bridge.FISAffiliationsSet(
+            bridge.fis_affiliations_set(
                 service,
                 "",
                 path,
@@ -376,7 +376,7 @@
         elif self.invitation_type == 'pubsub':
             service = self.invitation_data["service"]
             node = self.invitation_data["node"]
-            bridge.psNodeAffiliationsSet(
+            bridge.ps_node_affiliations_set(
                 service,
                 node,
                 {entity_jid: "none"},
@@ -400,13 +400,13 @@
             "identities": cache.identities,
         })
         affiliation_elt.replaceWith(new_affiliation_elt)
-        self._addAffiliationBindings(entity_jid, new_affiliation_elt)
+        self._add_affiliation_bindings(entity_jid, new_affiliation_elt)
 
     def _on_affiliation_set_ok(self, entity_jid, name, affiliation_elt, affiliation):
         if self.invitation_type == 'pubsub':
             service = self.invitation_data["service"]
             node = self.invitation_data["node"]
-            bridge.psNodeAffiliationsSet(
+            bridge.ps_node_affiliations_set(
                 service,
                 node,
                 {entity_jid: affiliation},