示例#1
0
    def add_to_history(self):
        FileTransferHistory().add_transfer(
            transfer_id=self.ft_info.transfer_id,
            direction=self.ft_info.direction,
            local_uri=self.ft_info.local_uri,
            remote_uri=self.ft_info.remote_uri,
            file_path=self.ft_info.file_path,
            bytes_transfered=self.ft_info.bytes_transfered,
            file_size=self.ft_info.file_size or 0,
            status=self.ft_info.status)

        message = "<h3>%s File Transfer</h3>" % self.ft_info.direction.capitalize(
        )
        message += "<p>%s (%s)" % (self.ft_info.file_path,
                                   format_size(self.ft_info.file_size or 0))
        media_type = 'file-transfer'
        local_uri = self.ft_info.local_uri
        remote_uri = self.ft_info.remote_uri
        direction = self.ft_info.direction
        status = 'delivered' if self.ft_info.status == 'completed' else 'failed'
        cpim_from = self.ft_info.remote_uri
        cpim_to = self.ft_info.remote_uri
        timestamp = str(ISOTimestamp.now())

        ChatHistory().add_message(self.ft_info.transfer_id, media_type,
                                  local_uri, remote_uri, direction, cpim_from,
                                  cpim_to, timestamp, message, "html", "0",
                                  status)
示例#2
0
 def get_previous_transfers(self, active_items=()):
     results = FileTransferHistory().get_transfers(20)
     already_added_file = set()
     transfers = []
     for transfer in results:
         file_idx = '%s%s' % (transfer.file_path, transfer.remote_uri)
         if transfer.transfer_id in active_items:
             continue
         if file_idx in already_added_file:
             continue
         already_added_file.add(file_idx)
         transfers.append(transfer)
     self.render_previous_transfers(reversed(transfers))
示例#3
0
 def delete_history_transfers(self):
     return FileTransferHistory().delete_transfers()