def files(self, **kwargs):
     user, role, defaultExpiration, uploadRequests, userFiles, userShareableAttributes, attributeFilesDict, sharedFiles = (
         cherrypy.session.get("user"), cherrypy.session.get("current_role"),
         None, [], [], [], {}, [])
     config = cherrypy.request.app.config['filelocker']
     orgConfig = get_config_dict_from_objects(
         session.query(ConfigParameter).filter(
             ConfigParameter.name.like('org_%')).all())
     maxDays = int(
         session.query(ConfigParameter).filter(
             ConfigParameter.name == 'max_file_life_days').one().value)
     geoTagging = get_config_dict_from_objects([
         session.query(ConfigParameter).filter(
             ConfigParameter.name == 'geotagging').one()
     ])['geotagging']
     adminEmail = session.query(ConfigParameter).filter(
         ConfigParameter.name == 'admin_email').one().value
     defaultExpiration = datetime.date.today() + (datetime.timedelta(
         days=maxDays))
     userFiles = self.file.get_user_file_list(format="list")
     if role is None:
         uploadRequests = session.query(UploadRequest).filter(
             UploadRequest.owner_id == user.id).all()
         userShareableAttributes = AccountService.get_shareable_attributes_by_user(
             user)
         attributeFilesDict = ShareService.get_files_shared_with_user_by_attribute(
             user)
         sharedFiles = ShareService.get_files_shared_with_user(user)
     else:
         userShareableAttributes = AccountService.get_shareable_attributes_by_role(
             role)
     tpl = Template(file=get_template_file('files.tmpl'),
                    searchList=[locals(), globals()])
     return str(tpl)
 def get_files_shared_with_user(self, format="json", **kwargs):
     #Determine which files are shared with the user
     user, sMessages, fMessages, sharedFiles = (cherrypy.session.get("user"), [], [], [])
     try:
         hiddenFileIds = []
         hiddenShares = session.query(HiddenShare).filter(HiddenShare.owner_id == user.id).all()
         for hiddenShare in hiddenShares:
             hiddenFileIds.append(hiddenShare.file_id)
         for flFile in ShareService.get_files_shared_with_user(user):
             if flFile.id not in hiddenFileIds:
                 sharedFiles.append(flFile.get_dict())
     except Exception, e:
         cherrypy.log.error("[%s] [get_files_shared_with_user] [Couldn't get files shared with user: %s]" % (user.id, str(e)))
         fMessages.append(str(e))
 def files(self, **kwargs):
     user, role, defaultExpiration, uploadRequests, userFiles, userShareableAttributes,attributeFilesDict,sharedFiles = (cherrypy.session.get("user"), cherrypy.session.get("current_role"), None, [], [], [], {}, [])
     config = cherrypy.request.app.config['filelocker']
     orgConfig = get_config_dict_from_objects(session.query(ConfigParameter).filter(ConfigParameter.name.like('org_%')).all())
     maxDays = int(session.query(ConfigParameter).filter(ConfigParameter.name=='max_file_life_days').one().value)
     geoTagging = get_config_dict_from_objects([session.query(ConfigParameter).filter(ConfigParameter.name=='geotagging').one()])['geotagging']
     adminEmail = session.query(ConfigParameter).filter(ConfigParameter.name=='admin_email').one().value
     defaultExpiration = datetime.date.today() + (datetime.timedelta(days=maxDays))
     userFiles = self.file.get_user_file_list(format="list")
     if role is None:
         uploadRequests = session.query(UploadRequest).filter(UploadRequest.owner_id==user.id).all()
         userShareableAttributes = AccountService.get_shareable_attributes_by_user(user)
         attributeFilesDict = ShareService.get_files_shared_with_user_by_attribute(user)
         sharedFiles = ShareService.get_files_shared_with_user(user)
     else:
         userShareableAttributes = AccountService.get_shareable_attributes_by_role(role)
     tpl = Template(file=get_template_file('files.tmpl'), searchList=[locals(),globals()])
     return str(tpl)
Beispiel #4
0
 def get_files_shared_with_user(self, format="json", **kwargs):
     #Determine which files are shared with the user
     user, sMessages, fMessages, sharedFiles = (
         cherrypy.session.get("user"), [], [], [])
     try:
         hiddenFileIds = []
         hiddenShares = session.query(HiddenShare).filter(
             HiddenShare.owner_id == user.id).all()
         for hiddenShare in hiddenShares:
             hiddenFileIds.append(hiddenShare.file_id)
         for flFile in ShareService.get_files_shared_with_user(user):
             if flFile.id not in hiddenFileIds:
                 sharedFiles.append(flFile.get_dict())
     except Exception, e:
         cherrypy.log.error(
             "[%s] [get_files_shared_with_user] [Couldn't get files shared with user: %s]"
             % (user.id, str(e)))
         fMessages.append(str(e))