from django.db import models
from json_field import JSONField


class Service(models.Model):
    name = models.CharField(max_length=64)
    secret = models.CharField(max_length=128)
    service_id = models.CharField(max_length=128)
    ips = JSONField(default=[])
    validate_ip = models.BooleanField(default=True)


class Message(models.Model):
    message = models.CharField(max_length=64)
    sender = models.CharField(max_length=64, db_index=True)
    country = models.CharField(max_length=2)
    price = models.FloatField()
    price_wo_vat = models.FloatField()
    currency = models.CharField(max_length=3)
    service_id = models.CharField(max_length=128)
    message_id = models.CharField(max_length=128)
    keyword = models.CharField(max_length=64)
    shortcode = models.CharField(max_length=64)
    operator = models.CharField(max_length=128)
    billing_type = models.CharField(max_length=2)
    status = models.CharField(max_length=64)
    test = models.CharField(max_length=16)
    sig = models.CharField(max_length=128)


class Payment(models.Model):
    service = models.ForeignKey(Service, related_name='payments')
    message = models.OneToOneField(Message)
    pin = models.CharField(max_length=16, unique=True)
    used = models.BooleanField(default=False)

@@ -310,16 +310,65 @@
 =True)%0A%0A
+    def __str__(self):%0A        return self.name%0A%0A
 %0Aclass M
@@ -1081,16 +1081,202 @@
 h=128)%0A%0A
+    def __str__(self):%0A        return '%7B%7D - %7B%7D from %7B%7D on %7B%7D'.format(%0A            self.keyword,%0A            self.message,%0A            self.sender,%0A            self.shortcode,%0A        )%0A%0A
 %0Aclass P
@@ -1508,8 +1508,83 @@
 =False)%0A
+%0A    def __str__(self):%0A        return '%7B%7D - %7B%7D'.format(self.id, self.pin)%0A

add __str__ methods to models