Changeset 9023


Ignore:
Timestamp:
19 Jul 2012, 10:32:40 (12 years ago)
Author:
Henrik Bettermann
Message:

Give access to processed (finished) import files.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/batchprocessing.txt

    r8976 r9023  
    619619    'users_zope.mgr.create.finished.csv', 'users_zope.mgr.csv']
    620620
     621Processed (finished) Files
     622==========================
     623
     624    >>> browser.open('http://localhost/app/datacenter/processed')
     625    >>> '<a href="download?filename=finished/certificates_zope.mgr.csv">' in browser.contents
     626    True
    621627
    622628Log Files
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r9011 r9023  
    810810        return
    811811
     812class DatacenterFinishedPage(KofaEditFormPage):
     813    grok.context(IDataCenter)
     814    grok.name('processed')
     815    grok.require('waeup.manageDataCenter')
     816    label = _(u'Processed Files')
     817    pnav = 0
     818
     819    def update(self):
     820        datatable.need()
     821        return super(DatacenterFinishedPage, self).update()
     822
    812823class DatacenterUploadPage(KofaPage):
    813824    grok.context(IDataCenter)
     
    898909
    899910    def getFiles(self):
    900         files = self.context.getFiles(sort='date')
     911        files = self.context.getPendingFiles(sort='date')
    901912        for file in files:
    902913            name = file.name
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/datacenterpage.pt

    r8366 r9023  
    2121      </thead>
    2222      <tbody>
    23         <tr tal:repeat="file context/getFiles" class="gradeC">
     23        <tr tal:repeat="file context/getPendingFiles" class="gradeC">
    2424          <td>
    2525            <input type="checkbox" name="val_id"
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r8920 r9023  
    386386    grok.require('waeup.manageDataCenter')
    387387    text = _('Edit settings')
     388    grok.order(1)
    388389
    389390class ManageFacultiesContainerActionButton(ManageActionButton):
     
    458459    text = _('Edit certificate course')
    459460
    460 #
    461 # Add actions...
    462 #
    463 
    464461class AddUserActionButton(AddActionButton):
    465462    grok.require('waeup.manageUsers')
     
    468465    text = _('Add user')
    469466
    470 #
    471 # Actions with a 'browse' icon...
    472 #
    473 class BrowseActionButton(ActionButton):
    474     grok.baseclass()
    475     grok.context(IKofaObject)
    476     grok.template('actionbutton')
    477     grok.viewletmanager(ActionBar)
     467class BrowseDatacenterLogs(ActionButton):
     468    grok.context(IDataCenter)
    478469    grok.require('waeup.manageDataCenter')
    479     icon = 'actionicon_manage.png' # File must exist in static/
    480     target = '@@show' # link to this viewname.
    481     text = _('Show logs') # Text to display on the button
    482 
    483 class BrowseDatacenterLogs(BrowseActionButton):
    484     grok.context(IDataCenter)
    485470    grok.view(DatacenterPage)
    486     grok.order(4)
     471    grok.order(2)
    487472    icon = 'actionicon_info.png'
    488473    target = '@@logs'
    489474    text = _('Show logs')
    490475
    491 #
    492 # Misc. buttons...
    493 #
     476class UploadCSVButton(ActionButton):
     477    grok.context(IDataCenter)
     478    grok.view(DatacenterPage)
     479    grok.require('waeup.manageDataCenter')
     480    grok.order(3)
     481    icon = 'actionicon_up.png'
     482    target = '@@upload'
     483    text = _('Upload CSV file')
     484
    494485class BatchOpButton(ActionButton):
    495486    grok.context(IDataCenter)
    496487    grok.view(DatacenterPage)
    497488    grok.require('waeup.importData')
    498     grok.order(6)
     489    grok.order(4)
    499490    icon = 'actionicon_gear.png'
    500491    target = '@@import1'
    501492    text = _('Batch processing')
    502493
    503 class UploadCSVButton(ActionButton):
     494class ExportCSVButton(ActionButton):
    504495    grok.context(IDataCenter)
    505496    grok.view(DatacenterPage)
    506497    grok.require('waeup.manageDataCenter')
    507498    grok.order(5)
    508     icon = 'actionicon_up.png'
    509     target = '@@upload'
    510     text = _('Upload CSV file')
    511 
    512 class ExportCSVButton(ActionButton):
    513     grok.context(IDataCenter)
    514     grok.view(DatacenterPage)
    515     grok.require('waeup.manageDataCenter')
    516     grok.order(7)
    517499    icon = 'actionicon_down.png'
    518500    target = '@@export'
    519501    text = _('Export CSV file')
     502
     503class BrowseFinishedFiles(ActionButton):
     504    grok.context(IDataCenter)
     505    grok.require('waeup.manageDataCenter')
     506    grok.view(DatacenterPage)
     507    grok.order(6)
     508    icon = 'actionicon_finished.png'
     509    target = '@@processed'
     510    text = _('Processed Files')
    520511
    521512#
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py

    r9008 r9023  
    6666        return os.path.join(self.storage, 'deleted')
    6767
    68     def getFiles(self, sort='name'):
     68    def getPendingFiles(self, sort='name'):
    6969        """Get a list of files stored in `storage`.
    7070
     
    8181                continue
    8282            result.append(DataCenterFile(fullpath))
     83        if sort == 'date':
     84            # sort results in newest-first order...
     85            result = sorted(result, key=lambda x: x.getTimeStamp(),
     86                            reverse=True)
     87        return result
     88
     89    def getFinishedFiles(self, sort='name'):
     90        """Get a list of files stored in `finished` subfolder of `storage`.
     91
     92        Files are sorted by basename.
     93        """
     94        result = []
     95        finished_dir = os.path.join(self.storage, 'finished')
     96        if not os.path.exists(finished_dir):
     97            return result
     98        for filename in sorted(os.listdir(finished_dir)):
     99            fullpath = os.path.join(finished_dir, filename)
     100            if not os.path.isfile(fullpath):
     101                continue
     102            if not filename.endswith('.csv'):
     103                continue
     104            result.append(DataCenterFile(fullpath, 'finished'))
    83105        if sort == 'date':
    84106            # sort results in newest-first order...
     
    300322    grok.implements(IDataCenterFile)
    301323
    302     def __init__(self, context):
     324    def __init__(self, context, folder_name=''):
    303325        self.context = context
    304326        self.name = os.path.basename(self.context)
     327        self.rel_path = os.path.join(folder_name, self.name)
    305328        self.size = self.getSize()
    306329        self.uploaddate = self.getDate()
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.txt

    r8398 r9023  
    8383We can get a list of files stored in that location:
    8484
    85     >>> mydatacenter.getFiles()
     85    >>> mydatacenter.getPendingFiles()
    8686    []
    8787
     
    9494Now we can find a file:
    9595
    96     >>> mydatacenter.getFiles()
     96    >>> mydatacenter.getPendingFiles()
    9797    [<waeup.kofa.datacenter.DataCenterFile object at 0x...>]
    9898
     
    102102pages:
    103103
    104     >>> datafile = mydatacenter.getFiles()[0]
     104    >>> datafile = mydatacenter.getPendingFiles()[0]
    105105    >>> datafile.getSize()
    106106    '13 bytes'
     
    272272finished-subdirectory remain.
    273273
     274
     275We can get a list of imported files stored in the finished subfolder:
     276
     277    >>> mydatacenter.getFinishedFiles()
     278    [<waeup.kofa.datacenter.DataCenterFile object at ...>, <waeup.kofa.datacenter.DataCenterFile object at ...>]
     279
     280    >>> datafile = mydatacenter.getFinishedFiles()[0]
     281    >>> datafile.getSize()
     282    '2 bytes'
     283
     284    >>> datafile.getDate() # Nearly current datetime...
     285    '...'
     286
     287
    274288Clean up:
    275289
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r8948 r9023  
    641641        )
    642642
    643     def getFiles(sort='name'):
     643    def getPendingFiles(sort='name'):
    644644        """Get a list of files stored in `storage` sorted by basename.
    645645        """
     646
     647    def getFinishedFiles(sort='name'):
     648        """Get a list of files stored in `finished` subfolder of `storage`
     649        sorted by basename.
     650        """
     651
    646652    def setStoragePath(path, move=False, overwrite=False):
    647653        """Set the path where to store files.
Note: See TracChangeset for help on using the changeset viewer.