~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/distroseriesdifference.py

  • Committer: Ian Booth
  • Date: 2011-04-19 15:10:57 UTC
  • mfrom: (12868 devel)
  • mto: This revision was merged to the branch mainline in revision 12983.
  • Revision ID: ian.booth@canonical.com-20110419151057-he56y6k29c4zeiyk
Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
                comment in comments]
152
152
 
153
153
    @property
 
154
    def can_request_diffs(self):
 
155
        """Does the user have permission to request diff calculation?"""
 
156
        return check_permission('launchpad.Edit', self.context)
 
157
 
 
158
    @property
154
159
    def show_edit_options(self):
155
160
        """Only show the options if an editor requests via JS."""
156
 
        return self.request.is_ajax and check_permission(
157
 
            'launchpad.Edit', self.context)
 
161
        return self.request.is_ajax and self.can_request_diffs
 
162
 
 
163
    @property
 
164
    def display_diffs(self):
 
165
        """Only show diffs if there's a base version."""
 
166
        return self.context.base_version is not None
158
167
 
159
168
    @property
160
169
    def display_child_diff(self):
162
171
        return self.context.source_version != self.context.base_version
163
172
 
164
173
    @property
 
174
    def display_parent_diff(self):
 
175
        """Only show the parent diff if we need to."""
 
176
        return self.context.parent_source_version != self.context.base_version
 
177
 
 
178
    @property
165
179
    def can_have_packages_diffs(self):
166
180
        """Return whether this dsd could have packages diffs."""
167
181
        diff_versions = DistroSeriesDifferenceType.DIFFERENT_VERSIONS
177
191
        This method is used in the template to show the package diff
178
192
        request link.
179
193
        """
180
 
        return (check_permission('launchpad.Edit', self.context) and
181
 
                self.context.base_version and
182
 
                (not self.context.package_diff or
183
 
                 not self.context.parent_package_diff))
 
194
        derived_diff_computable = (
 
195
            not self.context.package_diff and self.display_child_diff)
 
196
        parent_diff_computable = (
 
197
            not self.context.parent_package_diff and self.display_parent_diff)
 
198
        return (self.display_diffs and
 
199
                self.can_request_diffs and
 
200
                (derived_diff_computable or
 
201
                 parent_diff_computable))
 
202
 
 
203
    @property
 
204
    def display_package_diffs_info(self):
 
205
        """Whether or not to show package differences info.
 
206
 
 
207
        Show if:
 
208
 
 
209
          There are no diffs yet available AND the base version is set AND
 
210
          either the parent or the derived version differs from the base
 
211
          version AND the user can request diff calculation,
 
212
 
 
213
        Or:
 
214
 
 
215
          There are diffs.
 
216
 
 
217
        """
 
218
        return (
 
219
            self.context.package_diff is not None or
 
220
            self.context.parent_package_diff is not None or
 
221
            self.show_package_diffs_request_link)
184
222
 
185
223
 
186
224
class DistroSeriesDifferenceDisplayComment: