Commits

Matthew Schinckel committed 52e1c98

Really must test code more before releasing.

  • Participants
  • Parent commits de84a84

Comments (0)

Files changed (2)

sms/models/message.py

         app_label = 'sms'
     
     def get_messages(self):
-        return Message.objects.filter(uuid__in=[x['uuid'] for x in self.data.keys()])
+        return Message.objects.filter(uuid__in=self.data.keys())
     
     def get_unsent(self):
-        return [x for x in self.data if x['status'] == "Unsent"]
+        return [k for k,v in self.data.items() if v['status'] == "Unsent"]
         
     @property
     def percentage_complete(self):
         if not unsent_count:
             return 100
         
-        return (100 * (1 - unsent_count / message_count)).quantize('0.01')
+        return (100 * (1 - unsent_count / message_count)).quantize(Decimal('0.01'))
     
     def update_data(self):
         changed = False
         for msg in self.get_messages():
-            data = self.data[msg.uuid]
+            data = self.data[msg.uuid.replace('-', '')]
             if 'status_message' not in data or 'status' not in data or msg.status != data['status'] or msg.status_message != data['status_message']:
                 data['status'] = msg.status
                 data['status_message'] = msg.status_message
     def is_complete(self):
         return not self.get_unsent()
     
-    @models.permalink
     def get_absolute_url(self):
-        return reverse('messageset-status', args=(self.uuid,))
+        return reverse('messageset-status', args=[self.uuid])
     message_set = MessageSet.objects.get(uuid=uuid)
     message_set.update_data()
     if message_set.is_complete():
-        return HttpResponse(json.dumps(message_set.data))
-    return HttpResponse(message_set.percentage_complete)
+        return HttpResponse(json.dumps(message_set.data.values()))
+    return HttpResponse(str(message_set.percentage_complete))