launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19952
[Merge] lp:~wgrant/launchpad/ageless into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/ageless into lp:launchpad.
Commit message:
Remove unused IAging, inline IHasDateCreated.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/ageless/+merge/285150
Remove unused IAging, inline IHasDateCreated.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/ageless into lp:launchpad.
=== modified file 'lib/lp/app/configure.zcml'
--- lib/lp/app/configure.zcml 2012-04-17 04:28:15 +0000
+++ lib/lp/app/configure.zcml 2016-02-05 06:46:47 +0000
@@ -1,4 +1,4 @@
-<!-- Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+<!-- Copyright 2009-2016 Canonical Ltd. This software is licensed under the
GNU Affero General Public License version 3 (see the file LICENSE).
-->
@@ -36,12 +36,6 @@
provides="lp.app.interfaces.launchpad.ILaunchpadCelebrities">
</utility>
- <!-- Configuration related to datetime classes in Launchpad. -->
- <adapter
- for="lp.app.interfaces.launchpad.IHasDateCreated"
- provides="lp.app.interfaces.launchpad.IAging"
- factory="lp.app.model.cdatetime.AgingAdapter" />
-
<adapter
provides="lp.app.interfaces.launchpad.IPrivacy"
for="Exception"
=== removed file 'lib/lp/app/doc/datehandling.txt'
--- lib/lp/app/doc/datehandling.txt 2016-01-26 15:47:37 +0000
+++ lib/lp/app/doc/datehandling.txt 1970-01-01 00:00:00 +0000
@@ -1,61 +0,0 @@
-Date Handling in Launchpad
-==========================
-
-Time differences
-----------------
-
-It's often useful to know how long ago something was created, or how long ago
-something happened. So, let's demonstrate how this functionality can be
-accessed in Launchpad, using the age of a bug task as an example. First, let's
-pretend we're logged in as Sample Person:
-
- >>> from lp.testing import login
- >>> login("testing@xxxxxxxxxxxxx")
-
-Then let's grab one of their bug tasks to work with:
-
- >>> from zope.component import getUtility
- >>> from lp.bugs.interfaces.bugtask import IBugTaskSet
- >>> bugtaskset = getUtility(IBugTaskSet)
- >>> bt = bugtaskset.get(2)
-
-Then let's create a bunch of sample dates to work with:
-
- >>> from datetime import datetime, timedelta
- >>> import pytz
- >>> right_now = datetime.now(pytz.timezone('UTC'))
- >>> one_minute_ago = right_now - timedelta(minutes = 1)
- >>> four_hours_ago = right_now - timedelta(hours = 4)
- >>> sixteen_days_ago = right_now - timedelta(days = 16)
- >>> six_months_ago = right_now - timedelta(days = 180)
- >>> one_year_ago = right_now - timedelta(days = 365)
-
-An IBugTask extends the interface IHasDateCreated. IHasDateCreated can be
-adapted to IAging:
-
- >>> from lp.app.interfaces.launchpad import IAging
- >>> bt.datecreated = one_minute_ago
- >>> aging_bug = IAging(bt)
-
-IAging provides a method, currentApproximateAge, which returns a human-readable
-approximation of the age of a something.
-
- >>> print aging_bug.currentApproximateAge()
- 1 minute
-
-We're cheating a bit below (swapping in different values for datecreated, which
-you should never do in user code) to demonstrate the various kinds of values
-currentApproximateAge returns.
-
- >>> aging_bug.context.datecreated = four_hours_ago
- >>> print aging_bug.currentApproximateAge()
- 4 hours
- >>> aging_bug.context.datecreated = sixteen_days_ago
- >>> print aging_bug.currentApproximateAge()
- 2 weeks
- >>> aging_bug.context.datecreated = six_months_ago
- >>> print aging_bug.currentApproximateAge()
- 6 months
- >>> aging_bug.context.datecreated = one_year_ago
- >>> print aging_bug.currentApproximateAge()
- 1 year
=== modified file 'lib/lp/app/interfaces/launchpad.py'
--- lib/lp/app/interfaces/launchpad.py 2015-11-26 15:46:38 +0000
+++ lib/lp/app/interfaces/launchpad.py 2016-02-05 06:46:47 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interfaces for the Launchpad application.
@@ -9,8 +9,6 @@
__metaclass__ = type
__all__ = [
- 'IAging',
- 'IHasDateCreated',
'IHasIcon',
'IHasLogo',
'IHasMugshot',
@@ -159,17 +157,6 @@
mugshot = Attribute("The 192x192 mugshot.")
-class IAging(Interface):
- """Something that gets older as time passes."""
-
- def currentApproximateAge():
- """Return a human-readable string of how old this thing is.
-
- Values returned are things like '2 minutes', '3 hours',
- '1 month', etc.
- """
-
-
class IPrivacy(Interface):
"""Something that can be private."""
@@ -180,12 +167,6 @@
"Private objects are visible to members or subscribers."))
-class IHasDateCreated(Interface):
- """Something created on a certain date."""
-
- datecreated = Attribute("The date on which I was created.")
-
-
class IHeadingContext(Interface):
"""Something that appears in a page's header section.
=== removed file 'lib/lp/app/model/cdatetime.py'
--- lib/lp/app/model/cdatetime.py 2015-07-08 16:05:11 +0000
+++ lib/lp/app/model/cdatetime.py 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Date-related Launchpad components."""
-
-__metaclass__ = type
-
-from datetime import datetime
-
-import pytz
-from zope.interface import implementer
-
-from lp.app.interfaces.launchpad import IAging
-
-
-SECONDS_PER_HOUR = 3600
-SECONDS_PER_MINUTE = 60
-DAYS_PER_YEAR = 365
-DAYS_PER_MONTH = 30
-DAYS_PER_WEEK = 7
-
-
-@implementer(IAging)
-class AgingAdapter:
- """Adapt an IHasDateCreated to an IAging."""
-
- def __init__(self, context):
- self.context = context
-
- def currentApproximateAge(self):
- """See `ITimeDelta`."""
- age = ""
- datecreated = self.context.datecreated
- right_now = datetime.now(pytz.timezone('UTC'))
- delta = right_now - datecreated
- if not delta.days:
- if delta.seconds < SECONDS_PER_HOUR:
- # under an hour
- minutes = delta.seconds / SECONDS_PER_MINUTE
- age = "%d minute" % minutes
- if minutes > 1:
- age += "s"
- else:
- # over an hour
- hours = delta.seconds / SECONDS_PER_HOUR
- age = "%d hour" % hours
- if hours > 1:
- age += "s"
- else:
- # one or more days old
- if delta.days >= DAYS_PER_YEAR:
- # one or more years old
- years = delta.days / DAYS_PER_YEAR
- age = "%d year" % years
- if years > 1:
- age += "s"
- else:
- # under a year old
- if delta.days > DAYS_PER_MONTH:
- months = delta.days / DAYS_PER_MONTH
- age = "%d month" % months
- if months > 1:
- age += "s"
- else:
- if delta.days > DAYS_PER_WEEK:
- weeks = delta.days / DAYS_PER_WEEK
- age = "%d week" % weeks
- if weeks > 1:
- age += "s"
-
- return age
=== modified file 'lib/lp/blueprints/interfaces/specificationbranch.py'
--- lib/lp/blueprints/interfaces/specificationbranch.py 2013-01-07 02:40:55 +0000
+++ lib/lp/blueprints/interfaces/specificationbranch.py 2016-02-05 06:46:47 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interfaces for linking Specifications and Branches."""
@@ -21,17 +21,19 @@
Reference,
ReferenceChoice,
)
-from zope.interface import Interface
+from zope.interface import (
+ Attribute,
+ Interface,
+ )
from zope.schema import Int
from lp import _
-from lp.app.interfaces.launchpad import IHasDateCreated
from lp.blueprints.interfaces.specification import ISpecification
from lp.code.interfaces.branch import IBranch
from lp.registry.interfaces.person import IPerson
-class ISpecificationBranch(IHasDateCreated):
+class ISpecificationBranch(Interface):
"""A branch linked to a specification."""
export_as_webservice_entry(as_of="beta")
@@ -49,6 +51,7 @@
required=True,
schema=IBranch), as_of="beta")
+ datecreated = Attribute("The date on which I was created.")
registrant = exported(
Reference(
schema=IPerson, readonly=True, required=True,
=== modified file 'lib/lp/bugs/interfaces/bugbranch.py'
--- lib/lp/bugs/interfaces/bugbranch.py 2013-01-07 02:40:55 +0000
+++ lib/lp/bugs/interfaces/bugbranch.py 2016-02-05 06:46:47 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interfaces for linking BugTasks and Branches."""
@@ -15,7 +15,10 @@
exported,
)
from lazr.restful.fields import ReferenceChoice
-from zope.interface import Interface
+from zope.interface import (
+ Attribute,
+ Interface,
+ )
from zope.schema import (
Int,
Object,
@@ -23,7 +26,6 @@
)
from lp import _
-from lp.app.interfaces.launchpad import IHasDateCreated
from lp.bugs.interfaces.bugtask import IBugTask
from lp.bugs.interfaces.hasbug import IHasBug
from lp.code.interfaces.branch import IBranch
@@ -32,7 +34,7 @@
from lp.services.fields import BugField
-class IBugBranch(IHasDateCreated, IHasBug, IHasBranchTarget):
+class IBugBranch(IHasBug, IHasBranchTarget):
"""A branch linked to a bug."""
export_as_webservice_entry()
@@ -57,6 +59,7 @@
"against the branch's product)."),
readonly=True)
+ datecreated = Attribute("The date on which I was created.")
registrant = Object(
schema=IPerson, readonly=True, required=True,
title=_("The person who linked the bug to the branch"))
=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
--- lib/lp/bugs/interfaces/bugtask.py 2016-01-26 15:47:37 +0000
+++ lib/lp/bugs/interfaces/bugtask.py 2016-02-05 06:46:47 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Bug task interfaces."""
@@ -79,7 +79,6 @@
from zope.security.interfaces import Unauthorized
from lp import _
-from lp.app.interfaces.launchpad import IHasDateCreated
from lp.app.validators import LaunchpadValidationError
from lp.app.validators.name import name_validator
from lp.bugs.interfaces.bugwatch import (
@@ -390,7 +389,7 @@
"""
-class IBugTask(IHasDateCreated, IHasBug, IBugTaskDelete):
+class IBugTask(IHasBug, IBugTaskDelete):
"""A bug needing fixing in a particular product or package."""
export_as_webservice_entry()
Follow ups