Merge ~ilasc/launchpad:oci-recipe-push-rules-view into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: 6fb37207d74145c21f8d90032424b8767f9430f5
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:oci-recipe-push-rules-view
Merge into: launchpad:master
Diff against target: 89 lines (+45/-0)
4 files modified
lib/lp/oci/browser/ocirecipe.py (+9/-0)
lib/lp/oci/interfaces/ocipushrule.py (+3/-0)
lib/lp/oci/model/ocipushrule.py (+6/-0)
lib/lp/oci/templates/ocirecipe-index.pt (+27/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+386167@code.launchpad.net

Commit message

Add View for OCI push rules

Description of the change

Add View for OCI push rules

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
6fb3720... by Ioana Lasc

Merge branch 'master' into oci-recipe-push-rules-view

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py
index 5fcab06..356ac1c 100644
--- a/lib/lp/oci/browser/ocirecipe.py
+++ b/lib/lp/oci/browser/ocirecipe.py
@@ -184,6 +184,15 @@ class OCIRecipeView(LaunchpadView):
184 def builds(self):184 def builds(self):
185 return builds_for_recipe(self.context)185 return builds_for_recipe(self.context)
186186
187 @cachedproperty
188 def push_rules(self):
189 return list(
190 getUtility(IOCIPushRuleSet).findByRecipe(self.context))
191
192 @property
193 def has_push_rules(self):
194 return len(self.push_rules) > 0
195
187 @property196 @property
188 def person_picker(self):197 def person_picker(self):
189 field = copy_field(198 field = copy_field(
diff --git a/lib/lp/oci/interfaces/ocipushrule.py b/lib/lp/oci/interfaces/ocipushrule.py
index 45aeb3b..67db23e 100644
--- a/lib/lp/oci/interfaces/ocipushrule.py
+++ b/lib/lp/oci/interfaces/ocipushrule.py
@@ -127,6 +127,9 @@ class IOCIPushRuleSet(Interface):
127 def new(recipe, registry_credentials, image_name):127 def new(recipe, registry_credentials, image_name):
128 """Create an `IOCIPushRule`."""128 """Create an `IOCIPushRule`."""
129129
130 def findByRecipe(self, recipe):
131 """Find matching `IOCIPushRule`s by recipe."""
132
130 def findByRegistryCredentials(self, credentials):133 def findByRegistryCredentials(self, credentials):
131 """Find matching `IOCIPushRule` by credentials."""134 """Find matching `IOCIPushRule` by credentials."""
132135
diff --git a/lib/lp/oci/model/ocipushrule.py b/lib/lp/oci/model/ocipushrule.py
index 0354aad..24d5e27 100644
--- a/lib/lp/oci/model/ocipushrule.py
+++ b/lib/lp/oci/model/ocipushrule.py
@@ -91,6 +91,12 @@ class OCIPushRuleSet:
91 """See `IOCIPushRuleSet`."""91 """See `IOCIPushRuleSet`."""
92 return IStore(OCIPushRule).get(OCIPushRule, id)92 return IStore(OCIPushRule).get(OCIPushRule, id)
9393
94 def findByRecipe(self, recipe):
95 store = IStore(OCIPushRule)
96 return store.find(
97 OCIPushRule,
98 OCIPushRule.recipe == recipe)
99
94 def findByRegistryCredentials(self, credentials):100 def findByRegistryCredentials(self, credentials):
95 store = IStore(OCIPushRule)101 store = IStore(OCIPushRule)
96 return store.find(102 return store.find(
diff --git a/lib/lp/oci/templates/ocirecipe-index.pt b/lib/lp/oci/templates/ocirecipe-index.pt
index f7df628..cf7c549 100644
--- a/lib/lp/oci/templates/ocirecipe-index.pt
+++ b/lib/lp/oci/templates/ocirecipe-index.pt
@@ -116,6 +116,33 @@
116 tal:condition="link/enabled">116 tal:condition="link/enabled">
117 <tal:request-builds replace="structure link/fmt:link"/>117 <tal:request-builds replace="structure link/fmt:link"/>
118 </div>118 </div>
119
120
121 <h2>Recipe push rules</h2>
122 <table id="push-rules-listing" tal:condition="view/has_push_rules" class="listing"
123 style="margin-bottom: 1em; ">
124 <thead>
125 <tr>
126 <th>Registry URL</th>
127 <th>Username</th>
128 <th>Image Name</th>
129 </tr>
130 </thead>
131 <tbody>
132 <tal:recipe-push-rules repeat="item view/push_rules">
133 <tr tal:define="rule item"
134 tal:attributes="id string:rule-${rule/id}">
135 <td tal:content="rule/registry_credentials/url"/>
136 <td tal:content="rule/registry_credentials/username"/>
137 <td tal:content="rule/image_name"/>
138 </tr>
139 </tal:recipe-push-rules>
140 </tbody>
141 </table>
142 <p tal:condition="not: view/has_push_rules">
143 This OCI recipe has no push rules defined yet.
144 </p>
145
119 </div>146 </div>
120147
121</body>148</body>

Subscribers

People subscribed via source and target branches

to status/vote changes: