BO 1.25 App Texts
This commit is contained in:
parent
a9d34f65b8
commit
925c35f329
@ -14,3 +14,4 @@ from .split_tests import SplitTestAdmin
|
|||||||
from .training_plan_day import TrainingPlanDayAdmin
|
from .training_plan_day import TrainingPlanDayAdmin
|
||||||
from .controlling import ControllingAdmin
|
from .controlling import ControllingAdmin
|
||||||
from .sport import SportAdmin
|
from .sport import SportAdmin
|
||||||
|
from .app_text import AppTextAdmin
|
||||||
|
33
aitrainer_backoffice/aitrainer_backoffice/admin/app_text.py
Normal file
33
aitrainer_backoffice/aitrainer_backoffice/admin/app_text.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from django.utils.html import format_html
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from ..models.app_text import AppText, AppTextTranslation
|
||||||
|
|
||||||
|
|
||||||
|
class TranslationAppTextInline(admin.TabularInline):
|
||||||
|
model = AppTextTranslation
|
||||||
|
fields = ('language_code', 'translation')
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
|
class AppTextAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('text_key','checked')
|
||||||
|
fields = ('text_key','screenshot_url', 'checked')
|
||||||
|
readonly_fields = ("get_image_preview",)
|
||||||
|
|
||||||
|
def get_image_preview(self, obj):
|
||||||
|
screenshot_url = '/media/' + str(obj.url)
|
||||||
|
if obj.pk:
|
||||||
|
return format_html('<img src="{url}" title="{url}" width="30%" height="30%"/> ' \
|
||||||
|
.format(url=screenshot_url))
|
||||||
|
|
||||||
|
get_image_preview.short_description = _("Image Preview")
|
||||||
|
|
||||||
|
inlines = [
|
||||||
|
TranslationAppTextInline,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(AppText, AppTextAdmin)
|
||||||
|
admin.autodiscover()
|
@ -17,3 +17,4 @@ from .split_tests import SplitTests
|
|||||||
from .training_plan_day import TrainingPlanDay, TrainingPlanDayTranslation
|
from .training_plan_day import TrainingPlanDay, TrainingPlanDayTranslation
|
||||||
from .controlling import Controlling
|
from .controlling import Controlling
|
||||||
from .sports import Sport, SportTranslation
|
from .sports import Sport, SportTranslation
|
||||||
|
from .app_text import AppText, AppTextTranslation
|
32
aitrainer_backoffice/aitrainer_backoffice/models/app_text.py
Normal file
32
aitrainer_backoffice/aitrainer_backoffice/models/app_text.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from .enums import LanguageTypes
|
||||||
|
|
||||||
|
|
||||||
|
class AppText(models.Model):
|
||||||
|
text_id = models.AutoField(primary_key=True)
|
||||||
|
text_key = models.CharField(max_length=255, help_text='Do not edit this! It is the key in the mobile app',
|
||||||
|
verbose_name=_("text_key"))
|
||||||
|
screenshot_url = models.ImageField(upload_to='images/', help_text='The menu image size is 1366x768', blank=True, )
|
||||||
|
checked = models.BooleanField(blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'app_text'
|
||||||
|
verbose_name = _("App Text")
|
||||||
|
verbose_name_plural = _("App Texts")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.text_key
|
||||||
|
|
||||||
|
|
||||||
|
class AppTextTranslation(models.Model):
|
||||||
|
translation_id = models.AutoField(primary_key=True)
|
||||||
|
text = models.ForeignKey(AppText, on_delete=models.CASCADE)
|
||||||
|
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
|
||||||
|
translation = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'app_text_translation'
|
||||||
|
verbose_name = _("Translation")
|
||||||
|
verbose_name_plural = _("Translations")
|
@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BACKOFFICE_VERSION = 1.23
|
BACKOFFICE_VERSION = 1.25
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
@ -49,7 +49,7 @@ INSTALLED_APPS = [
|
|||||||
'ckeditor_uploader',
|
'ckeditor_uploader',
|
||||||
'django_admin_json_editor',
|
'django_admin_json_editor',
|
||||||
'rangefilter',
|
'rangefilter',
|
||||||
'django_crontab'
|
'django_cron',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@ -172,6 +172,7 @@ LOGGING = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
CRONJOBS = [
|
CRON_CLASSES = [
|
||||||
('4 */1 * * *', 'controlling.cron.sync_customers')
|
'aitrainer_backoffice.controlling.cron.sync_customers',
|
||||||
|
# ...
|
||||||
]
|
]
|
@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BACKOFFICE_VERSION = 1.23
|
BACKOFFICE_VERSION = 1.25
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
@ -45,7 +45,7 @@ INSTALLED_APPS = [
|
|||||||
'ckeditor_uploader',
|
'ckeditor_uploader',
|
||||||
'django_admin_json_editor',
|
'django_admin_json_editor',
|
||||||
'rangefilter',
|
'rangefilter',
|
||||||
'django_crontab'
|
'django_cron',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@ -183,7 +183,7 @@ CACHES = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CRONJOBS = [
|
CRON_CLASSES = [
|
||||||
('4 */1 * * *', 'aitrainer_backoffice.controlling.cron.sync_customers')
|
'aitrainer_backoffice.controlling.cron.sync_customers',
|
||||||
|
# ...
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
from ..mautic import MauticHelper
|
from ..mautic import MauticHelper
|
||||||
|
from django_cron import CronJobBase, Schedule
|
||||||
|
|
||||||
|
|
||||||
|
class MyCronJob(CronJobBase):
|
||||||
|
RUN_EVERY_MINS = 60 # every 2 hours
|
||||||
|
|
||||||
|
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
|
||||||
|
code = 'aitrainer_backoffice.controlling.cron' # a unique code
|
||||||
|
|
||||||
|
def do(self):
|
||||||
|
sync_customers() # do your thing here
|
||||||
|
|
||||||
|
|
||||||
def sync_customers():
|
def sync_customers():
|
||||||
helper = MauticHelper()
|
helper = MauticHelper()
|
||||||
helper.sync()
|
helper.syncTrial()
|
@ -1,12 +1,17 @@
|
|||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
|
import datetime
|
||||||
|
|
||||||
from ..models.customer import Customer
|
from ..models.customer import Customer
|
||||||
|
|
||||||
|
|
||||||
class MauticHelper:
|
class MauticHelper:
|
||||||
|
|
||||||
|
def syncTrial(self):
|
||||||
|
tenDays = datetime.datetime - datetime.timedelta(days=10)
|
||||||
|
qs = Customer.objects.raw(
|
||||||
|
'SELECT * from customer WHERE trial_date < "' + tenDays + '" and trial_date is not null')
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -13,5 +13,5 @@ mysqlclient==2.0.1
|
|||||||
requests==2.24.0
|
requests==2.24.0
|
||||||
pillow==7.2.0
|
pillow==7.2.0
|
||||||
gunicorn==20.0.4
|
gunicorn==20.0.4
|
||||||
django-crontab==0.7.1
|
django-cron==0.5.1
|
||||||
django-admin-rangefilter==0.8.1
|
django-admin-rangefilter==0.8.1
|
Loading…
Reference in New Issue
Block a user