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
1=== modified file 'lib/offspring/master/models.py'
2--- lib/offspring/master/models.py 2011-09-23 14:01:26 +0000
3+++ lib/offspring/master/models.py 2011-10-17 19:42:29 +0000
4@@ -157,6 +157,7 @@
5 title = Unicode()
6 priority = Int(default=0)
7 is_active = Bool(default=True)
8+ is_private = Bool(default=False)
9 launchpad_project_id = Unicode()
10 launchpad_project = Reference(launchpad_project_id, "LaunchpadProject.name")
11 suite = Unicode()
12
13=== modified file 'lib/offspring/master/notifications.py'
14--- lib/offspring/master/notifications.py 2010-11-29 08:27:24 +0000
15+++ lib/offspring/master/notifications.py 2011-10-17 19:42:29 +0000
16@@ -88,6 +88,9 @@
17 def notify_buildresult(build_result):
18 project = build_result.project
19 builder = build_result.builder
20+ if project.is_private:
21+ # We don't support subscriptions for private projects.
22+ return
23
24 build_date, build_id = build_result.name.rsplit('-', 1)
25 build_url = "%s/%s/%s/%s" % (offspring.config.web('build_results_uri'), project.name, build_date, build_id)
26
27=== modified file 'lib/offspring/master/tests.py'
28--- lib/offspring/master/tests.py 2011-09-08 19:12:29 +0000
29+++ lib/offspring/master/tests.py 2011-10-17 19:42:29 +0000
30@@ -5,7 +5,12 @@
31 import unittest
32
33 from offspring import config
34+from offspring.master.models import (
35+ Project,
36+ ProjectNotificationSubscription,
37+ )
38 from offspring.master.notifications import (
39+ notify_buildresult,
40 notify_crash,
41 notify_problem,
42 )
43@@ -20,6 +25,12 @@
44 self.mails.append((sender, rcpt, msg))
45
46
47+class FakeLexBuilder(object):
48+
49+ def __init__(self, name):
50+ self.name = name
51+
52+
53 class Factory(object):
54
55 def __init__(self):
56@@ -29,6 +40,13 @@
57 self.counter += 1
58 return 'str%s' % self.counter
59
60+ def makeProject(self, is_private=False):
61+ name = self.getUniqueString()
62+ project = Project(name=name)
63+ project.title = name.decode('utf-8')
64+ project.is_private = is_private
65+ return project
66+
67
68 class TestCaseWithFactory(unittest.TestCase):
69
70@@ -119,3 +137,24 @@
71 from_header = mailer.mails[0][0]
72 sender_real_name, sender_addr = email.utils.parseaddr(from_header)
73 self.assertEqual(addr, sender_addr)
74+
75+
76+class FakeBuildResult(object):
77+
78+ def __init__(self, project):
79+ self.project = project
80+ self.builder = None
81+
82+
83+class TestNotifyBuildResult(TestCaseWithFactory):
84+
85+ def test_private_project(self):
86+ # For simplicity, we don't support subscriptions for private projects,
87+ # so no notifications are sent here even though there is a project
88+ # subscription.
89+ mailer = StubMailer()
90+ project = self.factory.makeProject(is_private=True)
91+ project.subscriptions = [ProjectNotificationSubscription()]
92+ build = FakeBuildResult(project)
93+ notify_buildresult(build)
94+ self.assertEquals([], mailer.mails)
95
96=== modified file 'lib/offspring/web/templates/queuemanager/project_details.html'
97--- lib/offspring/web/templates/queuemanager/project_details.html 2011-10-10 19:42:14 +0000
98+++ lib/offspring/web/templates/queuemanager/project_details.html 2011-10-17 19:42:29 +0000
99@@ -537,8 +537,16 @@
100 contents:"${isSubscribed ? 'Unsubscribe' : 'Subscribe'} to Notifications",
101 dynamicContents:true,
102 icon: "/assets/images/mail--plus.png",
103+{% if not user.is_authenticated %}
104+ prompt: "You must login to manage your project build notification subscription",
105+ disabled: true,
106+{% else %} {% if project.is_private %}
107+ prompt: "Build notification subscription disabled for private projects",
108+ disabled: true,
109+{% else %}
110 prompt: "Manage project build notification subscription",
111- disabled: {% if user.is_authenticated %}false{% else %}true{% endif %},
112+ disabled: false,
113+{% endif %} {% endif %}
114 click: function() {
115 toggle_subscription();
116 return false;

Subscribers

People subscribed via source and target branches