"""
Created on 28.09.2011

@author: christian
"""
from django.core.files.storage import FileSystemStorage
from django.utils.translation import ugettext as _

from .countries import COUNTRIES
from .html_cleaner import HtmlCleaner
from .massmailer import MassMailer


CLEANER = HtmlCleaner()
STATUS_REJECTED, STATUS_WAITING, STATUS_PUBLISHED = -1, 0, 1
STATUS_CHOICES = (
    (STATUS_REJECTED, _('Rejected')),
    (STATUS_WAITING, _('Waiting...')),
    (STATUS_PUBLISHED, _('Published')),
)


class OverwriteStorage(FileSystemStorage):
    """
    Returns same name for existing file and deletes existing file on save.
    """

    def _save(self, name, content):
        if self.exists(name):
            self.delete(name)
        return super(OverwriteStorage, self)._save(name, content)

    def get_available_name(self, name, max_length=None):
        return name
