V1.31 exercise_type clone, evaluation inline

This commit is contained in:
Tibor Bossanyi (Freelancer)
2021-10-19 08:23:52 +02:00
parent ae805ffcf5
commit 2a4731dc29
26 changed files with 295 additions and 100 deletions
@@ -4,6 +4,7 @@ from firebase_admin import messaging, exceptions
class FCM:
logo_url = 'https://workouttest.com/wp-content/uploads/2020/10/WT_long_logo.png'
image_base = 'https://admin.aitrainer.app/media/images/'
# default constructor
def __init__(self):
@@ -53,10 +54,11 @@ class FCM:
if registration_token == None:
return "Registration token is null"
try:
notification_image_url = image_url
if image_url == None:
notification_image_url = self.logo_url
#registration_token = 'cOqNt8rzo074gbIkBSpCgW:APA91bEBuNi3iVzGKb4JhxqN2j80MoJbNptLHk2qsdeKBQz5grpHtrPPXvDqn5BJVVSaj1nwGPwgN7pi6FIApog_TTP3g1yobgmgpPN6udrYgzILlVPMvdGGFDSDh6gKlczhlTL9NEp0'
else:
notification_image_url = self.image_base + '/' + image_url
print(f'image: {notification_image_url}' )
@@ -2,8 +2,13 @@ import requests
import logging
from django.db import connections
import datetime
import os
from ..models.customer import Customer
SETTING = os.environ['WORKOUTTEST_SETTING']
if SETTING == "PROD":
from aitrainer_backoffice.aitrainer_backoffice.models.customer import Customer
else:
from aitrainer_backoffice.models.customer import Customer
class Mautic:
@@ -13,6 +18,37 @@ class Mautic:
qs = Customer.objects.raw(
'SELECT * from customer WHERE trial_date < "' + tenDays + '" and trial_date is not null')
def syncLang(self):
qs = Customer.objects.raw('SELECT * from customer WHERE lang is not null')
logger = logging.getLogger(__name__)
logger.info("Syncronising lang...")
headers = {
'content-type': "application/x-www-form-urlencoded",
'cache-control': "no-cache"
}
index = 0
for customer in qs:
data = "mauticform[email]=" + customer.email + \
"&mauticform[database_id]=" + str(customer.customer_id) + \
"&mauticform[lang]=" + str(customer.lang) + \
"&mauticform[formId]=3" + \
"&mauticform[formName]=appdatachange"
print(data)
form_url = 'https://mautic.aitrainer.app/form/submit?formId=3'
response = requests.post(form_url, data=data.encode('utf-8'), headers=headers)
print(customer.email + " " +str(response.status_code))
index = index + 1
if index == 2:
break
logger.info("Syncronised customer count: " + str(index))
return True
def sync(self):
logger = logging.getLogger(__name__)
logger.info("Syncronising...")