Ignore:
Timestamp:
5 Jan 2010, 11:32:48 (15 years ago)
Author:
uli
Message:

Remove viewing components from datacenter. Everything went to browser
subpackage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/datacenter.py

    r4669 r4682  
    205205        return size
    206206
    207 
    208 class Content(grok.Viewlet):
    209     grok.viewletmanager(MainArea)
    210     grok.context(IDataCenter)
    211     grok.view(Index)
    212 
    213 class Upload(grok.View):
    214     grok.context(IDataCenter)
    215     grok.name('upload')
    216     grok.template('master')
    217 
    218     def update(self, uploadfile=None, CANCEL=None, SUBMIT=None):
    219         if CANCEL is not None:
    220             self.redirect(self.url(self.context))
    221             return
    222         if not uploadfile:
    223             return
    224         try:
    225             filename = uploadfile.filename
    226             target = os.path.join(self.context.storage, filename)
    227             open(target, 'wb').write(uploadfile.read())
    228         except IOError:
    229             self.flash('Error while uploading file. Please retry.')
    230             self.flash('I/O error: %s' % sys.exc_info()[1])
    231             return
    232         self.redirect(self.url(self.context))
    233    
    234 class UploadMain(grok.Viewlet):
    235     grok.viewletmanager(MainArea)
    236     grok.context(IDataCenter)
    237     grok.view(Upload)
    238    
    239 
    240 class Settings(grok.View):
    241     grok.context(IDataCenter)
    242     grok.name('settings')
    243     grok.template('master')
    244 
    245     def update(self, newpath=None, move=False, overwrite=False,
    246                save=None, cancel=None):
    247         if move:
    248             move = True
    249         if overwrite:
    250             overwrite = True
    251         if newpath is None:
    252             return
    253         if cancel is not None:
    254             self.redirect(self.url(self.context))
    255             return
    256         try:
    257             not_copied = self.context.setStoragePath(newpath, move=move)
    258             for name in not_copied:
    259                 self.flash('File already existed (not copied): %s' % name)
    260         except ValueError:
    261             self.flash('Given storage path cannot be used.')
    262             self.flash('Error: %s' %sys.exc_info()[1])
    263             return
    264         if newpath:
    265             self.flash('New storage path succefully set.')
    266             self.redirect(self.url(self.context))
    267         return
    268 
    269 class SettingsMain(grok.Viewlet):
    270     grok.viewletmanager(MainArea)
    271     grok.context(IDataCenter)
    272     grok.view(Settings)
    273 
    274 class SettingsLink(grok.Viewlet):
    275     grok.viewletmanager(LeftSidebar)
    276     grok.context(IDataCenter)
    277     grok.view(Index)
    278     grok.order(2)
    279     grok.require('waeup.manageUniversity')
    280 
    281     def render(self):
    282         return u'<div class="portlet"><a href="@@settings">Settings</a></div>'
    283 
    284 class ImportCSV(grok.View):
    285     """A view for importing things.
    286 
    287     """
    288     grok.require('waeup.manageUniversity')
    289     grok.template('master')
    290     grok.context(IDataCenter)
    291 
    292     def update(self, csvfile=None, clear=None, overwrite=None,
    293                receiverid=None, CANCEL=None, SUBMIT=None):
    294         if CANCEL is not None:
    295             self.redirect(self.url(self.context))
    296             return
    297         if not csvfile:
    298             return
    299         if not SUBMIT:
    300             return
    301         try:
    302             self.context.doImport(csvfile, receiverid, clear=clear)
    303         except ValueError:
    304             self.flash('Could not import: %s' % os.path.basename(csvfile))
    305             return
    306         except:
    307             self.flash('Import failed: %s %s' % (sys.exc_info()[0],
    308                                                  sys.exc_info()[1]))
    309             return
    310         self.flash('Successfully imported: %s' % os.path.basename(csvfile))
    311         self.redirect(self.url(self.context))
    312         return
    313 
    314207class Import(object):
    315208    """Helper class to aggregate imports and their data.
     
    321214            importer.receiverid = receiverid
    322215            self.importers.append(importer)
    323        
    324 class ImportCSVMain(grok.Viewlet):
    325     grok.viewletmanager(MainArea)
    326     grok.context(IDataCenter)
    327     grok.view(ImportCSV)
    328     grok.require('waeup.manageUniversity')
    329 
    330     def getImports(self):
    331         result = []
    332         imports = self.context.getPossibleImports()
    333         result = [Import(x, y) for x, y in imports]
    334         return result
    335    
    336     def update(self, *args, **kw):
    337         return super(ImportCSVMain, self).update(*args, **kw)
    338        
Note: See TracChangeset for help on using the changeset viewer.