diff --git a/UPGRADE b/UPGRADE index 06bc5d67..874dccdf 100644 --- a/UPGRADE +++ b/UPGRADE @@ -9,4 +9,20 @@ all commands listed _after_ that checkout. ######################### 0. Table of Contents ######################### -No items yet. +1. 2009-01-23 (Changes added after SVN r99) + + +######################### +1. 2009-01-23 (Changes added after SVN r99) +######################### + +A new flag was added to the 'IgnoreEmail' model to allow emails from ignored +addresses to be either kept in the mailbox (for manual checking) or deleted. + +A new column called 'keep_in_mailbox' (type boolean, not required) is to be +added to the 'helpdesk_ignoreemail' table. The 'UPDATE' command will set all +ignore list entries to 'Keep mail from ignored address', which is the previous +behaviour. + + ALTER TABLE helpdesk_ignoreemail ADD "keep_in_mailbox" boolean; + UPDATE helpdesk_ignoreemail SET keep_in_mailbox='t'; diff --git a/management/commands/get_email.py b/management/commands/get_email.py index d7142356..1fccf14b 100644 --- a/management/commands/get_email.py +++ b/management/commands/get_email.py @@ -137,7 +137,11 @@ def ticket_from_message(message, queue): for ignore in IgnoreEmail.objects.filter(Q(queues=queue) | Q(queues__isnull=True)): if ignore.test(sender_email): - return False + if ignore.keep_in_mailbox: + # By returning 'False' the message will be kept in the mailbox, + # and the 'True' will cause the message to be deleted. + return False + return True regex = re.compile("^\[[A-Za-z0-9]+-\d+\]") if regex.match(subject): diff --git a/models.py b/models.py index ad2c148c..41821cbd 100644 --- a/models.py +++ b/models.py @@ -129,7 +129,7 @@ class Queue(models.Model): help_text=_('Whether to use SSL for IMAP or POP3 - the default ports ' 'when using SSL are 993 for IMAP and 995 for POP3.'), ) - + email_box_user = models.CharField( _('E-Mail Username'), max_length=200, @@ -847,7 +847,7 @@ class SavedSearch(models.Model): null=True, help_text=_('Should other users see this query?'), ) - + query = models.TextField( _('Search Query'), help_text=_('Pickled query object. Be wary changing this.'), @@ -867,7 +867,7 @@ class UserSettings(models.Model): We should always refer to user.usersettings.settings['setting_name']. """ - + user = models.OneToOneField(User) settings_pickled = models.TextField( @@ -882,7 +882,7 @@ class UserSettings(models.Model): import cPickle from helpdesk.lib import b64encode self.settings_pickled = b64encode(cPickle.dumps(data)) - + def _get_settings(self): # return a python dictionary representing the pickled data. import cPickle @@ -896,7 +896,7 @@ class UserSettings(models.Model): def __unicode__(self): return u'Preferences for %s' % self.user - + class Meta: verbose_name = 'User Settings' verbose_name_plural = 'User Settings' @@ -949,7 +949,7 @@ class IgnoreEmail(models.Model): _('Name'), max_length=100, ) - + date = models.DateField( _('Date'), help_text=_('Date on which this e-mail address was added'), @@ -964,9 +964,18 @@ class IgnoreEmail(models.Model): 'wildcards, eg *@domain.com or postmaster@*.'), ) + keep_in_mailbox = models.BooleanField( + _('Save Emails in Mailbox?'), + blank=True, + null=True, + help_text=_('Do you want to save emails from this address in the ' + 'mailbox? If this is unticked, emails from this address will ' + 'be deleted.'), + ) + def __unicode__(self): return u'%s' % self.name - + def save(self): if not self.date: self.date = datetime.now() @@ -983,7 +992,7 @@ class IgnoreEmail(models.Model): 1-4 return True, 5 returns False. """ - + own_parts = self.email_address.split("@") email_parts = email.split("@") diff --git a/templates/helpdesk/email_ignore_list.html b/templates/helpdesk/email_ignore_list.html index 834c8d2e..af38b0fa 100644 --- a/templates/helpdesk/email_ignore_list.html +++ b/templates/helpdesk/email_ignore_list.html @@ -10,7 +10,7 @@
{% trans "Ignored E-Mail Addresses" %} | |||||
{% trans "Name" %} | {% trans "E-Mail Address" %} | {% trans "Date Added" %} | {% trans "Queues" %} | {% trans "Delete" %} | |
---|---|---|---|---|---|
{% trans "Name" %} | {% trans "E-Mail Address" %} | {% trans "Date Added" %} | {% trans "Queues" %} | {% trans "Keep in mailbox?" %} | {% trans "Delete" %} | {{ ignore.name }} | {{ ignore.email_address }} | {{ ignore.date }} | -{% for queue in ignore.queues.all %}{{ queue.slug }}{% if not forloop.last %}, {% endif %}{% endfor %}{% if not ignore.queues.all %}All{% endif %} | -Delete | +{% for queue in ignore.queues.all %}{{ queue.slug }}{% if not forloop.last %}, {% endif %}{% endfor %}{% if not ignore.queues.all %}{% trans "All" %}{% endif %} | +{% if ignore.keep_in_mailbox %}{% trans "Keep" %}{% endif %} | +{% trans "Delete" %} | {% endfor %}
{% trans "Note: If the 'Keep' option is not selected, emails sent from that address will be deleted permanently." %}
+ {% endblock %}