Merge lp:~salgado/offspring/disable-subscription-for-private-projects into lp:~linaro-automation/offspring/private-builds

Proposed by Guilherme Salgado
Status: Merged
Approved by: James Tunnicliffe
Approved revision: no longer in the source branch.
Merged at revision: 69
Proposed branch: lp:~salgado/offspring/disable-subscription-for-private-projects
Merge into: lp:~linaro-automation/offspring/private-builds
Prerequisite: lp:~salgado/offspring/more-piston-handlers
Diff against target: 116 lines (+52/-1)
4 files modified
lib/offspring/master/models.py (+1/-0)
lib/offspring/master/notifications.py (+3/-0)
lib/offspring/master/tests.py (+39/-0)
lib/offspring/web/templates/queuemanager/project_details.html (+9/-1)
To merge this branch: bzr merge lp:~salgado/offspring/disable-subscription-for-private-projects
Reviewer Review Type Date Requested Status
Linaro Infrastructure Pending
Review via email: mp+79606@code.launchpad.net

Description of the change

This branch disables the ability to subscribe to notifications of private projects as well as the sending of notifications about private projects

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

On Mon, 17 Oct 2011 19:43:31 -0000, Guilherme Salgado <email address hidden> wrote:
> Guilherme Salgado has proposed merging lp:~salgado/offspring/disable-subscription-for-private-projects into lp:~linaro-infrastructure/offspring/private-builds with lp:~salgado/offspring/more-piston-handlers as a prerequisite.
>
> Requested reviews:
> Linaro Infrastructure (linaro-infrastructure)
>
> For more details, see:
> https://code.launchpad.net/~salgado/offspring/disable-subscription-for-private-projects/+merge/79606
>
> This branch disables the ability to subscribe to notifications of
> private projects as well as the sending of notifications about private
> projects

Hi,

What's the rationale for this one?

Thanks,

James

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

On 17 October 2011 21:34, James Westby <email address hidden> wrote:
> What's the rationale for this one?

The idea is to close the loop on:

1. Project is public
2. User subscribes to project
3. Project is made private
4. User is still subscribed to project, doesn't matter if they are a
member of the private projects team or not.

This is an initial implementation with a view to adding subscriptions
back to private projects if they are needed later.

--
James Tunnicliffe

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/offspring/master/models.py'
--- lib/offspring/master/models.py 2011-09-23 14:01:26 +0000
+++ lib/offspring/master/models.py 2011-10-17 19:42:29 +0000
@@ -157,6 +157,7 @@
157 title = Unicode()157 title = Unicode()
158 priority = Int(default=0)158 priority = Int(default=0)
159 is_active = Bool(default=True)159 is_active = Bool(default=True)
160 is_private = Bool(default=False)
160 launchpad_project_id = Unicode()161 launchpad_project_id = Unicode()
161 launchpad_project = Reference(launchpad_project_id, "LaunchpadProject.name")162 launchpad_project = Reference(launchpad_project_id, "LaunchpadProject.name")
162 suite = Unicode()163 suite = Unicode()
163164
=== modified file 'lib/offspring/master/notifications.py'
--- lib/offspring/master/notifications.py 2010-11-29 08:27:24 +0000
+++ lib/offspring/master/notifications.py 2011-10-17 19:42:29 +0000
@@ -88,6 +88,9 @@
88def notify_buildresult(build_result):88def notify_buildresult(build_result):
89 project = build_result.project89 project = build_result.project
90 builder = build_result.builder90 builder = build_result.builder
91 if project.is_private:
92 # We don't support subscriptions for private projects.
93 return
91 94
92 build_date, build_id = build_result.name.rsplit('-', 1)95 build_date, build_id = build_result.name.rsplit('-', 1)
93 build_url = "%s/%s/%s/%s" % (offspring.config.web('build_results_uri'), project.name, build_date, build_id)96 build_url = "%s/%s/%s/%s" % (offspring.config.web('build_results_uri'), project.name, build_date, build_id)
9497
=== modified file 'lib/offspring/master/tests.py'
--- lib/offspring/master/tests.py 2011-09-08 19:12:29 +0000
+++ lib/offspring/master/tests.py 2011-10-17 19:42:29 +0000
@@ -5,7 +5,12 @@
5import unittest5import unittest
66
7from offspring import config7from offspring import config
8from offspring.master.models import (
9 Project,
10 ProjectNotificationSubscription,
11 )
8from offspring.master.notifications import (12from offspring.master.notifications import (
13 notify_buildresult,
9 notify_crash,14 notify_crash,
10 notify_problem,15 notify_problem,
11)16)
@@ -20,6 +25,12 @@
20 self.mails.append((sender, rcpt, msg))25 self.mails.append((sender, rcpt, msg))
2126
2227
28class FakeLexBuilder(object):
29
30 def __init__(self, name):
31 self.name = name
32
33
23class Factory(object):34class Factory(object):
2435
25 def __init__(self):36 def __init__(self):
@@ -29,6 +40,13 @@
29 self.counter += 140 self.counter += 1
30 return 'str%s' % self.counter41 return 'str%s' % self.counter
3142
43 def makeProject(self, is_private=False):
44 name = self.getUniqueString()
45 project = Project(name=name)
46 project.title = name.decode('utf-8')
47 project.is_private = is_private
48 return project
49
3250
33class TestCaseWithFactory(unittest.TestCase):51class TestCaseWithFactory(unittest.TestCase):
3452
@@ -119,3 +137,24 @@
119 from_header = mailer.mails[0][0]137 from_header = mailer.mails[0][0]
120 sender_real_name, sender_addr = email.utils.parseaddr(from_header)138 sender_real_name, sender_addr = email.utils.parseaddr(from_header)
121 self.assertEqual(addr, sender_addr)139 self.assertEqual(addr, sender_addr)
140
141
142class FakeBuildResult(object):
143
144 def __init__(self, project):
145 self.project = project
146 self.builder = None
147
148
149class TestNotifyBuildResult(TestCaseWithFactory):
150
151 def test_private_project(self):
152 # For simplicity, we don't support subscriptions for private projects,
153 # so no notifications are sent here even though there is a project
154 # subscription.
155 mailer = StubMailer()
156 project = self.factory.makeProject(is_private=True)
157 project.subscriptions = [ProjectNotificationSubscription()]
158 build = FakeBuildResult(project)
159 notify_buildresult(build)
160 self.assertEquals([], mailer.mails)
122161
=== modified file 'lib/offspring/web/templates/queuemanager/project_details.html'
--- lib/offspring/web/templates/queuemanager/project_details.html 2011-10-10 19:42:14 +0000
+++ lib/offspring/web/templates/queuemanager/project_details.html 2011-10-17 19:42:29 +0000
@@ -537,8 +537,16 @@
537 contents:"${isSubscribed ? 'Unsubscribe' : 'Subscribe'} to Notifications",537 contents:"${isSubscribed ? 'Unsubscribe' : 'Subscribe'} to Notifications",
538 dynamicContents:true,538 dynamicContents:true,
539 icon: "/assets/images/mail--plus.png",539 icon: "/assets/images/mail--plus.png",
540{% if not user.is_authenticated %}
541 prompt: "You must login to manage your project build notification subscription",
542 disabled: true,
543{% else %} {% if project.is_private %}
544 prompt: "Build notification subscription disabled for private projects",
545 disabled: true,
546{% else %}
540 prompt: "Manage project build notification subscription",547 prompt: "Manage project build notification subscription",
541 disabled: {% if user.is_authenticated %}false{% else %}true{% endif %},548 disabled: false,
549{% endif %} {% endif %}
542 click: function() {550 click: function() {
543 toggle_subscription();551 toggle_subscription();
544 return false;552 return false;

Subscribers

People subscribed via source and target branches