Commits

Denis Darii committed 0418abb

added SatelliteInspection model

Comments (0)

Files changed (1)

+import datetime
 from django.db import models
 from django.utils.translation import ugettext as _
 from django.contrib.auth.models import User
 
 
 class Satellite(models.Model):
-    note = models.CharField(_('name'), max_length=200, blank=True, null=True)
+    name = models.CharField(_('name'), max_length=200, blank=True, null=True)
     user = models.ForeignKey(User, verbose_name=_('user'),
                     blank=True, null=True)
     url = models.URLField(_("url"), blank=True)
     created = models.DateTimeField(auto_now_add=True, editable=False)
 
     def __unicode__(self):
-        return '%s %s' % (self.user, self.url)
+        if self.name:
+            description = self.name
+        else:
+            description = self.url
+        return '%s (%s)' % (description, self.user)
 
     class Meta():
         verbose_name = _('satellite')
     class Meta():
         verbose_name = _('satellite log')
         verbose_name_plural = _('satellite logs')
+
+
+class SatelliteInspection(models.Model):
+    satellite_inspector = models.ForeignKey(Satellite, verbose_name=_('satellite inspector'))
+    satellite_inspected = models.ForeignKey(Satellite, verbose_name=_('satellite inspected'))
+    date = models.DateTimeField(_('date'), default=datetime.datetime.now)
+    response_time = models.IntegerField(_('response time'), default=0)
+    created = models.DateTimeField(auto_now_add=True, editable=False)
+
+    def __unicode__(self):
+        return '%s - %s' % (unicode(self.satellite_inspector), unicode(self.satellite_inspected))
+
+    class Meta():
+        verbose_name = _('satellite inspection')
+        verbose_name_plural = _('satellite inspections')