From 26f6974648b2f5d09ae9594bd2ff82fb085a5b2b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 6 Dec 2016 22:58:50 +0000 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B3=D0=B4=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20500?= =?UTF-8?q?=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BD=D0=B5=20=D0=B2=D1=8B=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=BB=D0=B8=20=D0=B0=D0=B1=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taskapp/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/taskapp/models.py b/taskapp/models.py index 73099b4..c7860ea 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -50,7 +50,7 @@ class Task(models.Model): state = models.CharField(max_length=1, choices=TASK_STATES, default=TASK_STATES[0][0]) attachment = models.ImageField(upload_to='task_attachments/%Y.%m.%d', blank=True, null=True) mode = models.CharField(max_length=2, choices=TASK_TYPES, default=TASK_TYPES[0][0]) - abon = models.ForeignKey(Abon, on_delete=models.SET_NULL, null=True, blank=True) + abon = models.ForeignKey(Abon, on_delete=models.SET_NULL, null=True, blank=True, related_name='+') def __unicode__(self): return self.descr @@ -70,6 +70,7 @@ class Task(models.Model): def task_handler(sender, instance, **kwargs): cur_dir = os.path.join(BASE_DIR, "taskapp") if instance.state == 'F': + # выполнена return if kwargs['created']: first_param = 'start' @@ -77,8 +78,10 @@ def task_handler(sender, instance, **kwargs): first_param = 'change' call(['%s/handle.sh' % cur_dir, first_param, instance.get_mode_display(), instance.device.ip_address if instance.mode != 'cr' or instance.mode != 'ot' else '', - instance.state, instance.recipient.telephone, instance.descr, instance.abon.fio, instance.abon.address, - instance.abon.telephone]) + instance.state, instance.recipient.telephone, instance.descr, + instance.abon.fio if instance.abon else '<нет фио>', + instance.abon.address if instance.abon else '<нет адреса>', + instance.abon.telephone if instance.abon else '<нет телефона>']) models.signals.post_save.connect(task_handler, sender=Task)