Merge lp://staging/~gary/launchpad/bug-772754-2 into lp://staging/launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 13243
Proposed branch: lp://staging/~gary/launchpad/bug-772754-2
Merge into: lp://staging/launchpad
Prerequisite: lp://staging/~gary/launchpad/bug792493
Diff against target: 2182 lines (+1238/-638)
15 files modified
lib/canonical/launchpad/icing/style.css (+10/-0)
lib/lp/bugs/browser/bug.py (+88/-57)
lib/lp/bugs/browser/configure.zcml (+1/-1)
lib/lp/bugs/browser/structuralsubscription.py (+14/-21)
lib/lp/bugs/browser/tests/test_bug_views.py (+1/-13)
lib/lp/bugs/javascript/bug_subscription_portlet.js (+385/-0)
lib/lp/bugs/javascript/bugtask_index_portlets.js (+0/-519)
lib/lp/bugs/javascript/tests/test_bug_subscription_portlet.html (+42/-0)
lib/lp/bugs/javascript/tests/test_bug_subscription_portlet.js (+637/-0)
lib/lp/bugs/javascript/tests/test_subscription.js (+4/-2)
lib/lp/bugs/model/bug.py (+1/-1)
lib/lp/bugs/model/structuralsubscription.py (+4/-5)
lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt (+14/-7)
lib/lp/bugs/templates/bug-portlet-subscription.pt (+36/-12)
lib/lp/registry/javascript/structural-subscription.js (+1/-0)
To merge this branch: bzr merge lp://staging/~gary/launchpad/bug-772754-2
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+63444@code.staging.launchpad.net

Description of the change

This branch implements the subscriptions portlet part of the design from bug 772754. I adjusted the design a bit as I worked on it, but it's close to what I had there.

You can think of this diff in three parts:
 (A) rip out the old subscription portlet code, including the bits that integrate with the subscriber portlet;
 (B) change the rendering of the subscription portlet to match the new design, with or without JS; and
 (C) add new subscription portlet JS code to handle subscriptions.

I'll divide up the diff into those three parts.

(A) rip out the old subscription portlet code

lib/lp/bugs/javascript/bugtask_index_portlets.js
    Danilo's changes will make this file disappear!

(B) change the rendering of the subscription portlet

lib/canonical/launchpad/icing/style.css
    (No comment)
lib/lp/bugs/browser/configure.zcml
    We use a new view class so we can specify just what we need.
lib/lp/bugs/browser/bug.py
    Note that we are sharing the new strings with JavaScript by dumping them in the JSONRequestCache.
    Note that user_should_see_mute_link is now an attribute rather than a property. The previous tests remain.
    Note that we use an existing structural subscription function to determine whether the user has any pertinent structural subscriptions. That function had to be modified to return a result set. That function change resulted in changes in these files:
  lib/lp/bugs/model/structuralsubscription.py
  lib/lp/bugs/browser/bugsubscription.py
  lib/lp/bugs/model/bug.py
lib/lp/bugs/browser/tests/test_bug_views.py
    I had to make the test helper a bit more robust because I was using much fewer classes, and sometime none at all.
lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt
    (No comment)
lib/lp/bugs/templates/bug-portlet-subscription.pt
    (No comment)

(C) add new subscription portlet JS code

lib/lp/bugs/javascript/bugtask_index_subscription_portlet.js
    setup_subscription_link_handlers looks a bit hairy at first glance, but I think the main reason is that it starts by setting up the DOM nodes we'll need. After that it is pretty straightforward; and other than that, it is relatively short.
lib/lp/bugs/javascript/tests/test_bugtask_index_subscription_portlet.html
    (No comment)
lib/lp/bugs/javascript/tests/test_bugtask_index_subscription_portlet.js
    I copied LPClient yet again. We really should put that somewhere else, and better document it, and maybe polish it to make it easier to use/understand. I didn't want to do that now. I also noted the problem in lib/lp/bugs/javascript/tests/test_subscription.js .

Beyond those bits, I had a single crazy whitespace change: lib/lp/registry/javascript/structural-subscription.js .

Thank you!

Gary

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :
Download full text (14.7 KiB)

Hi Gary,

Thanks for working on this: it's a huge improvement over what we used to
have, and very nicely factored. I do have a few suggestions on some
further factoring and a few cleanups, but that's about it.

The only other remark of note that I have is that I find the UI
presentation a bit weird for the overlay.

None of the changes I propose are binding, and I find your branch pretty
good.

  review approve
  merge approve

> === modified file 'lib/lp/bugs/browser/bug.py'
...
> +from lp.bugs.model.personsubscriptioninfo import PersonSubscriptions

I like it that you are reusing the work that we've already done. Cool :)

> @@ -642,6 +607,79 @@
> return ProxiedLibraryFileAlias(
> attachment.libraryfile, attachment).http_url
>
> +class BugSubscriptionPortletView(BugView):

I might have missed them, but at least a test or two for this view would
be nice to have.

Also, I ain't sure if you could have used BugViewMixin instead of
BugView directly. Worth checking, imo.

...
> +
> + def initialize(self):
...
> + if psi.direct.personal:
> + self.direct_notifications = True
> + direct = psi.direct.personal[0]
> + cache['subscription'] = direct.subscription
> + level = direct.subscription.bug_notification_level
> + if level == BugNotificationLevel.COMMENTS:
> + self.direct_all_notifications = True
> + elif level == BugNotificationLevel.METADATA:
> + self.direct_metadata_notifications = True
> + else:
> + assert level == BugNotificationLevel.LIFECYCLE
> + self.direct_lifecycle_notifications = True
> + self.other_subscription_notifications = bool(
> + has_structural_subscriptions or
> + psi.from_duplicate.count or
> + psi.as_owner.count or
> + psi.as_assignee.count or
> + psi.direct.as_team_member or
> + psi.direct.as_team_admin)

I find this interesting. What happens with eg. LIFECYCLE duplicate
subscription? How are we to show that in the UI? Should my code include
the current user among the 'Other subscribers' if they have a duplicate
subscription?

> === modified file 'lib/lp/bugs/browser/bugsubscription.py'
> --- lib/lp/bugs/browser/bugsubscription.py 2011-06-03 22:36:15 +0000
> +++ lib/lp/bugs/browser/bugsubscription.py 2011-06-03 22:36:29 +0000
> @@ -612,8 +612,8 @@
>
> def initialize(self):
> super(BugSubscriptionListView, self).initialize()
> - subscriptions = get_structural_subscriptions_for_bug(
> - self.context.bug, self.user)
> + subscriptions = list(get_structural_subscriptions_for_bug(
> + self.context.bug, self.user))
> expose_structural_subscription_data_to_js(
> self.context, self.request, self.user, subscriptions)
> subscriptions_info = PersonSubscriptions(

Looking at the code of expose_structural_subscription_data_to_js(), it
should have worked with a ResultSet(): it checks the length with
len(list(subscriptions)) and then calls ex...

review: Approve
Revision history for this message
Gary Poster (gary) wrote :
Download full text (18.7 KiB)

On Jun 6, 2011, at 7:43 AM, Данило Шеган wrote:

> Review: Approve
> Hi Gary,
>
> Thanks for working on this: it's a huge improvement over what we used to
> have, and very nicely factored. I do have a few suggestions on some
> further factoring and a few cleanups, but that's about it.
>
> The only other remark of note that I have is that I find the UI
> presentation a bit weird for the overlay.
>
> None of the changes I propose are binding, and I find your branch pretty
> good.
>
> review approve
> merge approve

Thank you Danilo. Comments inline below.

>
>> === modified file 'lib/lp/bugs/browser/bug.py'
> ...
>> +from lp.bugs.model.personsubscriptioninfo import PersonSubscriptions
>
> I like it that you are reusing the work that we've already done. Cool :)
>
>> @@ -642,6 +607,79 @@
>> return ProxiedLibraryFileAlias(
>> attachment.libraryfile, attachment).http_url
>>
>> +class BugSubscriptionPortletView(BugView):
>
> I might have missed them, but at least a test or two for this view would
> be nice to have.

Some existing ones are there. I modified them slightly to look at some of the new attributes.

>
> Also, I ain't sure if you could have used BugViewMixin instead of
> BugView directly. Worth checking, imo.

Yeah, that worked. Done, thank you.

>
> ...
>> +
>> + def initialize(self):
> ...
>> + if psi.direct.personal:
>> + self.direct_notifications = True
>> + direct = psi.direct.personal[0]
>> + cache['subscription'] = direct.subscription
>> + level = direct.subscription.bug_notification_level
>> + if level == BugNotificationLevel.COMMENTS:
>> + self.direct_all_notifications = True
>> + elif level == BugNotificationLevel.METADATA:
>> + self.direct_metadata_notifications = True
>> + else:
>> + assert level == BugNotificationLevel.LIFECYCLE
>> + self.direct_lifecycle_notifications = True
>> + self.other_subscription_notifications = bool(
>> + has_structural_subscriptions or
>> + psi.from_duplicate.count or
>> + psi.as_owner.count or
>> + psi.as_assignee.count or
>> + psi.direct.as_team_member or
>> + psi.direct.as_team_admin)
>
> I find this interesting. What happens with eg. LIFECYCLE duplicate
> subscription? How are we to show that in the UI? Should my code include
> the current user among the 'Other subscribers' if they have a duplicate
> subscription?

We talked about this. Practically, we agreed that "Edit bug mail" would be sufficient for now: for my portlet, it will just be another subscription, and you will not list the user in your portlet for any reason. If people need the duplicate functionality, we can look into it when they file a bug.

>
>> === modified file 'lib/lp/bugs/browser/bugsubscription.py'
>> --- lib/lp/bugs/browser/bugsubscription.py 2011-06-03 22:36:15 +0000
>> +++ lib/lp/bugs/browser/bugsubscription.py 2011-06-03 22:36:29 +0000
>> @@ -612,8 +612,8 @@
>>
>> def initialize(se...

Revision history for this message
Данило Шеган (danilo) wrote :

У сре, 08. 06 2011. у 18:24 +0000, Gary Poster пише:
>
> That said, your position is a well-reasoned whole, of which this is
> only a part. I'll continue to consider it, and I'm pretty sure that
> your position corresponds better with our agreed-upon best practices
> than mine.

You must also understand that I am coming from a background where I had
to fight numerous historical Rosetta corner-case tests from pagetests
and doctests, and thus I am a bit over-sensitive in the other
direction :)

Anyway, the branch is now even more good-to-go :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.