Example #1
0
    def absolute_document_path(self, document_widget):
        """
        Build the absolute document path using info from the document widget.
        :param document_widget: Instance of document widget.
        :return: Absolute path of the supporting document.
        :rtype: str
        """
        abs_path = ''

        file_manager = document_widget.fileManager
        if not file_manager is None:
            network_repository = file_manager.networkPath
            file_id = document_widget.file_identifier()
            source_entity = document_widget.doc_source_entity()
            profile_name = current_profile().name
            doc_type = document_widget.doc_type_value().lower().replace(
                ' ', '_'
            )
            file_name, file_extension = guess_extension(
                document_widget.displayName()
            )

            abs_path = network_repository + "/" +profile_name + '/' +\
                       unicode(source_entity) + "/" + unicode(doc_type) + "/" +\
                       unicode(file_id) + unicode(file_extension)

        return abs_path
Example #2
0
    def file_exist(self, doc_model=None, doc_type=None):
        """
        Check if a file exists before removing.
        """
        file_found = True
        if doc_model is not None:
            #Build the path from the model variable values.
            fileName, fileExt = guess_extension(doc_model.filename)
            profile_name = self.curr_profile.name
            #Qt always expects the file separator be be "/" regardless of platform.
            absPath = u'{}/{}/{}/{}/{}{}'.format(
                self.networkPath, profile_name.lower(),
                doc_model.source_entity,
                doc_type.lower().replace(' ', '_'),
                doc_model.document_identifier, fileExt)

            file_found = QFile.exists(absPath)
        return file_found
Example #3
0
    def deleteDocument(self, docmodel=None, doc_type=None):
        """
        Delete the source document from the central repository.
        """
        if not docmodel is None:
            #Build the path from the model variable values.
            fileName, fileExt = guess_extension(docmodel.filename)
            profile_name = self.curr_profile.name
            #Qt always expects the file separator be be "/" regardless of platform.
            absPath = '{}/{}/{}/{}/{}{}'.format(
                self.networkPath, profile_name.lower(), docmodel.source_entity,
                doc_type.lower().replace(' ', '_'),
                docmodel.document_identifier, fileExt)

            return QFile.remove(absPath)

        else:
            return QFile.remove(self.destinationPath)
Example #4
0
    def deleteDocument(self, docmodel = None, doc_type=None):
        """
        Delete the source document from the central repository.
        """
        if not docmodel is None:
            #Build the path from the model variable values.
            fileName, fileExt = guess_extension(docmodel.filename)
            profile_name = self.curr_profile.name
            #Qt always expects the file separator be be "/" regardless of platform.
            absPath = u'{}/{}/{}/{}/{}{}'.format(
                self.networkPath,
                profile_name.lower(),
                docmodel.source_entity,
                doc_type.lower().replace(' ', '_'),
                docmodel.document_identifier,
                fileExt
            )

            return QFile.remove(absPath)
        
        else:
            return QFile.remove(self.destinationPath)