|
@@ -1,3 +1,6 @@
|
|
|
|
|
+import datetime
|
|
|
|
|
+
|
|
|
|
|
+from django.utils import timezone
|
|
|
from django.dispatch import receiver
|
|
from django.dispatch import receiver
|
|
|
from django.urls import reverse
|
|
from django.urls import reverse
|
|
|
from django.forms.models import model_to_dict
|
|
from django.forms.models import model_to_dict
|
|
@@ -52,18 +55,13 @@ def search_agent(sender, instance, update_fields=None, **kwargs):
|
|
|
|
|
|
|
|
def process_triggers():
|
|
def process_triggers():
|
|
|
|
|
|
|
|
- for trigger in Trigger.objects.all():
|
|
|
|
|
- print("there is a trigger!")
|
|
|
|
|
|
|
+ for trigger in Trigger.objects.filter(sent=False):
|
|
|
instance = Product.objects.get(pk = trigger.instancepk)
|
|
instance = Product.objects.get(pk = trigger.instancepk)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- for agent in SearchAgent.objects.all():
|
|
|
|
|
|
|
+ for agent in SearchAgent.objects.all( ):
|
|
|
|
|
|
|
|
for agentOrt in agent.ort:
|
|
for agentOrt in agent.ort:
|
|
|
if agentOrt == instance.ort:
|
|
if agentOrt == instance.ort:
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
context = {}
|
|
context = {}
|
|
|
context['product'] = model_to_dict ( instance )
|
|
context['product'] = model_to_dict ( instance )
|
|
|
context['agent'] = model_to_dict ( agent )
|
|
context['agent'] = model_to_dict ( agent )
|
|
@@ -86,7 +84,4 @@ def process_triggers():
|
|
|
priority='medium',
|
|
priority='medium',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- # trigger.delete()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-# process_triggers()
|
|
|
|
|
|
|
+ Trigger.objects.filter(pk=trigger.pk).update( sent=True, sentdate = timezone.now() )
|