Changeset 2342
- Timestamp:
- 10 Oct 2007, 15:43:43 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTool.py
r2335 r2342 695 695 picture_path = os.path.join(i_home,path) 696 696 response = self.REQUEST.RESPONSE 697 #import pdb;pdb.set_trace() 697 698 if os.path.exists(picture_path): 698 699 response.setHeader('Content-type','image/jpeg') -
WAeUP_SRP/base/Widgets.py
r2336 r2342 1335 1335 reference = '' 1336 1336 1337 def prepare(self, datastructure, **kw): ###( 1338 """Prepare datastructure from datamodel.""" 1339 datamodel = datastructure.getDataModel() 1340 v = datamodel[self.fields[0]] 1341 widget_id = self.getWidgetId() 1342 if v and type(v) is StringType: 1343 try: 1344 p,b,n = v.split('-') 1345 v = ScratchCardPin(p,b,n) 1346 except ValueError: 1347 v = ScratchCardPin(v,'','') 1348 if v: 1349 p = '%s' % v.p 1350 b = '%s' % v.b 1351 n = '%s' % v.n 1352 else: 1353 p = self.prefix 1354 if p.startswith('@'): 1355 p = getattr(self,self.prefix[1:])() 1356 b = n = '' 1357 v = ScratchCardPin(p,b,n) 1358 datastructure[widget_id] = v 1359 datastructure[widget_id+'_p'] = p 1360 datastructure[widget_id+'_b'] = b 1361 datastructure[widget_id+'_n'] = n 1362 screening_type = datamodel.get('screening_type',None) 1363 if screening_type is None: 1364 screening_type = self.REQUEST.form.get('screening_type','unknown') 1365 datastructure["screening_type"] = screening_type 1366 ###) 1367 1337 1368 def validate(self, datastructure, **kw): ###( 1338 1369 """Validate datastructure and update datamodel.""" … … 1396 1427 break 1397 1428 if ok >= 1: 1398 screening_type = self.REQUEST.form.get('screening_type','unknown') 1429 #screening_type = self.REQUEST.form.get('screening_type','unknown') 1430 screening_type = datastructure['screening_type'] 1399 1431 if self.isStudent(): 1400 1432 err = "This is only for Pume application." … … 1504 1536 ###) 1505 1537 1506 class NoZodbImageWidget(CPSImageWidget): ###(1538 class ApplicationImageWidget(CPSImageWidget): ###( 1507 1539 """Image widget with filesystem storage.""" 1508 meta_type = ' No ZodbImage Widget'1540 meta_type = 'Application Image Widget' 1509 1541 _properties = CPSImageWidget._properties +\ 1510 1542 ( … … 1520 1552 def getImageInfo(self, datastructure): ###( 1521 1553 """Get the file info from the datastructure.""" 1522 #import pdb; pdb.set_trace()1523 1554 widget_id = self.getWidgetId() 1524 1555 if datastructure.has_key(widget_id): … … 1526 1557 dm = datastructure.getDataModel() 1527 1558 field_id = self.fields[0] 1528 content_url = "/viewimage?path=%s/%s_%s.jpg" %\ 1529 (self.path, 1530 datastructure[self.id_field], 1531 self.getWidgetId(), 1532 ) 1559 screening_type = datastructure.get('screening_type') 1533 1560 current_filename = "%s_%s.jpg" % (datastructure[self.id_field], 1534 1561 field_id,) 1535 file_path = "/%s/%s" % (self.storage_path, 1536 current_filename) 1562 base_path = os.path.join(screening_type,current_filename) 1563 content_url = os.path.join('viewimage',self.path,base_path) 1564 file_path = os.path.join(self.storage_path,base_path) 1565 #import pdb; pdb.set_trace() 1537 1566 else: 1538 1567 file_path = "XXX" … … 1610 1639 ###) 1611 1640 1612 1613 1641 def checkFileName(self, filename, mimetype): 1614 1642 return '', {} … … 1625 1653 if self.allow_resize: 1626 1654 datastructure[self.getWidgetId() + '_resize'] = '' 1655 screening_type = datamodel.get('screening_type',None) 1656 if not screening_type: 1657 screening_type = self.REQUEST.form.get('screening_type','pume') 1658 datastructure["screening_type"] = screening_type 1627 1659 datastructure[widget_id] = file_name 1628 1660 datastructure[widget_id + '_choice'] = 'change' … … 1634 1666 """Update datamodel from user data in datastructure. 1635 1667 """ 1636 logger = logging.getLogger('Widgets. NoZodbImageWidget.validate')1668 logger = logging.getLogger('Widgets.ApplicationImageWidget.validate') 1637 1669 datamodel = datastructure.getDataModel() 1638 1670 field_id = self.fields[0] … … 1694 1726 if is_upload and store: 1695 1727 ext ='jpg' 1728 screening_type = datastructure.get('screening_type') 1696 1729 filename = "%s_%s.%s" % (datastructure[self.id_field], 1697 self.getWidgetId(),1698 ext)1730 self.getWidgetId(), 1731 ext) 1699 1732 datamodel[field_id] = filename 1700 1733 registry = getToolByName(self, 'mimetypes_registry') … … 1702 1735 if mimetype is not None: 1703 1736 mimetype = str(mimetype) # normalize 1704 # Set/update data1705 # file_path = "%s_%s.jpg" % (datamodel[self.id_field],1706 # field_id,)1707 full_path = "%s/%s" % (self.storage_path, filename)1708 #import pdb; pdb.set_trace()1709 1737 file = self.makeFile(filename, fileupload, datastructure) 1710 1738 # Fixup mimetype … … 1712 1740 file.content_type = mimetype 1713 1741 # Store the file in the filesystem 1714 if not os.path.exists(self.storage_path):1715 os.mkdir(self.storage_path)1716 1742 #import pdb;pdb.set_trace() 1743 base_path = os.path.join(self.storage_path, screening_type) 1744 if not os.path.exists(base_path): 1745 os.mkdir(base_path) 1746 full_path = os.path.join(base_path, file_name) 1717 1747 pict = open(full_path,"w") 1718 1748 fileupload.seek(0) … … 1735 1765 ###) 1736 1766 1737 InitializeClass( NoZodbImageWidget)1738 1739 widgetRegistry.register( NoZodbImageWidget)1767 InitializeClass(ApplicationImageWidget) 1768 1769 widgetRegistry.register(ApplicationImageWidget) 1740 1770 ###) 1741 1771 … … 1749 1779 {'id': 'id_field', 'type': 'string', 'mode': 'w', 1750 1780 'label': 'Field to build the id'}, 1781 {'id': 'show_image', 'type': 'boolean', 'mode': 'w', 1782 'label': 'Show Image'}, 1751 1783 ) 1752 1784 path = "images" 1753 1785 storage_path = "%s/%s" % (i_home,path) 1754 1786 id_field = "" 1755 1787 show_image = False 1788 1756 1789 def getImageInfo(self, datastructure): ###( 1757 1790 """Get the file info from the datastructure.""" … … 1851 1884 image_info['width'] = width 1852 1885 image_info['image_tag'] = tag 1886 image_info['show_image'] = self.show_image 1853 1887 return image_info 1854 1888 ###) … … 1985 2019 render_method = 'widget_image_render' 1986 2020 meth = getattr(self, render_method, None) 2021 #import pdb;pdb.set_trace() 1987 2022 if meth is None: 1988 2023 raise RuntimeError("Unknown Render Method %s for widget type %s" -
WAeUP_SRP/base/skins/cps_custom/widget_image_render.pt
r2332 r2342 1 1 <tal:block define="mode options/mode; 2 id here/getWidgetId;3 fields here/fields;4 current_filename options/current_filename;5 empty_file options/empty_file;6 session_file options/session_file;7 mimetype options/mimetype;8 size options/size;9 content_url options/content_url;10 last_modified options/last_modified;11 content_url_nocache string:${content_url}?nocache=${last_modified};12 image_width options/width;13 image_height options/height;14 image_tag options/image_tag;15 ">16 <span tal:condition="python:0">17 < img tal:condition="python: mode == 'view' and not empty_file"18 tal:replace="structure image_tag" />19 </span>20 <span tal:condition="python: mode == 'view' and not empty_file">21 <a href="" target="_new"22 tal:attributes="href content_url"23 tal:content="current_filename" >24 </a>25 </span>26 2 id here/getWidgetId; 3 fields here/fields; 4 current_filename options/current_filename; 5 empty_file options/empty_file; 6 session_file options/session_file; 7 mimetype options/mimetype; 8 size options/size; 9 content_url options/content_url; 10 last_modified options/last_modified; 11 content_url_nocache string:${content_url}?nocache=${last_modified}; 12 image_width options/width; 13 image_height options/height; 14 image_tag options/image_tag; 15 show_image options/show_image|nothing;" 16 > 17 <span tal:condition="python: mode == 'view' and not empty_file" tal:omit-tag=""> 18 <img tal:condition="python: show_image" 19 tal:replace="structure image_tag" /> 20 <span tal:condition="python: not show_image" tal:omit-tag=""> 21 <a href="" target="_new" 22 tal:attributes="href content_url" 23 tal:content="current_filename" > 24 </a> 25 </span> 26 </span> 27 27 <tal:block condition="python: mode == 'edit'"> 28 28 -
WAeUP_SRP/uniben/profiles/default/layouts/application_manage.xml
r2327 r2342 324 324 <property name="css_class_expr">string:row</property> 325 325 </widget> 326 <widget name="passport" meta_type=" No ZodbImage Widget">326 <widget name="passport" meta_type="Application Image Widget"> 327 327 <property name="title">Passport Photograph</property> 328 328 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pce.xml
r2321 r2342 324 324 <property name="css_class_expr">string:row</property> 325 325 </widget> 326 <widget name="passport" meta_type=" No ZodbImage Widget">326 <widget name="passport" meta_type="Application Image Widget"> 327 327 <property name="title">Passport Photograph</property> 328 328 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pde.xml
r2341 r2342 388 388 <property name="css_class_expr">string:row</property> 389 389 </widget> 390 <widget name="passport" meta_type=" No ZodbImage Widget">390 <widget name="passport" meta_type="Application Image Widget"> 391 391 <property name="title">Passport Photograph</property> 392 392 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_prence.xml
r2330 r2342 360 360 <property name="css_class_expr">string:row</property> 361 361 </widget> 362 <widget name="passport" meta_type=" No ZodbImage Widget">362 <widget name="passport" meta_type="Application Image Widget"> 363 363 <property name="title">Passport Photograph</property> 364 364 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/application_pume.xml
r2321 r2342 326 326 <property name="css_class_expr">string:row</property> 327 327 </widget> 328 <widget name="passport" meta_type=" No ZodbImage Widget">328 <widget name="passport" meta_type="Application Image Widget"> 329 329 <property name="title">Passport Photograph</property> 330 330 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/student_application.xml
r2338 r2342 274 274 <property name="display_width">150</property> 275 275 <property name="display_height">200</property> 276 </widget> 276 <property name="show_image">True</property> 277 </widget> 277 278 <table> 278 279 <row> -
WAeUP_SRP/uniben/profiles/default/layouts/student_application_fe.xml
r2338 r2342 263 263 <property name="display_height">200</property> 264 264 <property name="allow_resize">True</property> 265 <property name="show_image">True</property> 265 266 </widget> 266 267 <table>
Note: See TracChangeset for help on using the changeset viewer.