BO 1.23 controlling, cron: sync customers
This commit is contained in:
@@ -12,3 +12,4 @@ from .training_plan import TrainingPlanAdmin, TrainingPlanDetailAdmin
|
||||
from .faq import FaqAdmin
|
||||
from .split_tests import SplitTestAdmin
|
||||
from .training_plan_day import TrainingPlanDayAdmin
|
||||
from .controlling import ControllingAdmin
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{% extends "admin/base_site.html" %}
|
||||
|
||||
{% block extrahead %}
|
||||
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p>Controlling</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
from django.contrib import admin
|
||||
from django.db import models
|
||||
from django.urls import path
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
class Controlling(models.Model):
|
||||
class Meta:
|
||||
verbose_name_plural = 'Controlling'
|
||||
app_label = 'aitrainer_backoffice'
|
||||
|
||||
|
||||
def my_custom_view(request):
|
||||
return HttpResponse('Admin Custom View')
|
||||
|
||||
|
||||
class ControllingAdmin(admin.ModelAdmin):
|
||||
model = Controlling
|
||||
|
||||
def get_urls(self):
|
||||
view_name = '{}_{}_changelist'.format(
|
||||
self.model._meta.app_label, self.model._meta.model_name)
|
||||
return [
|
||||
path('my_admin_path/', my_custom_view, name=view_name),
|
||||
]
|
||||
|
||||
|
||||
admin.site.register(Controlling, ControllingAdmin)
|
||||
admin.autodiscover()
|
||||
@@ -0,0 +1,22 @@
|
||||
class TestRouter:
|
||||
"""
|
||||
A router to control all database operations on models
|
||||
"""
|
||||
live_app_labels = {'controlling'}
|
||||
|
||||
def db_for_read(self, model, **hints):
|
||||
if model._meta.app_label == 'controlling':
|
||||
return 'live'
|
||||
else:
|
||||
return 'default'
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
if model._meta.app_label == 'controlling':
|
||||
raise Exception("This table cannot be changed!")
|
||||
return 'default'
|
||||
|
||||
def allow_relation(self, obj1, obj2, **hints):
|
||||
return True
|
||||
|
||||
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
||||
return False
|
||||
@@ -15,3 +15,4 @@ from .training_plan import TrainingPlan, TrainingPlanDetail
|
||||
from .faq import Faq, FaqTranslation
|
||||
from .split_tests import SplitTests
|
||||
from .training_plan_day import TrainingPlanDay, TrainingPlanDayTranslation
|
||||
from .controlling import Controlling
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Controlling(models.Model):
|
||||
sort = models.IntegerField(blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Controlling'
|
||||
app_label = 'controlling'
|
||||
@@ -0,0 +1,28 @@
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class MultiDBModelAdmin(admin.ModelAdmin):
|
||||
# A handy constant for the name of the alternate database.
|
||||
using = 'default'
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
# Tell Django to save objects to the 'other' database.
|
||||
obj.save(using=self.using)
|
||||
|
||||
def delete_model(self, request, obj):
|
||||
# Tell Django to delete objects from the 'other' database
|
||||
obj.delete(using=self.using)
|
||||
|
||||
def get_queryset(self, request):
|
||||
# Tell Django to look for objects on the 'other' database.
|
||||
return super().get_queryset(request).using(self.using)
|
||||
|
||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ForeignKey widgets using a query
|
||||
# on the 'other' database.
|
||||
return super().formfield_for_foreignkey(db_field, request, using=self.using, **kwargs)
|
||||
|
||||
def formfield_for_manytomany(self, db_field, request, **kwargs):
|
||||
# Tell Django to populate ManyToMany widgets using a query
|
||||
# on the 'other' database.
|
||||
return super().formfield_for_manytomany(db_field, request, using=self.using, **kwargs)
|
||||
@@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
||||
|
||||
import os
|
||||
|
||||
BACKOFFICE_VERSION = 1.22
|
||||
BACKOFFICE_VERSION = 1.23
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -38,6 +38,7 @@ ALLOWED_HOSTS = ['localhost']
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'aitrainer_backoffice',
|
||||
'controlling.apps.ControllingConfig',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@@ -47,6 +48,8 @@ INSTALLED_APPS = [
|
||||
'ckeditor',
|
||||
'ckeditor_uploader',
|
||||
'django_admin_json_editor',
|
||||
'rangefilter',
|
||||
'django_crontab'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -93,7 +96,7 @@ DATABASES = {
|
||||
},
|
||||
'live': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'aitrainer2',
|
||||
'NAME': 'aitrainer',
|
||||
'USER': 'aitrainer',
|
||||
'PASSWORD': 'andio2009',
|
||||
'HOST': '127.0.0.1',
|
||||
@@ -101,6 +104,8 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ['aitrainer_backoffice.db_router.TestRouter']
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
|
||||
|
||||
@@ -166,3 +171,7 @@ LOGGING = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
CRONJOBS = [
|
||||
('4 */1 * * *', 'controlling.cron.sync_customers')
|
||||
]
|
||||
|
||||
@@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
||||
|
||||
import os
|
||||
|
||||
BACKOFFICE_VERSION = 1.22
|
||||
BACKOFFICE_VERSION = 1.23
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -34,6 +34,7 @@ ALLOWED_HOSTS = ['62.171.188.119', 'localhost', 'andio.eu', 'aitrainer.info','ai
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'aitrainer_backoffice.aitrainer_backoffice',
|
||||
'controlling.apps.ControllingConfig',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@@ -43,6 +44,8 @@ INSTALLED_APPS = [
|
||||
'ckeditor',
|
||||
'ckeditor_uploader',
|
||||
'django_admin_json_editor',
|
||||
'rangefilter',
|
||||
'django_crontab'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -89,6 +92,8 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ['aitrainer_backoffice.db_router.TestRouter']
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
|
||||
|
||||
@@ -170,3 +175,7 @@ CACHES = {
|
||||
}
|
||||
}
|
||||
|
||||
CRONJOBS = [
|
||||
('4 */1 * * *', 'controlling.cron.sync_customers')
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends 'admin/change_list.html' %}
|
||||
|
||||
{% block object-tools %}
|
||||
<div>
|
||||
<form action="mautic/" method="POST">
|
||||
{% csrf_token %}
|
||||
<button type="submit">Mautic Sync</button>
|
||||
</form>
|
||||
</div>
|
||||
<br />
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user