Changeset 7107 for main/waeup.sirp/trunk/src
- Timestamp:
- 14 Nov 2011, 08:18:15 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7097 r7107 471 471 pnav = 4 472 472 files_changed = [] 473 files_deleted = [] 473 474 474 475 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/filedisplay.pt
r7106 r7107 1 <tr >1 <tr tal:condition = "viewlet/file_exists"> 2 2 <td class="label"> 3 3 <label i18n:translate=""> -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/fileupload.pt
r7106 r7107 7 7 <td class="field"> 8 8 <span class="widget"> 9 <a tal:attributes="href viewlet/download_name" 10 tal:content="viewlet/download_name" 11 target="image"> 12 LINK 13 </a> 14 <br /> 9 <tal:file tal:condition="viewlet/file_exists"> 10 <input type="submit" id="delete" 11 name="delete" value="Delete file" class="button" /> 12 <a tal:attributes="href viewlet/download_name" 13 tal:content="viewlet/download_name" 14 target="image"> 15 LINK 16 </a> 17 <br /><br /> 18 </tal:file> 19 Upload new file:<br /> 15 20 <input type="file" tal:attributes="name viewlet/input_name"/> 16 21 <br /> -
main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py
r7106 r7107 198 198 rel_link = '/students/%s' % self.request.principal.id 199 199 return self.view.application_url() + rel_link 200 201 def handle_file_delete(context, view, download_name): 202 """Handle deletion of student file. 203 204 """ 205 store = getUtility(IExtFileStore) 206 store.deleteFileByContext(context, attr=download_name) 207 view.flash('File %s deleted.' % download_name) 208 return 200 209 201 210 def handle_file_upload(upload, context, view, max_size, download_name=None): … … 248 257 download_name = u'filename.jpg' 249 258 259 @property 260 def file_exists(self): 261 image = getUtility(IExtFileStore).getFileByContext( 262 self.context, attr=self.download_name) 263 if image: 264 return True 265 else: 266 return False 267 250 268 class FileUpload(FileDisplay): 251 269 """Base upload viewlet. … … 262 280 def update(self): 263 281 self.max_upload_size = string_from_bytes(self.mus) 282 delete = self.request.form.get('delete', None) 283 if delete: 284 self.view.files_deleted += self.download_name 285 handle_file_delete( 286 context=self.context, view=self.view, 287 download_name=self.download_name) 288 self.view.redirect( 289 self.view.url(self.context, self.view.__name__)) 290 return 264 291 upload = self.request.form.get(self.input_name, None) 265 292 if upload:
Note: See TracChangeset for help on using the changeset viewer.