From 94941a633fdd31ac33aa4f36b7bc6d0592909287 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Thu, 30 Apr 2015 11:24:18 +0000 Subject: [PATCH] Fixes on webapps --- TODO.md | 29 +++++++++++++++++++++++ orchestra/api/actions.py | 2 +- orchestra/conf/base_settings.py | 1 - orchestra/contrib/webapps/backends/php.py | 1 + orchestra/contrib/webapps/models.py | 1 + orchestra/contrib/webapps/types/cms.py | 4 ++-- orchestra/utils/options.py | 4 +++- 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 97a0c760..6448070f 100644 --- a/TODO.md +++ b/TODO.md @@ -298,3 +298,32 @@ https://code.djangoproject.com/ticket/24576 # django SITE_NAME vs ORCHESTRA_SITE_NAME ? # accounts.migrations link to last auth migration instead of first + + + +Replace celery by a custom solution? + * No more jumbo dependencies and wierd bugs + 1) Periodic Monitoring: + * runtask management command + crontab scheduling or high performance beat crontab (not loading bloated django system) + class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument('method', help='') + parser.add_argument('args', nargs='*', help='') + def handle(self, *args, **options): + method = import_class(options['method']) + kwargs = {} + arguments = [] + for arg in args: + if '=' in args: + name, value = arg.split('=') + kwargs[name] = value + else: + arguments.append(arg) + args = arguments + method(*args, **kwargs) + 2) Single time shot: + sys.run("python3 manage.py runtas 'task' args") + 3) Emails: + Custom backend that distinguishes between priority and bulk mail + priority: custom Thread backend + bulk: wrapper arround django-mailer to avoid loading django system diff --git a/orchestra/api/actions.py b/orchestra/api/actions.py index 55d6e176..246e40ff 100644 --- a/orchestra/api/actions.py +++ b/orchestra/api/actions.py @@ -6,7 +6,7 @@ from .serializers import SetPasswordSerializer class SetPasswordApiMixin(object): - @detail_route(serializer_class=SetPasswordSerializer) + @detail_route(methods=['post'], serializer_class=SetPasswordSerializer) def set_password(self, request, pk): obj = self.get_object() data = request.DATA diff --git a/orchestra/conf/base_settings.py b/orchestra/conf/base_settings.py index 3d085706..17ad8178 100644 --- a/orchestra/conf/base_settings.py +++ b/orchestra/conf/base_settings.py @@ -89,7 +89,6 @@ INSTALLED_APPS = ( 'orchestra.contrib.miscellaneous', 'orchestra.contrib.bills', 'orchestra.contrib.payments', - 'orchestra.contrib.tasks', # Third-party apps 'django_extensions', diff --git a/orchestra/contrib/webapps/backends/php.py b/orchestra/contrib/webapps/backends/php.py index 3cad18b4..88b11c47 100644 --- a/orchestra/contrib/webapps/backends/php.py +++ b/orchestra/contrib/webapps/backends/php.py @@ -135,6 +135,7 @@ class PHPBackend(WebAppServiceMixin, ServiceController): def get_options(self, webapp): kwargs = {} + print(webapp.data) if self.MERGE: kwargs = { 'webapp__account': webapp.account, diff --git a/orchestra/contrib/webapps/models.py b/orchestra/contrib/webapps/models.py index 6d78e504..9256919c 100644 --- a/orchestra/contrib/webapps/models.py +++ b/orchestra/contrib/webapps/models.py @@ -54,6 +54,7 @@ class WebApp(models.Model): def clean(self): apptype = self.type_instance apptype.validate() + a = apptype.clean_data() self.data = apptype.clean_data() @cached diff --git a/orchestra/contrib/webapps/types/cms.py b/orchestra/contrib/webapps/types/cms.py index 87509296..98dc64e7 100644 --- a/orchestra/contrib/webapps/types/cms.py +++ b/orchestra/contrib/webapps/types/cms.py @@ -92,10 +92,10 @@ class CMSApp(PHPApp): user.set_password(password) user.save() db.users.add(user) - self.instance.data = { + self.instance.data.update({ 'db_name': db_name, 'db_user': db_user, 'password': password, 'db_id': db.id, 'db_user_id': user.id, - } + }) diff --git a/orchestra/utils/options.py b/orchestra/utils/options.py index 7d58de9b..20f60785 100644 --- a/orchestra/utils/options.py +++ b/orchestra/utils/options.py @@ -47,9 +47,11 @@ def database_ready(): return (not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv and + # Celerybeat has yet to stablish a connection at AppConf.ready() 'celerybeat' not in sys.argv and + # Allow to run python manage.py without a database len(sys.argv) <= 1 and - '--help' in sys.argv) + '--help' not in sys.argv) def dict_setting_to_choices(choices):