Changeset 3292
- Timestamp:
- 9 Mar 2008, 12:47:17 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/Upload.py
r3277 r3292 63 63 def checkKeys(self): 64 64 """check fields in csv-headline""" 65 csv_path = os.path.join(storage_path,self.filename) 65 doc = self.getContent() 66 csv_path = os.path.join(storage_path,doc.filename) 66 67 importer_name = ''.join([part.capitalize() for part in self.getContent().import_layout.split('_')]) 67 68 importer = eval("%sImport" % importer_name)(self) … … 69 70 invalid_keys = [] 70 71 if not os.path.exists(csv_path): 71 msg = 'No such file %(csv_path)s' % vars() 72 base,ext = os.path.splitext(csv_path) 73 if os.path.exists("%(base)s.done" % vars()): 74 #import pdb;pdb.set_trace() 75 #msg = "imported" 76 pass 77 else: 78 base_path = os.path.split(csv_path)[1] 79 msg = 'No such file %(base_path)s' % vars() 72 80 else: 73 81 headline = csv.reader(open(csv_path,"rb")).next() … … 79 87 return msg,invalid_keys 80 88 81 security.declareProtected(View," checkFields") ###(89 security.declareProtected(View,"getFields") ###( 82 90 def getKeys(self): 83 91 """return the valid keys for headline""" … … 87 95 keys.sort() 88 96 return keys 97 ###) 89 98 99 security.declareProtected(View,"getUploadFileInfo") ###( 100 def getUploadFileInfo(self): 101 """return the valid keys for headline""" 102 doc = self.getContent() 103 return os.stat(os.path.join(storage_path,doc.filename)) 104 90 105 security.declareProtected(ModifyPortalContent,"editHeadline") ###( 91 106 def editHeadline(self,key_pairs): -
WAeUP_SRP/base/WAeUPImport.py
r3277 r3292 137 137 ###) 138 138 139 def checkHeadline(self,headline): 139 def checkHeadline(self,headline): ###( 140 140 """ check the headline of an csv.file """ 141 141 import_keys = [k.strip() for k in headline if not (k.strip().startswith('ignore') … … 147 147 return list(diff2schema) 148 148 return [] 149 ###) 149 150 ###) 150 151 -
WAeUP_SRP/base/WAeUPTool.py
r3277 r3292 52 52 import csv,re,os,sys 53 53 import md5 54 from shutil import copy2 54 from shutil import copy2,copy 55 55 from Products.AdvancedQuery import Eq, Between, Le,In 56 56 … … 1388 1388 import random 1389 1389 students_folder = self.portal_url.getPortalObject().campus.students 1390 uploads_folder = self.portal_url.getPortalObject().campus.uploads 1390 1391 pending_only = False 1391 1392 pend_str = '--' … … 1456 1457 total_added_to_imported = 0 1457 1458 total_pending = 0 1459 import_source_done = "" 1458 1460 if pending_only: 1459 1461 import_source_path = pending_path 1460 1462 else: 1461 1463 import_source_path = "%s/import/%s.csv" % (i_home,filename) 1464 import_source_done = "%s/import/%s.done" % (i_home,filename) 1462 1465 if not os.path.exists(import_source_path): 1463 1466 fn = os.path.split(import_source_path)[1] … … 1626 1629 #msg += "%(total_pending)d totally written" % vars() # this line does not make any sense 1627 1630 logger.info(msg) 1631 if import_source_done: 1632 copy(import_source_path,import_source_done) 1633 os.remove(import_source_path) 1634 upload = getattr(uploads_folder,os.path.split(import_source_path)[1],None) 1635 if upload is not None: 1636 upload_doc = upload.getContent() 1637 mapping = {} 1638 mapping['imported_at'] = DateTime.DateTime() 1639 mapping['import_message'] = msg 1640 upload_doc.edit(mapping = mapping) 1628 1641 os.remove(pending_tmp) 1629 1642 return msg 1630 1643 ###) 1631 1632 1633 1644 1634 1645 security.declareProtected(ModifyPortalContent,"moveImagesToFS")###( -
WAeUP_SRP/base/skins/waeup_upload/uploads_form.pt
r3291 r3292 1 1 <metal:html tal:define="info options/info; 2 portal_status_message options/psm ;2 portal_status_message options/psm|request/portal_status_message; 3 3 ds options/ds; 4 4 mode options/mode; … … 23 23 class="destructive" /> 24 24 </form> 25 <form action="" method="post" class="group" 26 tal:attributes="action info/action" 27 tal:define="rows python: info['items'];" 28 > 29 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 30 <tr> 31 <th></th> 32 <th>Filename</th> 33 <th>Data Layout</th> 34 <th>By</th> 35 <th>Date</th> 36 <th>Message</th> 37 <th>Unknown Fields</th> 38 </tr> 39 <tr tal:repeat="row rows" 40 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 41 <td align="left" valign="middle" style="width: 5px;"> 42 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 43 tal:define="id string:${row/id}.csv" 44 tal:attributes="value id; 45 id python:'cb_' + id; 46 checked python:id in info['choosen_ids'];" 47 /> 48 </td> 49 <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a> </td> 50 <td tal:content="string:${row/id}.csv" ></td> 51 <td> 52 <select name="import_layout:record" tal:attributes="name string:${row/id}.import_layout:record"> 53 <option tal:repeat="option python: context.portal_vocabularies.import_names.items()" 54 tal:attributes="value python: option[0]; 55 selected python: option[0] == row['import_layout']" 56 tal:content="python:option[1]" /> 57 </select> 58 </td> 59 <td tal:content="row/uploaded_by" ></td> 60 <td tal:content="row/upload_date" ></td> 61 <td tal:content="row/msg" ></td> 62 <td> 63 <div tal:repeat="key row/invalid_keys"> 64 <span tal:replace="key" /><br /> 65 <select tal:attributes="name string:${row/id}|${key}.valid_key:record"> 66 <option tal:repeat="new row/valid_keys" 67 tal:attributes="value new" 68 tal:content="new" /> 25 <span tal:condition="info/wrong"> 26 <h2>Uploads which must be corrected:</h2> 27 <form action="" method="post" class="group" 28 tal:attributes="action info/action" 29 > 30 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 31 <tr> 32 <th></th> 33 <th>Filename</th> 34 <th>Data Layout</th> 35 <th>By</th> 36 <th>Date</th> 37 <th>Message</th> 38 <th>Unknown Fields</th> 39 </tr> 40 <tr tal:repeat="row info/wrong" 41 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 42 <td align="left" valign="middle" style="width: 5px;"> 43 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 44 tal:define="id string:${row/id}.csv" 45 tal:attributes="value id; 46 id python:'cb_' + id; 47 checked python:id in info['choosen_ids'];" 48 /> 49 </td> 50 <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a> </td> 51 <td tal:content="string:${row/id}.csv" ></td> 52 <td> 53 <select name="import_layout:record" tal:attributes="name string:${row/id}.import_layout:record"> 54 <option tal:repeat="option python: context.portal_vocabularies.import_names.items()" 55 tal:attributes="value python: option[0]; 56 selected python: option[0] == row['import_layout']" 57 tal:content="python:option[1]" /> 69 58 </select> 70 </div> 71 </td> 72 <td tal:condition="python:0"> 73 <a href="edit" tal:attributes="href string:${row/url}/external_edit_form" 74 target="edit" 75 onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"> 76 [edit] 59 </td> 60 <td tal:content="row/uploaded_by" ></td> 61 <td tal:content="row/upload_date" ></td> 62 <td tal:content="row/msg" ></td> 63 <td> 64 <div tal:repeat="key row/invalid_keys"> 65 <span tal:replace="key" /><br /> 66 <select tal:attributes="name string:${row/id}|${key}.valid_key:record"> 67 <option tal:repeat="new row/valid_keys" 68 tal:attributes="value new" 69 tal:content="new" /> 70 </select> 71 </div> 72 </td> 73 <td tal:condition="python:0"> 74 <a href="edit" tal:attributes="href string:${row/url}/external_edit_form" 75 target="edit" 76 onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"> 77 [edit] 77 78 </a> 78 </td> 79 80 </tr> 81 </table> 82 83 <br /> 84 85 <input tal:condition="nothing" type="button" value="button_select_all" class="context" 86 onclick="someJavaScriptFunctionThatWillBeReplaced" 87 i18n:attributes="value" 88 tal:attributes="onclick python:'toggleSelect(this, \'%s\', \'%s\')' 89 % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))" 90 /> 91 <input type="submit" name="edit" value="Edit" 92 class="destructive" i18n:attributes="value" 93 /> 94 <input type="submit" name="folder_delete:method" value="button_delete" 95 class="destructive" i18n:attributes="value" 96 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 97 (cpsmcat('description_confirm_delete'), )" 98 /> 99 100 </form> 79 </td> 80 </tr> 81 </table> 82 <br /> 83 <input tal:condition="nothing" type="button" value="button_select_all" class="context" 84 onclick="someJavaScriptFunctionThatWillBeReplaced" 85 i18n:attributes="value" 86 tal:attributes="onclick python:'toggleSelect(this, \'%s\', \'%s\')' 87 % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))" 88 /> 89 <input type="submit" name="edit" value="edit" 90 class="destructive" i18n:attributes="value" 91 /> 92 <input type="submit" name="folder_delete:method" value="button_delete" 93 class="destructive" i18n:attributes="value" 94 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 95 (cpsmcat('description_confirm_delete'), )" 96 /> 97 </form> 98 </span> 99 <span tal:condition="info/importable"> 100 <h2>Importable Uploads:</h2> 101 <form action="" method="post" class="group" 102 tal:attributes="action info/action" 103 > 104 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 105 <tr> 106 <th></th> 107 <th>Filename</th> 108 <th>Data Layout</th> 109 <th>By</th> 110 <th>Date</th> 111 </tr> 112 <tr tal:repeat="row info/importable" 113 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 114 <td align="left" valign="middle" style="width: 5px;"> 115 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 116 tal:define="id string:${row/id}.csv" 117 tal:attributes="value id; 118 id python:'cb_' + id; 119 checked python:id in info['choosen_ids'];" 120 /> 121 </td> 122 <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a> </td> 123 <td tal:content="string:${row/id}.csv" ></td> 124 <td tal:content="row/import_layout"></td> 125 <td tal:content="row/uploaded_by" ></td> 126 <td tal:content="row/upload_date" ></td> 127 <td tal:content="row/msg" ></td> 128 </tr> 129 </table> 130 <br /> 131 <input tal:condition="nothing" type="button" value="button_select_all" class="context" 132 onclick="someJavaScriptFunctionThatWillBeReplaced" 133 i18n:attributes="value" 134 tal:attributes="onclick python:'toggleSelect(this, \'%s\', \'%s\')' 135 % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))" 136 /> 137 <input type="submit" name="import_uploads:method" value="import" 138 class="destructive" i18n:attributes="value" 139 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 140 (cpsmcat('description_confirm_delete'), )" 141 /> 142 <input type="submit" name="folder_delete:method" value="button_delete" 143 class="destructive" i18n:attributes="value" 144 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 145 (cpsmcat('description_confirm_delete'), )" 146 /> 147 </form> 148 </span> 149 <span tal:condition="info/imported"> 150 <h2>Imported Uploads:</h2> 151 <form action="" method="post" class="group" 152 tal:attributes="action info/action" 153 > 154 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 155 <tr> 156 <th>Filename</th> 157 <th>Data Layout</th> 158 <th>By</th> 159 <th>Date</th> 160 <th>Import Date</th> 161 <th>Message</th> 162 </tr> 163 <tr tal:repeat="row info/imported" 164 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 165 <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a> </td> 166 <td tal:content="string:${row/id}.done" ></td> 167 <td tal:content="row/import_layout"></td> 168 <td tal:content="row/uploaded_by" ></td> 169 <td tal:content="row/upload_date" ></td> 170 <td tal:content="row/imported_at" ></td> 171 <td tal:content="row/msg"></td> 172 </tr> 173 </table> 174 </form> 175 </span> 101 176 </metal:main> 102 103 177 <metal:sub fill-slot="sub"/> 104 178 </metal:body> -
WAeUP_SRP/base/skins/waeup_upload/uploads_index.py
r3291 r3292 1 ## Script (Python) " getUploadsInfo"1 ## Script (Python) "uploads_index" 2 2 ##bind container=container 3 3 ##bind context=context … … 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= student=None7 ##parameters= 8 8 ##title= 9 9 ## 10 # $Id: getUploadsInfo.py 486 2006-09-06 10:09:39Z joachim $10 # $Id:uploads_index.py 486 2006-09-06 10:09:39Z joachim $ 11 11 """ 12 12 return Info about the Uploads … … 35 35 info['doc'] = context.getContent() 36 36 37 items = []38 37 edit = request.form.has_key('edit') 39 38 ids = request.get('ids',[]) … … 59 58 request.RESPONSE.redirect(context.absolute_url()) 60 59 60 wrong = [] 61 imported = [] 62 importable = [] 61 63 for id,upload in context.objectItems(): 64 add_to = wrong 62 65 row = {} 63 66 doc = upload.getContent() … … 67 70 row['title'] = doc.filename 68 71 row['url'] = upload.absolute_url() 69 row['msg'], row['invalid_keys'] = doc['checkKeys']() 72 row['imported'] = False 73 row['invalid_keys'] = [] 74 import_message = getattr(doc,'import_message','') 75 if import_message: 76 row['imported'] = True 77 row['msg'] = import_message 78 row['imported_at'] = doc.imported_at.strftime("%d/%m/%y %H:%M:%S") 79 add_to = imported 80 else: 81 row['msg'],row['invalid_keys'] = doc['checkKeys']() 82 if not row['msg'] and not row['invalid_keys']: 83 add_to = importable 70 84 row['filename'] = doc.filename 71 85 row['import_layout'] = doc.import_layout 72 86 row['upload_date'] = doc.upload_date.strftime("%d/%m/%y %H:%M:%S") 73 87 row['uploaded_by'] = doc.uploaded_by 74 items.append(row) 75 items.sort() 76 info['items'] = items 88 add_to.append(row) 89 wrong.sort() 90 imported.sort() 91 importable.sort() 92 info['wrong'] = wrong 93 info['imported'] = imported 94 info['importable'] = importable 77 95 78 96 validate = "upload" in request.keys() -
WAeUP_SRP/uniben/profiles/default/schemas/upload.xml
r3285 r3292 7 7 <field name="uploaded_by" meta_type="CPS String Field"/> 8 8 <field name="import_date" meta_type="CPS DateTime Field"/> 9 <field name="import_message" meta_type="CPS String Field"/> 9 10 </object>
Note: See TracChangeset for help on using the changeset viewer.