src/cm/models_utils.py
author Simon Descarpentries <sid@sopinspace.com>
Wed, 30 Oct 2013 18:08:42 +0100
changeset 556 69503659fe8f
parent 0 40c8f766c9b8
permissions -rw-r--r--
[c_selection.js] If safari_mobile, get current selection from a previously created global variable [c_sync.js] ref where the safari_mobile global is used [c_text_view_comments.js] if safari_mobile update selection also on selectionChange event [text_view_comments.html] if safari_mobile store a clone of the current selection on each selectionChange set layout width to 99% to improve display factorize safari mobile detection code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
# models used to internal work
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
from django.db import models
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
from django.contrib.auth.models import User
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
class Email(models.Model):
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     7
    """
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
    Simple (no multipart support) email storage
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
    """
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    10
    created = models.DateTimeField(auto_now_add=True)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    11
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    12
    subject = models.TextField()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    13
    body = models.TextField()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    14
    from_email = models.TextField()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    15
    to = models.TextField()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
    bcc = models.TextField()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
    message = models.TextField() #full message
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    18
    
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
    def get_recipents_number(self):
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    20
        from cm.utils.mail import LIST_SEP
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    21
        res = 0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    22
        if self.to:
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    23
            res = len(self.to.split(LIST_SEP))
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    24
        if self.bcc:
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    25
            res += len(self.bcc.split(LIST_SEP))
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    26
        return res
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    27
      
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    28
    get_recipents_number.short_description = "#recipients"
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    29
    
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    30
    def __unicode__(self):
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    31
        return ' '.join([self.from_email, self.to, self.subject])
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    32