Changeset 5530 for main/waeup.sirp/branches/ulif-images/src/waeup
- Timestamp:
- 25 Sep 2010, 15:47:02 (14 years ago)
- Location:
- main/waeup.sirp/branches/ulif-images/src/waeup/sirp/jambtables
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-images/src/waeup/sirp/jambtables/applicants.py
r5483 r5530 28 28 IResultEntry, IApplicant, IApplicantContainer, IApplicantPDEEditData 29 29 ) 30 from waeup.sirp.widgets.passportwidget import PassportImage 30 31 31 32 class ResultEntry(grok.Context): … … 37 38 38 39 class Applicant(grok.Context): 40 # class Applicant(grok.Model): 39 41 grok.implements(IApplicant, IApplicantPDEEditData) 40 42 grok.provides(IApplicant) … … 105 107 self.import_from = None 106 108 109 class ApplicantTraverser(grok.Traverser): 110 grok.context(IApplicant) 111 def traverse(self, name): 112 passport_filename = self.context.passport.filename 113 print "FILENAME: ", passport_filename 114 if name == passport_filename: 115 print "USE FILE", self.context.passport 116 return self.context.passport 117 if name == 'passport.jpg': 118 if self.context.passport is not None: 119 print "PP: ", self.context.passport 120 return self.context.passport 121 return PassportImage(None) 122 107 123 class ApplicantFactory(grok.GlobalUtility): 108 124 """A factory for faculty containers. -
main/waeup.sirp/branches/ulif-images/src/waeup/sirp/jambtables/browser.py
r5488 r5530 24 24 import grok 25 25 26 from zope.formlib.widgets import FileWidget 26 27 from waeup.sirp.browser import ( 27 28 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, … … 33 34 from waeup.sirp.jambtables.interfaces import ( 34 35 IApplicant, IApplicantContainer, IApplicantPrincipal, IApplicantPDEEditData) 35 36 36 from waeup.sirp.widgets.passportwidget import ( 37 PassportWidget, PassportDisplayWidget 38 ) 37 39 #from zope.formlib.objectwidget import ObjectWidget 38 40 from zope.formlib.sequencewidget import ListSequenceWidget, SequenceDisplayWidget … … 43 45 from waeup.sirp.widgets.multilistwidget import ( 44 46 MultiListWidget, MultiListDisplayWidget) 47 from waeup.sirp.image.browser.widget import ( 48 ThumbnailWidget, EncodingImageFileWidget, 49 ) 45 50 46 51 results_widget = CustomWidgetFactory( … … 77 82 form_fields = grok.AutoFields(IApplicant) 78 83 form_fields['fst_sit_results'].custom_widget = list_results_widget 84 form_fields['passport'].custom_widget = EncodingImageFileWidget 79 85 label = 'Add Applicant' 80 86 title = 'Add Applicant' … … 100 106 form_fields = grok.AutoFields(IApplicant) 101 107 form_fields['fst_sit_results'].custom_widget = list_results_display_widget 108 #form_fields['passport'].custom_widget = PassportDisplayWidget 109 form_fields['passport'].custom_widget = ThumbnailWidget 102 110 label = 'Applicant' 103 111 title = 'Applicant' … … 108 116 grok.name('edit') 109 117 form_fields = grok.AutoFields(IApplicantPDEEditData) 118 #form_fields['passport'].custom_widget = FileWidget 119 #form_fields['passport'].custom_widget = PassportWidget 120 form_fields['passport'].custom_widget = EncodingImageFileWidget 110 121 grok.template('form_edit_pde') 111 122 123 def update(self): 124 super(EditApplicant, self).update() 125 print self.request.form 126 return 127 112 128 @property 113 129 def label(self): -
main/waeup.sirp/branches/ulif-images/src/waeup/sirp/jambtables/interfaces.py
r5486 r5530 22 22 """Interfaces for JAMB data tables and related components. 23 23 """ 24 from waeup.sirp.interfaces import IWAeUPObject 24 import os 25 import waeup.sirp.browser 26 from hurry.file import HurryFile 25 27 from zc.sourcefactory.basic import BasicSourceFactory 26 28 from zope import schema 29 from zope.app.file.interfaces import IImage 27 30 from zope.interface import Interface, Attribute 28 31 from zope.pluggableauth.interfaces import IPrincipalInfo 29 32 from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal 30 33 from waeup.sirp.interfaces import IWAeUPObject 34 from waeup.sirp.image.schema import ImageFile 35 36 IMAGE_PATH = os.path.join( 37 os.path.dirname(waeup.sirp.browser.__file__), 38 'static' 39 ) 40 DEFAULT_PASSPORT_IMAGE_MALE = HurryFile( 41 'passport.jpg', 42 open(os.path.join(IMAGE_PATH, 'placeholder_m.jpg')).read(), 43 ) 44 DEFAULT_PASSPORT_IMAGE_FEMALE = HurryFile( 45 'passport.jpg', 46 open(os.path.join(IMAGE_PATH, 'placeholder_f.jpg')).read(), 47 ) 31 48 32 49 class GenderSource(BasicSourceFactory): … … 179 196 required = False, 180 197 ) 181 passport = schema.Bool( 198 #passport = schema.Bool( 199 # title = u'Passport Photograph', 200 # default = True, 201 # required = False, 202 # ) 203 passport = ImageFile( 182 204 title = u'Passport Photograph', 183 default = True,184 required = False,205 default = DEFAULT_PASSPORT_IMAGE_MALE, 206 required = True, 185 207 ) 186 208 aos = schema.TextLine( … … 422 444 default = u'm', 423 445 ) 424 passport = schema.Bool( 446 #passport = schema.Bool( 447 # title = u'Passport Photograph', 448 # default = True, 449 # ) 450 passport = ImageFile( 425 451 title = u'Passport Photograph', 426 default = True, 452 default = DEFAULT_PASSPORT_IMAGE_MALE, 453 required = True, 427 454 ) 428 455 # … … 578 605 readonly = True, 579 606 ) 580 passport = schema.Bool( 607 #passport = schema.Bool( 608 # title = u'Passport Photograph', 609 # default = True, 610 # required = False, 611 # ), 612 #passport = schema.Bytes( 613 # title = u'Passport Photograph', 614 # required = True, 615 # ) 616 #passport = schema.Object( 617 # title = u'Passport Photograph', 618 # required = True, 619 # schema = IImage) 620 passport = ImageFile( 581 621 title = u'Passport Photograph', 582 default = True, 583 required = False, 584 ) 585 622 default = DEFAULT_PASSPORT_IMAGE_MALE, 623 required = True, 624 ) 586 625 587 626 class IApplicantPDEImportData(IApplicantBaseData):
Note: See TracChangeset for help on using the changeset viewer.