Commits

Matthew Schinckel committed 0732215

Add reverse relation name to sender on Message.
Add length property to message

  • Participants
  • Parent commits 5c216f1

Comments (0)

Files changed (1)

File sms/models/message.py

     content = models.TextField(help_text=_(u'The body of the message.'))
     recipient_number = models.CharField(max_length=32, 
         help_text=_(u'The international number of the recipient, without the leading +'))
-    # TODO: Remove this link to a non-contrib app!
-    # recipient = models.ForeignKey('person.Person')
     
-    sender = models.ForeignKey('auth.User')
+    sender = models.ForeignKey('auth.User', related_name='sent_sms_messages')
     send_date = models.DateTimeField(null=True, blank=True, editable=False)
     delivery_date = models.DateTimeField(null=True, blank=True, editable=False)
     uuid = uuidfield.UUIDField(auto=True, help_text=_(u'Used for associating replies.'))
         app_label = 'sms'
 
     def send(self, gateway):
-        if self.status != "Unsent":
-            gateway.send(self)
-        else:
-            pass
-            # clone us, and send again.
-    
+        gateway.send(self)
+    
+    @property
+    def length(self):
+        return len(self.content) / 160 + 1