Changeset 3283


Ignore:
Timestamp:
7 Mar 2008, 16:37:05 (17 years ago)
Author:
joachim
Message:
  1. show --- as default, and dont edit when set
  2. show full filename
  3. check if upload-object exists, display error message, at the moment the
Location:
WAeUP_SRP/base/skins/waeup_upload
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_upload/uploads_form.pt

    r3277 r3283  
    4040            <td align="left" valign="middle" style="width: 5px;">
    4141              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
    42                      tal:define="id row/id"
     42                     tal:define="id string:${row/id}.csv"
    4343                     tal:attributes="value id;
    4444                     id python:'cb_' + id;
     
    4747            </td>
    4848            <td tal:condition="nothing"> <a href="view" tal:attributes="href string:${row/url}"> <span tal:content="row/id" /></a>  </td>
    49             <td tal:content="row/id" ></td>
     49            <td tal:content="string:${row/id}.csv" ></td>
    5050            <td>
    5151              <select name="import_layout:record" tal:attributes="name string:${row/id}.import_layout:record">
     
    6969              </span>
    7070            </td>
    71             <td tal:condition="nothing">
     71            <td tal:condition="python:0">
    7272            <a href="edit" tal:attributes="href string:${row/url}/external_edit_form"
    7373                target="edit"
  • WAeUP_SRP/base/skins/waeup_upload/uploads_index.py

    r3277 r3283  
    2525
    2626path_info = request.get('PATH_INFO').split('/')
    27 
     27NO_KEY = '----'
    2828info = {}
    2929info['action'] = "%s" % context.absolute_url()
     
    3636#set_trace()
    3737if edit and ids:
    38     for id in ids:
    39         doc = getattr(context, "%s.csv" % id).getContent()
    40         doc.edit(mapping = request.form[id])
     38    for long_id in ids:
     39        short_id = long_id.replace('.csv','')
     40        doc = getattr(context, long_id).getContent()
     41        doc.edit(mapping = request.form[short_id])
    4142        msg, invalid_keys = doc['checkKeys']()
    4243        new_keys = []
    4344        for key in invalid_keys:
    44             id_key = "%s|%s" % (id,key)
     45            id_key = "%s|%s" % (short_id,key)
    4546            if request.form.has_key(id_key):
    46                 new_keys += (key,request.form.get(id_key)['valid_key']),
     47                new_key = request.form.get(id_key)['valid_key']
     48                if new_key != NO_KEY:
     49                    new_keys += (key,new_key),
    4750        if new_keys:
    4851            doc.editHeadline(new_keys)
     
    5356    doc = upload.getContent()
    5457    row['valid_keys'] = doc['getKeys']()
     58    row['valid_keys'][0] = NO_KEY
    5559    row['id'] = id.replace('.csv','')
    5660    row['title'] = doc.filename
     
    7579                             commit = True,
    7680                            )
    77 if psm == 'invalid':
    78     return context.uploads_form(rendered = res,
    79                                  psm = "Please correct your input!",
    80                                  mode = mode,
    81                                  ds = ds,
    82                                  info = info,
    83                                 )
    84 elif psm == '':
     81while True:
     82    if psm == 'invalid':
     83        psm = "Please correct your input!"
     84    # return context.uploads_form(rendered = res,
     85    #                              psm = "Please correct your input!",
     86    #                              mode = mode,
     87    #                              ds = ds,
     88    #                              info = info,
     89    #                             )
     90    elif psm == 'valid':
     91        filename = ds['upload_file'].filename
     92        if filename not in context.objectIds():
     93            break
     94        psm = "Upload file exists"
    8595    return context.uploads_form(rendered = res,
    8696                                        psm = psm,
     
    8999                                        info = info,
    90100                                       )
    91 elif psm == 'valid':
    92     pass
    93 filename = ds['upload_file'].filename
    94101
    95 if filename not in context.objectIds():
    96     context.invokeFactory('Upload',filename)
    97     upload = getattr(context,filename)
    98     d = {}
    99     d['filename'] = d['id'] = filename
    100     d['upload_date'] =  DateTime.DateTime()
    101     d['import_layout'] = ds.get('import_layout','')
    102     d['uploaded_by'] = str(member)
    103     d['url'] = upload.absolute_url()
    104     upload.getContent().edit(mapping=d)
    105     #info['items'].append(d)
     102context.invokeFactory('Upload',filename)
     103upload = getattr(context,filename)
     104d = {}
     105d['filename'] = d['id'] = filename
     106d['upload_date'] =  DateTime.DateTime()
     107d['import_layout'] = ds.get('import_layout','')
     108d['uploaded_by'] = str(member)
     109d['url'] = upload.absolute_url()
     110upload.getContent().edit(mapping=d)
     111
    106112request.RESPONSE.redirect(context.absolute_url())   
    107113
  • WAeUP_SRP/base/skins/waeup_upload/widget_uploadfile_render.pt

    r3277 r3283  
    7272                 id string:${radio_name}_change"
    7373                 />
    74           <label i18n:translate="cpsschemas_label_file_change"
    75                  tal:attributes="for string:${radio_name}_change">Change</label>
    7674          <input type="file" name="." size="24"
    7775                 tal:attributes="name name;
Note: See TracChangeset for help on using the changeset viewer.