← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~nigelbabu/launchpad/188187-time-zone-offset into lp:launchpad

 

Nigel Babu has proposed merging lp:~nigelbabu/launchpad/188187-time-zone-offset into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #188187 in Launchpad itself: "Please display offset to UTC with timezone info for profiles"
  https://bugs.launchpad.net/launchpad/+bug/188187

For more details, see:
https://code.launchpad.net/~nigelbabu/launchpad/188187-time-zone-offset/+merge/73168

= Summary =

Display UTC offset along with the timezone.  For example, "Asia/Kolkata" will be displayed as "Asia/Kolkata (UTC+0530)"

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/browser/person.py
  lib/lp/registry/templates/person-portlet-contact-details.pt
-- 
https://code.launchpad.net/~nigelbabu/launchpad/188187-time-zone-offset/+merge/73168
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~nigelbabu/launchpad/188187-time-zone-offset into lp:launchpad.
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2011-06-10 10:50:45 +0000
+++ lib/lp/registry/browser/person.py	2011-08-29 07:12:53 +0000
@@ -3202,6 +3202,14 @@
 
         return False
 
+    @property
+    def show_time_offset(self):
+        """
+        Return the time-zone and offset from UTC
+        """
+        return datetime.now(
+                    pytz.timezone(self.context.time_zone)).strftime("%z")
+
 
 class PersonParticipationView(LaunchpadView):
     """View for the ~person/+participation page."""

=== modified file 'lib/lp/registry/browser/tests/test_person_view.py'
--- lib/lp/registry/browser/tests/test_person_view.py	2011-07-14 07:08:38 +0000
+++ lib/lp/registry/browser/tests/test_person_view.py	2011-08-29 07:12:53 +0000
@@ -8,6 +8,8 @@
 from testtools.matchers import LessThan
 import transaction
 from zope.component import getUtility
+import doctest
+from testtools.matchers import DocTestMatches
 
 from canonical.config import config
 from canonical.launchpad.ftests import (
@@ -19,6 +21,7 @@
 from canonical.launchpad.interfaces.logintoken import ILoginTokenSet
 from canonical.launchpad.webapp.interfaces import ILaunchBag
 from canonical.launchpad.webapp.servers import LaunchpadTestRequest
+from canonical.launchpad.testing.pages import extract_text
 from canonical.testing.layers import (
     DatabaseFunctionalLayer,
     LaunchpadFunctionalLayer,
@@ -80,6 +83,13 @@
         self.assertEqual(1, len(notifications))
         self.assertEqual(message, notifications[0].message)
 
+    def test_display_utcoffset(self):
+        person = self.factory.makePerson(time_zone='Asia/Kolkata')
+        html = create_initialized_view(person, '+portlet-contact-details')()
+        self.assertThat(extract_text(html), DocTestMatches(extract_text(
+            "... Asia/Kolkata (UTC+0530) ..."), doctest.ELLIPSIS
+            | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF))
+
 
 class TestPersonViewKarma(TestCaseWithFactory):
 
@@ -202,7 +212,7 @@
 
         # But if the context person has a second ppa that is public,
         # then anon users will see the section.
-        second_ppa = self.factory.makeArchive(owner=self.owner)
+        self.factory.makeArchive(owner=self.owner)
         person_view = PersonView(self.owner, LaunchpadTestRequest())
         self.failUnless(person_view.should_show_ppa_section)
 
@@ -226,7 +236,7 @@
         self.failIf(person_view.should_show_ppa_section)
 
         # Unless the team also has another ppa which is public.
-        second_ppa = self.factory.makeArchive(owner=self.team)
+        self.factory.makeArchive(owner=self.team)
         person_view = PersonView(self.team, LaunchpadTestRequest())
         self.failUnless(person_view.should_show_ppa_section)
 
@@ -295,7 +305,7 @@
             'field.actions.add_email': 'Add',
             'field.newemail': email_address,
             }
-        view = create_initialized_view(self.person, "+editemails", form=form)
+        create_initialized_view(self.person, "+editemails", form=form)
 
         # If everything worked, there should now be a login token to validate
         # this email address for this user.
@@ -307,7 +317,7 @@
 
     def test_add_email_address_taken(self):
         email_address = self.factory.getUniqueEmailAddress()
-        account = self.factory.makeAccount(
+        self.factory.makeAccount(
             displayname='deadaccount',
             email=email_address,
             status=AccountStatus.NOACCOUNT)
@@ -345,7 +355,7 @@
             'field.subscriptionpolicy-empty-marker': 1,
             }
         person_set = getUtility(IPersonSet)
-        view = create_initialized_view(
+        create_initialized_view(
             person_set, '+newteam', form=form)
         team = person_set.getByName('libertyland')
         self.assertTrue(team is not None)
@@ -353,7 +363,7 @@
 
     def test_validate_email_catches_taken_emails(self):
         email_address = self.factory.getUniqueEmailAddress()
-        account = self.factory.makeAccount(
+        self.factory.makeAccount(
             displayname='libertylandaccount',
             email=email_address,
             status=AccountStatus.NOACCOUNT)
@@ -477,7 +487,7 @@
         # Verify the path of indirect membership.
         a_team = self.factory.makeTeam(name='a')
         b_team = self.factory.makeTeam(name='b', owner=a_team)
-        c_team = self.factory.makeTeam(name='c', owner=b_team)
+        self.factory.makeTeam(name='c', owner=b_team)
         login_person(a_team.teamowner)
         a_team.addMember(self.user, a_team.teamowner)
         transaction.commit()
@@ -525,8 +535,8 @@
                 sourcename=source_name,
                 status=PackagePublishingStatus.PUBLISHED,
                 archive=archive,
-                maintainer = maintainer,
-                creator = self.user,
+                maintainer=maintainer,
+                creator=self.user,
                 distroseries=self.warty)
         login(ANONYMOUS)
 
@@ -621,6 +631,7 @@
         self.assertIn('<a href="%s/+bugs">' % expected_base, html)
         self.assertIn('<a href="%s/+questions">' % expected_base, html)
 
+
 class TestPersonPPAPackagesView(TestCaseWithFactory):
     """Test the maintained packages view."""
 
@@ -884,7 +895,8 @@
         view = create_initialized_view(self.person, self.view_name)
         Store.of(self.subscribed_bug).invalidate()
         with StormStatementRecorder() as recorder:
-            prejoins=[(Person, LeftJoin(Person, BugTask.owner==Person.id))]
+            prejoins = [(Person, LeftJoin(Person,
+                BugTask.owner == Person.id))]
             bugtasks = view.searchUnbatched(prejoins=prejoins)
             [bugtask.owner for bugtask in bugtasks]
         self.assertThat(recorder, HasQueryCount(LessThan(3)))

=== modified file 'lib/lp/registry/templates/person-portlet-contact-details.pt'
--- lib/lp/registry/templates/person-portlet-contact-details.pt	2011-06-02 17:15:39 +0000
+++ lib/lp/registry/templates/person-portlet-contact-details.pt	2011-08-29 07:12:53 +0000
@@ -173,7 +173,9 @@
       <dt>Time zone:
         <a tal:replace="structure overview_menu/editlocation/fmt:icon" />
       </dt>
-      <dd tal:content="context/time_zone">UTC</dd>
+      <dd><tal:offset content="context/time_zone">UTC</tal:offset>
+      (UTC<tal:offset content="view/show_time_offset">+0000</tal:offset>)
+      </dd>
     </dl>
 
     <dl id="karma">