Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master

2024-01-12 Thread Ines Almeida



Diff comments:

> diff --git a/lib/lp/registry/browser/person.py 
> b/lib/lp/registry/browser/person.py
> index 65ae0ba..b247e59 100644
> --- a/lib/lp/registry/browser/person.py
> +++ b/lib/lp/registry/browser/person.py
> @@ -2415,6 +2426,69 @@ class PersonEditIRCNicknamesView(LaunchpadFormView):
>  )
>  
>  
> +class PersonEditMatrixAccountsView(LaunchpadFormView):
> +schema = Interface
> +
> +@property
> +def page_title(self):
> +return smartquote(f"{self.context.displayname}'s Matrix accounts")
> +
> +label = page_title
> +
> +@property
> +def cancel_url(self):
> +return canonical_url(self.context)
> +
> +@property
> +def matrix_accounts(self):

We might change the API to list social_accounts separated by platform. If so, I 
will remove this. If not, then I'll see what better way there is to list these

> +accounts = []
> +for account in self.context.social_accounts:
> +if account.platform == SocialPlatform.MATRIX:
> +accounts.append(account)
> +return accounts
> +
> +@action(_("Save Changes"), name="save")
> +def save(self, action, data):
> +"""Process the matrix accounts form."""
> +form = self.request.form
> +for social_account in self.matrix_accounts:
> +if form.get(f"remove_{social_account.id}"):
> +social_account.destroySelf()
> +
> +else:
> +updated_identity = {
> +field: form.get(f"{field}_{social_account.id}")
> +for field in SocialPlatform.matrix_identity_fields
> +}
> +if not all(updated_identity.values()):
> +self.request.response.addErrorNotification(
> +"Fields cannot be empty."
> +)
> +return
> +
> +social_account.identity = updated_identity
> +
> +new_account_identity = {
> +field_name: form.get(f"new_{field_name}")
> +for field_name in SocialPlatform.matrix_identity_fields
> +}
> +
> +if all(new_account_identity.values()):
> +getUtility(ISocialAccountSet).new(
> +self.context, SocialPlatform.MATRIX, new_account_identity
> +)
> +
> +elif any(new_account_identity.values()):
> +for field_key, field_value in new_account_identity.items():
> +self.__setattr__(f"new_{field_key}", field_value)
> +self.request.response.addErrorNotification(
> +"All fields must be filled."
> +)
> +
> +# Clean the cached social_accounts if form is saved
> +del get_property_cache(self.context).social_accounts
> +
> +
>  class PersonEditJabberIDsView(LaunchpadFormView):
>  schema = IJabberID
>  field_names = ["jabberid"]
> diff --git a/lib/lp/registry/interfaces/socialaccount.py 
> b/lib/lp/registry/interfaces/socialaccount.py
> index 7e910cc..e8c219e 100644
> --- a/lib/lp/registry/interfaces/socialaccount.py
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -40,6 +40,7 @@ class SocialPlatform(DBEnumeratedType):
>  The Social Account will hold Matrix account info.
>  """,
>  )
> +matrix_identity_fields = ["nickname", "network"]

I would rather this was fetched from a simple Matrix class that contains this + 
other information on the specific social platform. This was a quick way of 
having it for now. Thoughts?

>  
>  
>  # XXX pelpsi 2023-12-14 bug=760849: "beta" is a lie to get WADL generation


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458537
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master

2024-01-12 Thread Ines Almeida
Ines Almeida has proposed merging 
~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master with 
~pelpsi/launchpad:social-account-interface-and-implementation as a prerequisite.

Commit message:
ui: Add edit matrix accounts view

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458537

This adds a new view: 
https://launchpad.net/~/+editsocialaccounts-matrix

This view allows users to add, edit or remove their matrix accounts.

(Update to view the matrix accounts in the profile will go in a separate MP)
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master.
diff --git a/lib/lp/registry/browser/configure.zcml b/lib/lp/registry/browser/configure.zcml
index 046db06..eaf8e17 100644
--- a/lib/lp/registry/browser/configure.zcml
+++ b/lib/lp/registry/browser/configure.zcml
@@ -1219,6 +1219,13 @@
 template="../templates/person-editircnicknames.pt"
 />
 
+http://www.w3.org/1999/xhtml";
+  xmlns:tal="http://xml.zope.org/namespaces/tal";
+  xmlns:metal="http://xml.zope.org/namespaces/metal";
+  xmlns:i18n="http://xml.zope.org/namespaces/i18n";
+  metal:use-macro="view/macro:page/main_only"
+  i18n:domain="launchpad"
+>
+
+
+
+
+  
+
+
+
+
+
+  
+
+  Network:
+  Nickname:
+
+
+  
+
+  
+  
+
+  
+
+  
+
+  
+  Remove
+
+  
+
+  
+
+  
+
+  
+
+
+  
+
+  
+
+  
+Example: ubuntu.com
+Example: mark
+  
+
+  
+
+
+
+
+
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master

2024-01-12 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/registry/interfaces/socialaccount.py 
> b/lib/lp/registry/interfaces/socialaccount.py
> index 7e910cc..e8c219e 100644
> --- a/lib/lp/registry/interfaces/socialaccount.py
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -40,6 +40,7 @@ class SocialPlatform(DBEnumeratedType):
>  The Social Account will hold Matrix account info.
>  """,
>  )
> +matrix_identity_fields = ["nickname", "network"]

I think that we can use the following approach for the moment and then replace 
it later, using a proper class for a given Social Platform storing all the 
specific information. I will update my MP too, with matrix_identity_fields.

>  
>  
>  # XXX pelpsi 2023-12-14 bug=760849: "beta" is a lie to get WADL generation


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458537
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp