Example #1
0
 def create_file(self, user, shared_file):
     ''' Saves uploaded file '''
     file_upload = FileUpload(team_id=user.team.id)
     file_upload.file_name = shared_file['filename']
     file_upload.data = shared_file['body']
     file_upload.description = self.get_argument('description', '')
     self.dbsession.add(file_upload)
     self.dbsession.commit()
     return file_upload
 def create_file(self, user, shared_file):
     ''' Saves uploaded file '''
     try:
         file_upload = FileUpload(team_id=user.team.id)
         file_upload.file_name = shared_file['filename']
         file_upload.data = shared_file['body']
         file_upload.description = self.get_argument('description', '')
         self.dbsession.add(file_upload)
         self.dbsession.commit()
         return file_upload
     except ValidationError as error:
         self.errors.append(str(error))
 def create_file(self, user, shared_file):
     ''' Saves uploaded file '''
     try:
         file_upload = FileUpload(team_id=user.team.id)
         file_upload.file_name = shared_file['filename']
         file_upload.data = shared_file['body']
         file_upload.description = self.get_argument('description', '')
         self.dbsession.add(file_upload)
         self.dbsession.commit()
         return file_upload
     except ValidationError as error:
         self.errors.append(str(error))
Example #4
0
 def create_file(self, user, shared_file):
     if options.team_sharing:
         """ Saves uploaded file """
         try:
             file_upload = FileUpload(team_id=user.team.id)
             file_upload.file_name = shared_file["filename"]
             file_upload.data = shared_file["body"]
             file_upload.description = self.get_argument("description", "")
             self.dbsession.add(file_upload)
             self.dbsession.commit()
             return file_upload
         except ValidationError as error:
             self.errors.append(str(error))
     else:
         self.redirect("/404")
Example #5
0
 def post(self, *args, **kwargs):
     user = self.get_current_user()
     shared_file = FileUpload.by_uuid(self.get_argument('uuid', ''))
     if shared_file is not None and shared_file in user.team.files:
         logging.info("%s deleted a shared file %s" % (user.handle, shared_file.uuid))
         shared_file.delete_data()
         self.dbsession.delete(shared_file)
         self.dbsession.commit()
         self.redirect('/user/share/files')
     else:
         self.redirect("/404")
Example #6
0
 def get(self, *args, **kwargs):
     ''' Get a file and send it to the user '''
     user = self.get_current_user()
     shared_file = FileUpload.by_uuid(self.get_argument('uuid', ''))
     if shared_file is not None and shared_file in user.team.files:
         self.set_header('Content-Type', shared_file.content_type)
         self.set_header('Content-Length', shared_file.byte_size)
         self.set_header('Content-Disposition', 'attachment; filename=%s' % shared_file.file_name)
         self.write(shared_file.data)
     else:
         self.render("public/404.html")
Example #7
0
 def get(self, *args, **kwargs):
     ''' Get a file and send it to the user '''
     user = self.get_current_user()
     shared_file = FileUpload.by_uuid(self.get_argument('uuid', ''))
     if shared_file is not None and shared_file in user.team.files:
         self.set_header('Content-Type', shared_file.content_type)
         self.set_header('Content-Length', shared_file.byte_size)
         self.set_header('Content-Disposition',
                         'attachment; filename=%s' % shared_file.file_name)
         self.write(shared_file.data)
     else:
         self.render("public/404.html")
Example #8
0
 def get(self, *args, **kwargs):
     if options.team_sharing:
         ''' Get a file and send it to the user '''
         user = self.get_current_user()
         shared_file = FileUpload.by_uuid(self.get_argument('uuid', ''))
         if user.has_permission(ADMIN_PERMISSION) or (
                 shared_file is not None
                 and shared_file in user.team.files):
             self.set_header('Content-Type', shared_file.content_type)
             self.set_header('Content-Length', shared_file.byte_size)
             self.set_header(
                 'Content-Disposition',
                 'attachment; filename=%s' % (shared_file.file_name))
             self.write(shared_file.data)
         else:
             self.render("public/404.html")
     else:
         self.redirect("/404")
Example #9
0
 def get(self, *args, **kwargs):
     if options.team_sharing:
         """ Get a file and send it to the user """
         user = self.get_current_user()
         shared_file = FileUpload.by_uuid(self.get_argument("uuid", ""))
         if user.is_admin() or (shared_file is not None
                                and shared_file in user.team.files):
             self.set_header("Content-Type", shared_file.content_type)
             self.set_header("Content-Length", shared_file.byte_size)
             self.set_header(
                 "Content-Disposition",
                 "attachment; filename=%s" % (shared_file.file_name),
             )
             self.write(shared_file.data)
         else:
             self.render("public/404.html")
     else:
         self.redirect("/404")
Example #10
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         user = self.get_current_user()
         shared_file = FileUpload.by_uuid(self.get_argument('uuid', ''))
         if user.has_permission(ADMIN_PERMISSION):
             logging.info("%s deleted a shared file %s" %
                          (user.handle, shared_file.uuid))
             shared_file.delete_data()
             self.dbsession.delete(shared_file)
             self.dbsession.commit()
             self.redirect('/admin/view/fileshare')
         if shared_file is not None and shared_file in user.team.files:
             logging.info("%s deleted a shared file %s" %
                          (user.handle, shared_file.uuid))
             shared_file.delete_data()
             self.dbsession.delete(shared_file)
             self.dbsession.commit()
             self.redirect('/user/share/files')
         else:
             self.redirect("/404")
     else:
         self.redirect("/404")
Example #11
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         user = self.get_current_user()
         shared_file = FileUpload.by_uuid(self.get_argument("uuid", ""))
         if user.is_admin():
             logging.info("%s deleted a shared file %s" %
                          (user.handle, shared_file.uuid))
             shared_file.delete_data()
             self.dbsession.delete(shared_file)
             self.dbsession.commit()
             self.redirect("/admin/view/fileshare")
         elif shared_file is not None and shared_file in user.team.files:
             logging.info("%s deleted a shared file %s" %
                          (user.handle, shared_file.uuid))
             shared_file.delete_data()
             self.dbsession.delete(shared_file)
             self.dbsession.commit()
             self.redirect("/user/share/files")
         else:
             self.redirect("/404")
     else:
         self.redirect("/404")