Merge lp:~wgrant/launchpad/answer-contacts-are-satan into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 18177
Proposed branch: lp:~wgrant/launchpad/answer-contacts-are-satan
Merge into: lp:launchpad
Diff against target: 41 lines (+11/-1)
2 files modified
lib/lp/answers/tests/test_question.py (+10/-0)
lib/lp/security.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/answer-contacts-are-satan
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+303646@code.launchpad.net

Commit message

Prevent answer contacts from editing question titles and descriptions.

Description of the change

Prevent answer contacts from editing question titles and descriptions.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/answers/tests/test_question.py'
2--- lib/lp/answers/tests/test_question.py 2015-12-01 11:38:01 +0000
3+++ lib/lp/answers/tests/test_question.py 2016-08-23 04:39:00 +0000
4@@ -4,9 +4,11 @@
5 __metaclass__ = type
6
7 from testtools.testcase import ExpectedException
8+from zope.component import getUtility
9 from zope.security.interfaces import Unauthorized
10 from zope.security.proxy import removeSecurityProxy
11
12+from lp.services.worlddata.interfaces.language import ILanguageSet
13 from lp.testing import (
14 admin_logged_in,
15 anonymous_logged_in,
16@@ -33,6 +35,14 @@
17 question.title = 'foo random'
18 with ExpectedException(Unauthorized):
19 question.description = 'foo random'
20+ answer_contact = self.factory.makePerson()
21+ with person_logged_in(answer_contact):
22+ answer_contact.addLanguage(getUtility(ILanguageSet)['en'])
23+ question.target.addAnswerContact(answer_contact, answer_contact)
24+ with ExpectedException(Unauthorized):
25+ question.title = 'foo contact'
26+ with ExpectedException(Unauthorized):
27+ question.description = 'foo contact'
28 with person_logged_in(question.owner):
29 question.title = question.description = 'foo owner'
30 with person_logged_in(question.target.owner):
31
32=== modified file 'lib/lp/security.py'
33--- lib/lp/security.py 2016-07-15 14:25:15 +0000
34+++ lib/lp/security.py 2016-08-23 04:39:00 +0000
35@@ -2042,7 +2042,7 @@
36
37 def checkAuthenticated(self, user):
38 return (
39- AppendQuestion(self.obj).checkAuthenticated(user)
40+ AdminQuestion(self.obj).checkAuthenticated(user)
41 or QuestionOwner(self.obj).checkAuthenticated(user))
42
43