Merge lp:~cjwatson/launchpad/git-repository-description into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17406
Proposed branch: lp:~cjwatson/launchpad/git-repository-description
Merge into: lp:launchpad
Diff against target: 112 lines (+24/-5)
5 files modified
lib/lp/code/interfaces/gitrepository.py (+4/-0)
lib/lp/code/model/gitnamespace.py (+2/-2)
lib/lp/code/model/gitrepository.py (+6/-3)
lib/lp/code/model/tests/test_gitrepository.py (+8/-0)
lib/lp/code/templates/gitrepository-index.pt (+4/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/git-repository-description
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+253238@code.launchpad.net

Commit message

Model, export, and render GitRepository.description.

Description of the change

Model, export, and render GitRepository.description.

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/code/interfaces/gitrepository.py'
2--- lib/lp/code/interfaces/gitrepository.py 2015-03-17 10:42:24 +0000
3+++ lib/lp/code/interfaces/gitrepository.py 2015-03-17 16:09:05 +0000
4@@ -306,6 +306,10 @@
5 date_last_modified = exported(Datetime(
6 title=_("Date last modified"), required=True, readonly=True))
7
8+ description = exported(Text(
9+ title=_("Description"), required=False, readonly=False,
10+ description=_("A short description of this repository.")))
11+
12
13 class IGitRepositoryModerate(Interface):
14 """IGitRepository methods that can be called by more than one community."""
15
16=== modified file 'lib/lp/code/model/gitnamespace.py'
17--- lib/lp/code/model/gitnamespace.py 2015-03-03 14:37:54 +0000
18+++ lib/lp/code/model/gitnamespace.py 2015-03-17 16:09:05 +0000
19@@ -60,7 +60,7 @@
20 """Common code for Git repository namespaces."""
21
22 def createRepository(self, registrant, name, information_type=None,
23- date_created=DEFAULT):
24+ date_created=DEFAULT, description=None):
25 """See `IGitNamespace`."""
26
27 self.validateRegistrant(registrant)
28@@ -73,7 +73,7 @@
29
30 repository = GitRepository(
31 registrant, self.owner, self.target, name, information_type,
32- date_created)
33+ date_created, description=description)
34 repository._reconcileAccess()
35
36 notify(ObjectCreatedEvent(repository))
37
38=== modified file 'lib/lp/code/model/gitrepository.py'
39--- lib/lp/code/model/gitrepository.py 2015-03-17 10:42:24 +0000
40+++ lib/lp/code/model/gitrepository.py 2015-03-17 16:09:05 +0000
41@@ -161,18 +161,21 @@
42
43 name = Unicode(name='name', allow_none=False)
44
45+ description = Unicode(name='description', allow_none=True)
46+
47 information_type = EnumCol(enum=InformationType, notNull=True)
48 owner_default = Bool(name='owner_default', allow_none=False)
49 target_default = Bool(name='target_default', allow_none=False)
50
51 def __init__(self, registrant, owner, target, name, information_type,
52- date_created):
53+ date_created, description=None):
54 if not getFeatureFlag(GIT_FEATURE_FLAG):
55 raise GitFeatureDisabled
56 super(GitRepository, self).__init__()
57 self.registrant = registrant
58 self.owner = owner
59 self.name = name
60+ self.description = description
61 self.information_type = information_type
62 self.date_created = date_created
63 self.date_last_modified = date_created
64@@ -511,12 +514,12 @@
65 implements(IGitRepositorySet)
66
67 def new(self, registrant, owner, target, name, information_type=None,
68- date_created=DEFAULT):
69+ date_created=DEFAULT, description=None):
70 """See `IGitRepositorySet`."""
71 namespace = get_git_namespace(target, owner)
72 return namespace.createRepository(
73 registrant, name, information_type=information_type,
74- date_created=date_created)
75+ date_created=date_created, description=description)
76
77 def getByPath(self, user, path):
78 """See `IGitRepositorySet`."""
79
80=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
81--- lib/lp/code/model/tests/test_gitrepository.py 2015-03-17 10:47:59 +0000
82+++ lib/lp/code/model/tests/test_gitrepository.py 2015-03-17 16:09:05 +0000
83@@ -653,6 +653,14 @@
84 self.assertEqual(
85 InformationType.PRIVATESECURITY, repository.information_type)
86
87+ def test_attribute_smoketest(self):
88+ # Users with launchpad.Moderate can set attributes.
89+ project = self.factory.makeProduct()
90+ repository = self.factory.makeGitRepository(target=project)
91+ with person_logged_in(project.owner):
92+ repository.description = u"something"
93+ self.assertEqual(u"something", repository.description)
94+
95
96 class TestGitRepositorySetOwner(TestCaseWithFactory):
97 """Test `IGitRepository.setOwner`."""
98
99=== modified file 'lib/lp/code/templates/gitrepository-index.pt'
100--- lib/lp/code/templates/gitrepository-index.pt 2015-03-04 16:49:42 +0000
101+++ lib/lp/code/templates/gitrepository-index.pt 2015-03-17 16:09:05 +0000
102@@ -32,6 +32,10 @@
103
104 <div metal:fill-slot="main">
105
106+ <div id="repository-description" tal:condition="context/description"
107+ class="summary"
108+ tal:content="structure context/description/fmt:text-to-html" />
109+
110 <div class="yui-g first">
111 <div id="repository-management" class="portlet">
112 <tal:repository-management