← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~andrey-fedoseev/launchpad:fix-field-description-re-linked-urls into launchpad:master

 

Andrey Fedoseev has proposed merging ~andrey-fedoseev/launchpad:fix-field-description-re-linked-urls into launchpad:master.

Commit message:
Set a person's `description` field hint dynamically

The hint text for a person's `description` field should
should change depending on whether the URLs in the
description are linked, actually (this depends on person's karma)

We should either include or exclude the "URLs are linked"
part of the text.

LP: #1225710

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1225710 in Launchpad itself: "URLs in the personal details description are not linked"
  https://bugs.launchpad.net/launchpad/+bug/1225710

For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/422814

URLs in person's description text are converted to links only if the person has karma (this is to prevent spam)

The hint for the description field in person's edit form should either include or exclude the "URLs are linked" text, depending whether the URL are actually linked for that person.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~andrey-fedoseev/launchpad:fix-field-description-re-linked-urls into launchpad:master.
diff --git a/lib/lp/registry/browser/person.py b/lib/lp/registry/browser/person.py
index c53195c..13b0933 100644
--- a/lib/lp/registry/browser/person.py
+++ b/lib/lp/registry/browser/person.py
@@ -2640,6 +2640,14 @@ class PersonEditView(PersonRenameFormMixin, BasePersonEditView):
     # account with full knowledge of the consequences.
     i_know_this_is_an_openid_security_issue_input = None
 
+    def setUpWidgets(self):
+        super().setUpWidgets()
+        linkify_text = not self.context.is_probationary
+        if not linkify_text:
+            self.widgets["description"].hint = _(
+                "Details about interests and goals. Use plain text, "
+                "paragraphs are preserved.")
+
     def validate(self, data):
         """If the name changed, warn the user about the implications."""
         new_name = data.get('name')
diff --git a/lib/lp/registry/browser/tests/test_person.py b/lib/lp/registry/browser/tests/test_person.py
index ad6bd61..30a060a 100644
--- a/lib/lp/registry/browser/tests/test_person.py
+++ b/lib/lp/registry/browser/tests/test_person.py
@@ -1053,6 +1053,21 @@ class TestPersonEditView(TestPersonRenameFormMixin, TestCaseWithFactory):
             '%s/+editemails/+login?reauth=1' % canonical_url(self.person))
         self.assertEqual(expected_url, response.getHeader('location'))
 
+    def test_description_hint_depends_on_probationary_status(self):
+        """
+        The hint message for for the 'Description' field should change
+        depending on the `probationary` status of the person. We don't
+        linkify the URLs in the description for people without karma, this
+        should be reflected in the hint text.
+        """
+        person_with_karma = self.factory.makePerson(karma=10)
+        view = create_initialized_view(person_with_karma, "+edit")
+        self.assertIn("URLs are linked", view.widgets["description"].hint)
+
+        person_without_karma = self.factory.makePerson(karma=0)
+        view = create_initialized_view(person_without_karma, "+edit")
+        self.assertNotIn("URLs are linked", view.widgets["description"].hint)
+
 
 class TestPersonParticipationView(TestCaseWithFactory):