~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/browser/productrelease.py

  • Committer: Curtis Hovey
  • Date: 2009-02-06 22:27:46 UTC
  • mto: This revision was merged to the branch mainline in revision 7755.
  • Revision ID: curtis.hovey@canonical.com-20090206222746-1nswuptyrkqsfs8o
Deleting a release now deletes the files attached to a release too. Updated the
release templates to onecolumn format. Removed the administrator's view because
project owners should manage the version field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    @enabled_with_permission('launchpad.Edit')
60
60
    def add_file(self):
61
61
        text = 'Add download file'
62
 
        return Link('+adddownloadfile', text, icon='edit')
 
62
        return Link('+adddownloadfile', text, icon='add')
63
63
 
64
64
    @enabled_with_permission('launchpad.Admin')
65
65
    def administer(self):
91
91
        self._nextURL = canonical_url(newrelease)
92
92
        notify(ObjectCreatedEvent(newrelease))
93
93
 
 
94
    @property
 
95
    def cancel_url(self):
 
96
        return canonical_url(self.context)
 
97
 
94
98
 
95
99
class ProductReleaseEditView(LaunchpadEditFormView):
96
100
    """Edit view for ProductRelease objects"""
97
101
 
98
102
    schema = IProductRelease
99
 
    label = "Edit project release details"
100
 
    field_names = ["summary", "description", "changelog", "codename"]
 
103
    field_names = [
 
104
        "summary", "description", "changelog", "codename", "version"]
101
105
    custom_widget('summary', TextAreaWidget, width=62, height=5)
102
106
 
 
107
    @property
 
108
    def label(self):
 
109
        """The form label."""
 
110
        return 'Edit %s release details' % self.context.title
 
111
 
103
112
    @action('Change', name='change')
104
113
    def change_action(self, action, data):
105
114
        self.updateContextFromData(data)
106
115
        self.next_url = canonical_url(self.context)
107
116
 
 
117
    @property
 
118
    def cancel_url(self):
 
119
        return canonical_url(self.context)
 
120
 
108
121
 
109
122
class ProductReleaseRdfView(object):
110
123
    """A view that sets its mime-type to application/rdf+xml"""
141
154
 
142
155
    custom_widget('description', TextWidget, width=62)
143
156
 
 
157
    @property
 
158
    def label(self):
 
159
        """The form label."""
 
160
        return 'Add a download file to %s' % self.context.title
 
161
 
144
162
    @action('Upload', name='add')
145
163
    def add_action(self, action, data):
146
164
        form = self.request.form
185
203
 
186
204
        self.next_url = canonical_url(self.context)
187
205
 
 
206
    @property
 
207
    def cancel_url(self):
 
208
        return canonical_url(self.context)
 
209
 
188
210
 
189
211
class ProductReleaseView(LaunchpadView, ProductDownloadFileMixin):
190
212
    """View for ProductRelease overview."""
201
223
 
202
224
class ProductReleaseDeleteView(LaunchpadFormView):
203
225
    """A view for deleting an `IProductRelease`."""
204
 
    label = 'Delete release'
205
226
    schema = IProductRelease
206
227
    field_names = []
207
228
 
208
 
    def canBeDeleted(self, action=None):
209
 
        """Can this release be deleted?
210
 
 
211
 
        Only releases which have no files associated with it can be deleted.
212
 
        """
213
 
        return self.context.files.count() == 0
214
 
 
215
 
    @action('Yes, Delete it', name='delete', condition=canBeDeleted)
 
229
    @property
 
230
    def label(self):
 
231
        """The form label."""
 
232
        return 'Delete %s' % self.context.title
 
233
 
 
234
    @action('Delete this Release', name='delete')
216
235
    def add_action(self, action, data):
 
236
        for release_file in self.context.files:
 
237
            release_file.destroySelf()
217
238
        self.request.response.addInfoNotification(
218
239
            "Release %s deleted." % self.context.version)
219
240
        self.next_url = canonical_url(self.context.productseries)
220
241
        self.context.destroySelf()
 
242
 
 
243
    @property
 
244
    def cancel_url(self):
 
245
        return canonical_url(self.context)
 
246