Merge lp:~sinzui/launchpad/team-renewal-0 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Curtis Hovey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11620 |
Proposed branch: | lp:~sinzui/launchpad/team-renewal-0 |
Merge into: | lp:launchpad |
Diff against target: |
329 lines (+111/-102) 4 files modified
lib/lp/registry/interfaces/person.py (+17/-7) lib/lp/registry/stories/team/xx-team-edit.txt (+10/-27) lib/lp/registry/stories/teammembership/xx-new-team.txt (+0/-68) lib/lp/registry/tests/test_team.py (+84/-0) |
To merge this branch: | bzr merge lp:~sinzui/launchpad/team-renewal-0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+36246@code.launchpad.net |
Description of the change
This is my branch to prevent impossibly default renewal periods.
lp:~sinzui/launchpad/team-renewal-0
Diff size: 146
Launchpad bug:
https:/
Test command: ./bin/test -vv \
-t TestDefaultRene
Pre-
Target release: 10.10
Prevent impossibly default renewal periods
-------
A user entered an integer that exceeds the expectations of postgresql;
The default renewal period for a team membership was set to be older
than the Himalayas. We expect the value in days to be a few months to a
few years.
Meanwhile, we have a constraint issue. There is an invariant guarding the
minimum number of days, there could be a maximum number of days
Rules
-----
* Revise the invariant to raise Invalid if the days are greater than
3650 (10 years).
* There are a few insane cases in the DB where teams have set
the value greater than a human life time. The teams will need to
set the renewal policy to None. or revise the number if they choose
to edit the team details.
QA
--
* Choose the Change details link for a team you control.
* Set the renewal policy to automatic or ondemand
* Set the renewal period to 9999999999 in disregard of the text
that asks for a number from 1 to 3650.
* Verify the form states that it wants a number from 1 to 3650.
Lint
----
Linting changed files:
lib/lp/
lib/lp/
Test
----
* lib/lp/
* Added a test to verify the invariant that governs membership
policy and renewal period.
Implementation
--------------
* lib/lp/
* Added a maximum day constraint and refactored the test to raise
Invalid to be in two parts.
Hi Curtis,
This looks good. I just have a couple of comments below. Feel free to ignore the comment about changing the minimum number of days since that requires more work.
>=== modified file 'lib/lp/ registry/ interfaces/ person. py' registry/ interfaces/ person. py 2010-08-22 03:09:51 +0000 registry/ interfaces/ person. py 2010-09-22 20:06:34 +0000 person( obj, attr, value): providedBy( person) person_ common( obj, attr, value, validate) public_ person( obj, attr, value): person( person) person_ common( obj, attr, value, validate) defaultrenewalp eriod RenewalPolicy. AUTOMATIC, enewalPolicy. ONDEMAND]
>--- lib/lp/
>+++ lib/lp/
>@@ -182,15 +182,19 @@
>
> def validate_
> """Validate the person is a real person with no other restrictions."""
>+
> def validate(person):
> return IPerson.
>+
> return validate_
>
>
> def validate_
> """Validate that the person identified by value is public."""
>+
> def validate(person):
> return is_public_
>+
> return validate_
>
>
>@@ -1630,13 +1634,18 @@
> return
>
> renewal_period = person.
>- automatic, ondemand = [TeamMembership
>- TeamMembershipR
>- cannot_be_none = renewal_policy in [automatic, ondemand]
>- if ((renewal_period is None and cannot_be_none)
>- or (renewal_period is not None and renewal_period <= 0)):
>+ cannot_be_none = (
It seems like it would make more sense to call this value_missing. Otherwise, it looks like a logic error when
is_required_
you check whether renewal_period is None to decide whether it cannot be
None.
>+ renewal_period is None enewalPolicy. AUTOMATIC, enewalPolicy. ONDEMAND] )
>+ and renewal_policy in [
>+ TeamMembershipR
>+ TeamMembershipR
>+ out_of_range = (
>+ renewal_period is not None
>+ and (renewal_period <= 0 or renewal_period > 3650))
>+ if cannot_be_none or out_of_range:
> raise Invalid(
>- 'You must specify a default renewal period greater than 0.')
>+ 'You must specify a default renewal period greater than 0 '
>+ 'and less than 3651 days.')
Wouldn't it be easier to read "from 1 to 3650 days"?
Also, if the renewal period is less than 2 days, the user may not get
the next renewal email if the cronjob runs before they renew it.
> teamdescription = exported( _('Renewal period'), required=False,
> Text(title=_('Team Description'), required=False, readonly=False,
>@@ -1676,6 +1685,7 @@
> Int(title=
> description=_(
> "Number of days a subscription lasts after being renewed. "
>+ "The number can be from 1 to 3650 (10 years). "
> "You can customize the lengths of individual renewals, but "
> "this is what's used for auto-renewed and user-renewed "
> "memberships.")),
>