Remove compatibility kludges around EbookField.
[wolnelektury.git] / src / club / civicrm.py
index c44f6f8..b770fbd 100644 (file)
@@ -1,6 +1,6 @@
 from datetime import datetime
 import json
-from celery.task import task
+from celery import shared_task
 from django.conf import settings
 import requests
 import yaml
@@ -9,8 +9,8 @@ import yaml
 class CiviCRM:
     def __init__(self, base, key):
         self.base = base
-        self.api_base = base + 'civicrm/ajax/api4/'
         self.key = key
+        self.api_base = (base or '') + 'civicrm/ajax/api4/'
         self.enabled = bool(self.base and self.key)
 
     def request(self, resource, method, params):
@@ -89,6 +89,9 @@ class CiviCRM:
                 
 
     def report_activity(self, email, tpwl_key, key, name, datetime, details):
+        if not self.enabled:
+            return
+
         contact_id = self.create_or_update_contact(email, tpwl_key)
 
         activity_id = self.get_activity_id(key)
@@ -168,7 +171,7 @@ civicrm = CiviCRM(
     settings.CIVICRM_KEY,
 )
 
-@task(ignore_result=True)
+@shared_task(ignore_result=True)
 def report_activity(*args, **kwargs):
     civicrm.report_activity(*args, **kwargs)