Ejemplo n.º 1
0
def archive_file(root_dir, relative_file_path, request):
    """
    Archive the file into the database if it is edited
    """
    file_path = os.path.join(root_dir, relative_file_path)
    if os.path.isfile(file_path):
        (file_dir, file_name) = os.path.split(file_path)
        fd = open(file_path, 'r')
        content = fd.read()
        fd.close()
        archive = ThemeFileVersion(file_name=file_name,
                                   content=content,
                                   relative_file_path=relative_file_path,
                                   author=request.user)
        archive.save()
Ejemplo n.º 2
0
def archive_file(request, relative_file_path, ROOT_DIR=THEME_ROOT):
    """
    Archive the file into the database if it is edited
    """
    file_path = os.path.join(ROOT_DIR, relative_file_path)
    if os.path.isfile(file_path):
        (file_dir, file_name) = os.path.split(file_path)
        fd = open(file_path, 'r')
        content = fd.read()
        fd.close()
        archive = ThemeFileVersion(file_name=file_name,
                                  content=content,
                                  relative_file_path=relative_file_path,
                                  author=request.user)
        archive.save()