From 9d71c7700e8f059d5494a6e04a67d8d746a101d1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 14 Feb 2014 12:45:06 +0100 Subject: [PATCH] Add BofhStorage; Also removed stale changes file, everything's in git history --- CHANGES.txt | 30 ------------------------------ fnpdjango/storage.py | 29 +++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) delete mode 100644 CHANGES.txt create mode 100644 fnpdjango/storage.py diff --git a/CHANGES.txt b/CHANGES.txt deleted file mode 100644 index 526cd79..0000000 --- a/CHANGES.txt +++ /dev/null @@ -1,30 +0,0 @@ - - Fix makecontribmessages command. - -v0.1.6 2013-03-20 - - Update to Django 1.5 - -v0.1.5 2013-02-22 - - Make prevnext respect current GET parameters. - - Add a management command for localizing contrib apps. - - Fix deployment sudo problem. - -v0.1.4 2013-01-10 - - Add tQ function for filtering translated fields. - -v0.1.3 2013-01-09 - - Fix get_here_url. - - Nicer project starter. - - Fix deployment scripts. - -v0.1.2 2012-11-30 - - Added app settings. - - Fix deployment scripts. - - Minor fixes. - -v0.1.1 2012-11-22 - - Deployment scripts. - - Minor fixes. - -v0.1 2012-11-05 - - Initial release. - diff --git a/fnpdjango/storage.py b/fnpdjango/storage.py new file mode 100644 index 0000000..72719b2 --- /dev/null +++ b/fnpdjango/storage.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# This file is part of FNPDjango, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.core.files.storage import FileSystemStorage + +class BofhStorageMixin(FileSystemStorage): + """Bastard Operator From Hell file storage for Django. + + When a user asks for a place available for saving a file and + the proposed filename is occupied, default Django file storage + looks for a free spot by appending a suffix. + + This storage just deletes the previous content and replies: + sure, just save it right where you want it. + + The user is now responsible for making sure they don't + accidentally overwrite anything they weren't supposed to, + and for sane caching settings. + + """ + def get_available_name(self, name): + if self.exists(name): + self.delete(name) + return name + +class BofhFileSystemStorage(BofhStorageMixin, FileSystemStorage): + """Bastard Operator From Hell storage for standard filesystem.""" + pass diff --git a/setup.py b/setup.py index db7ff1a..f9e8261 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def whole_trees(package_dir, paths): setup( name='fnpdjango', - version='0.1.14', + version='0.1.15', author='Radek Czajka', author_email='radekczajka@nowoczesnapolska.org.pl', url = '', -- 2.20.1