From 5786cff38c6d13a8db250979bcbf37aefb571611 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Sat, 22 Oct 2016 07:23:45 +0000 Subject: [PATCH] Upgade to dj 1.10 --- TODO.md | 2 -- orchestra/admin/decorators.py | 3 +-- orchestra/admin/options.py | 4 +--- .../project_template/project_name/settings.py | 4 ++++ orchestra/contrib/domains/forms.py | 10 +++++----- orchestra/contrib/domains/validators.py | 2 +- orchestra/contrib/history/admin.py | 2 +- orchestra/contrib/letsencrypt/actions.py | 3 +-- orchestra/contrib/orchestration/manager.py | 2 +- orchestra/contrib/saas/backends/wordpressmu.py | 17 ++++++++++------- orchestra/contrib/systemusers/actions.py | 6 ++---- requirements.txt | 2 +- 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/TODO.md b/TODO.md index 33c40a68..26b041ab 100644 --- a/TODO.md +++ b/TODO.md @@ -465,8 +465,6 @@ with open(file) as handler: # Add confirmation step on transaction actions like process transaction - # SAVE INISTIAL PASSWORD from all services, and just use it to create the service, never update it - # Don't use system groups for unixmailbackends diff --git a/orchestra/admin/decorators.py b/orchestra/admin/decorators.py index 4c5abcae..5daf00dd 100644 --- a/orchestra/admin/decorators.py +++ b/orchestra/admin/decorators.py @@ -96,7 +96,6 @@ def action_with_confirmation(action_name=None, extra_context=None, validator=Non context['display_objects'] = format_display_objects(modeladmin, request, queryset) # Display the confirmation page - return TemplateResponse(request, template, - context, current_app=modeladmin.admin_site.name) + return TemplateResponse(request, template, context) return inner return decorator diff --git a/orchestra/admin/options.py b/orchestra/admin/options.py index f49be37d..f8b20367 100644 --- a/orchestra/admin/options.py +++ b/orchestra/admin/options.py @@ -330,9 +330,7 @@ class ChangePasswordAdminMixin(object): 'password': random_ascii(10), } context.update(admin.site.each_context(request)) - return TemplateResponse(request, - self.change_user_password_template, - context, current_app=self.admin_site.name) + return TemplateResponse(request, self.change_user_password_template, context) def show_hash(self, request, id): if not request.user.is_superuser: diff --git a/orchestra/conf/project_template/project_name/settings.py b/orchestra/conf/project_template/project_name/settings.py index dc683c45..571f8762 100644 --- a/orchestra/conf/project_template/project_name/settings.py +++ b/orchestra/conf/project_template/project_name/settings.py @@ -196,6 +196,10 @@ AUTHENTICATION_BACKENDS = [ EMAIL_BACKEND = 'orchestra.contrib.mailer.backends.EmailBackend' +# Needed for Bulk operations +DATA_UPLOAD_MAX_NUMBER_FIELDS = None + + ################################# ## 3RD PARTY APPS CONIGURATION ## ################################# diff --git a/orchestra/contrib/domains/forms.py b/orchestra/contrib/domains/forms.py index 4bdebcdb..95ae47ec 100644 --- a/orchestra/contrib/domains/forms.py +++ b/orchestra/contrib/domains/forms.py @@ -97,10 +97,10 @@ class ValidateZoneMixin(object): super(ValidateZoneMixin, self).clean() if any(self.errors): return - has_srv = False + is_host = True for form in self.forms: - has_srv = form.cleaned_data.get('type') == Record.SRV - if has_srv: + if form.cleaned_data.get('type') in (Record.TXT, Record.SRV, Record.CNAME): + is_host = False break domain_names = [] if self.instance.name: @@ -113,9 +113,9 @@ class ValidateZoneMixin(object): data = form.cleaned_data if data and not data['DELETE']: records.append(data) - if '_' in name and not has_srv: + if '_' in name and is_host: errors.append(ValidationError( - _("%s: Domains containing underscore character '_' must provide an SRV record.") % name + _("%s: Hosts can not have underscore character '_', consider providing a SRV, CNAME or TXT record.") % name )) domain = domain_for_validation(self.instance, records) try: diff --git a/orchestra/contrib/domains/validators.py b/orchestra/contrib/domains/validators.py index 47830688..b37600ce 100644 --- a/orchestra/contrib/domains/validators.py +++ b/orchestra/contrib/domains/validators.py @@ -29,7 +29,7 @@ def validate_allowed_domain(value): def validate_domain_name(value): - # SRV records may use '_' in the domain name + # SRV, CNAME and TXT records may use '_' in the domain name value = value.lstrip('*.').replace('_', '') try: validate_hostname(value) diff --git a/orchestra/contrib/history/admin.py b/orchestra/contrib/history/admin.py index 7d2b86e5..09a35e07 100644 --- a/orchestra/contrib/history/admin.py +++ b/orchestra/contrib/history/admin.py @@ -47,7 +47,7 @@ class LogEntryAdmin(admin.ModelAdmin): elif log.is_change(): return _('Changed "%(link)s" - %(changes)s %(edit)s') % { 'link': self.content_object_link(log), - 'changes': log.change_message, + 'changes': log.get_change_message(), 'edit': edit, } elif log.is_deletion(): diff --git a/orchestra/contrib/letsencrypt/actions.py b/orchestra/contrib/letsencrypt/actions.py index a4d6ce8a..b484494f 100644 --- a/orchestra/contrib/letsencrypt/actions.py +++ b/orchestra/contrib/letsencrypt/actions.py @@ -111,6 +111,5 @@ def letsencrypt(modeladmin, request, queryset): 'action_checkbox_name': admin.helpers.ACTION_CHECKBOX_NAME, 'form': form, } - return TemplateResponse(request, 'admin/orchestra/generic_confirmation.html', - context, current_app=modeladmin.admin_site.name) + return TemplateResponse(request, 'admin/orchestra/generic_confirmation.html', context) letsencrypt.short_description = "Let's encrypt!" diff --git a/orchestra/contrib/orchestration/manager.py b/orchestra/contrib/orchestration/manager.py index 4a3fb719..eafe8422 100644 --- a/orchestra/contrib/orchestration/manager.py +++ b/orchestra/contrib/orchestration/manager.py @@ -30,7 +30,7 @@ def keep_log(execute, log, operations): except Exception as e: trace = traceback.format_exc() log.state = log.EXCEPTION - log.stderr = trace + log.stderr += trace log.save() subject = 'EXCEPTION executing backend(s) %s %s' % (args, kwargs) logger.error(subject) diff --git a/orchestra/contrib/saas/backends/wordpressmu.py b/orchestra/contrib/saas/backends/wordpressmu.py index 9fb5a47e..6dcbf8a9 100644 --- a/orchestra/contrib/saas/backends/wordpressmu.py +++ b/orchestra/contrib/saas/backends/wordpressmu.py @@ -31,10 +31,12 @@ class WordpressMuController(ServiceController): def with_retry(self, method, *args, retries=1, sleep=0.5, **kwargs): for i in range(retries): try: - return method(*args, **kwargs) + return method(*args, verify=self.VERIFY, **kwargs) except requests.exceptions.ConnectionError: if i >= retries: raise + sys.stderr.write("Connection error while {method}{args}, retry {i}/{retries}\n".format( + method=method.__name__, args=str(args), i=i, retries=retries)) time.sleep(sleep) def login(self, session): @@ -46,7 +48,7 @@ class WordpressMuController(ServiceController): 'redirect_to': '/wp-admin/' } sys.stdout.write("Login URL: %s\n" % login_url) - response = self.with_retry(session.post, login_url, data=login_data, verify=self.VERIFY) + response = self.with_retry(session.post, login_url, data=login_data) if response.url != main_url + '/wp-admin/': raise IOError("Failure login to remote application (%s)" % login_url) @@ -69,7 +71,8 @@ class WordpressMuController(ServiceController): 'class="edit">%s' % saas.name ) sys.stdout.write("Search URL: %s\n" % search) - content = self.with_retry(session.get, search, verify=self.VERIFY).content.decode('utf8') + response = self.with_retry(session.get, search) + content = response.content.decode('utf8') # Get id ids = regex.search(content) if not ids and not blog_id: @@ -94,7 +97,7 @@ class WordpressMuController(ServiceController): url = self.get_main_url() url += '/wp-admin/network/site-new.php' sys.stdout.write("Create URL: %s\n" % url) - content = self.with_retry(session.get, url, verify=self.VERIFY).content.decode('utf8') + content = self.with_retry(session.get, url).content.decode('utf8') wpnonce = re.compile('name="_wpnonce_add-blog"\s+value="([^"]*)"') try: @@ -111,7 +114,7 @@ class WordpressMuController(ServiceController): } # Validate response - response = self.with_retry(session.post, url, data=data, verify=self.VERIFY) + response = self.with_retry(session.post, url, data=data) self.validate_response(response) blog_id = re.compile(r'') content = response.content.decode('utf8') @@ -130,7 +133,7 @@ class WordpressMuController(ServiceController): action_url = re.search(url_regex, content).groups()[0].replace("&", '&') sys.stdout.write("%s confirm URL: %s\n" % (action, action_url)) - content = self.with_retry(session.get, action_url, verify=self.VERIFY).content.decode('utf8') + content = self.with_retry(session.get, action_url).content.decode('utf8') wpnonce = re.compile('name="_wpnonce"\s+value="([^"]*)"') try: wpnonce = wpnonce.search(content).groups()[0] @@ -145,7 +148,7 @@ class WordpressMuController(ServiceController): action_url = self.get_main_url() action_url += '/wp-admin/network/sites.php?action=%sblog' % action sys.stdout.write("%s URL: %s\n" % (action, action_url)) - response = self.with_retry(session.post, action_url, data=data, verify=self.VERIFY) + response = self.with_retry(session.post, action_url, data=data) self.validate_response(response) def is_active(self, content): diff --git a/orchestra/contrib/systemusers/actions.py b/orchestra/contrib/systemusers/actions.py index 6c3b0e80..f2e53ec5 100644 --- a/orchestra/contrib/systemusers/actions.py +++ b/orchestra/contrib/systemusers/actions.py @@ -71,8 +71,7 @@ def set_permission(modeladmin, request, queryset): 'action_checkbox_name': admin.helpers.ACTION_CHECKBOX_NAME, 'form': form, } - return TemplateResponse(request, 'admin/systemusers/systemuser/set_permission.html', - context, current_app=modeladmin.admin_site.name) + return TemplateResponse(request, 'admin/systemusers/systemuser/set_permission.html', context) set_permission.url_name = 'set-permission' set_permission.tool_description = _("Set permission") @@ -126,8 +125,7 @@ def create_link(modeladmin, request, queryset): 'action_checkbox_name': admin.helpers.ACTION_CHECKBOX_NAME, 'form': form, } - return TemplateResponse(request, 'admin/systemusers/systemuser/create_link.html', - context, current_app=modeladmin.admin_site.name) + return TemplateResponse(request, 'admin/systemusers/systemuser/create_link.html', context) create_link.url_name = 'create-link' create_link.tool_description = _("Create link") diff --git a/requirements.txt b/requirements.txt index b4b0a0b7..be8472c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ Markdown==2.4 djangorestframework==3.4.7 ecdsa==0.11 Pygments==1.6 -django-filter==0.7 +django-filter==0.15.2 jsonfield==0.9.22 python-dateutil==2.2 https://github.com/glic3rinu/passlib/archive/master.zip