diff --git a/TODO.md b/TODO.md
index c9c6617c..22cae58c 100644
--- a/TODO.md
+++ b/TODO.md
@@ -284,12 +284,9 @@ https://code.djangoproject.com/ticket/24576
# TODO orchestra related services code reload: celery/uwsgi reloading find aonther way without root and implement reload
-# size monitor of @002 @003 database names
# password validation cracklib on change password form=?????
# reset setting button
-# periodic cleaning of spam mailboxes
-
# admin edit relevant djanog settings
# django SITE_NAME vs ORCHESTRA_SITE_NAME ?
@@ -365,9 +362,6 @@ pip3 install https://github.com/fantix/gevent/archive/master.zip
# SIgnal handler for notify workers to reload stuff, like resource sync: https://docs.python.org/2/library/signal.html
-# INVOICE fucking Id based on order ID or what?
-
-# user order_id as bill line id
# BUG Delete related services also deletes account!
# auto apend trailing slash
@@ -375,17 +369,11 @@ pip3 install https://github.com/fantix/gevent/archive/master.zip
# uwsgi hot reload? http://uwsgi-docs.readthedocs.org/en/latest/articles/TheArtOfGracefulReloading.html
-
# change mailer.message.priority by, queue/sent inmediatelly or rename critical to noq
-# method(
+method(
arg, arg, arg)
-
-# Finish Nested *resource* serializers, like websites.domains: make fields readonly: read_only_fields = ('name',)
-# websites.directives full validation like directive formset: move formset validation out and call it with compat-data from both places
-
-
-# apply normlocation function on unique_location validation
+# Restart postfix on user pwd change/disabling
diff --git a/orchestra/admin/menu.py b/orchestra/admin/menu.py
index fdef845c..78b96f0d 100644
--- a/orchestra/admin/menu.py
+++ b/orchestra/admin/menu.py
@@ -6,7 +6,6 @@ from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from orchestra.core import services, accounts, administration
-from orchestra.utils.apps import isinstalled
def api_link(context):
diff --git a/orchestra/admin/options.py b/orchestra/admin/options.py
index 3396b97e..c6bab447 100644
--- a/orchestra/admin/options.py
+++ b/orchestra/admin/options.py
@@ -1,5 +1,5 @@
from django import forms
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from django.contrib import admin, messages
from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.admin.utils import unquote
@@ -68,9 +68,9 @@ class ChangeViewActionsMixin(object):
urls = super(ChangeViewActionsMixin, self).get_urls()
admin_site = self.admin_site
opts = self.model._meta
- new_urls = patterns('')
+ new_urls = []
for action in self.get_change_view_actions():
- new_urls += patterns('',
+ new_urls.append(
url('^(\d+)/%s/$' % action.url_name,
admin_site.admin_view(action),
name='%s_%s_%s' % (opts.app_label, opts.model_name, action.url_name)
@@ -187,11 +187,11 @@ class ChangePasswordAdminMixin(object):
def get_urls(self):
opts = self.model._meta
info = opts.app_label, opts.model_name
- return patterns('',
+ return [
url(r'^(\d+)/password/$',
self.admin_site.admin_view(self.change_password),
- name='%s_%s_change_password' % info),
- ) + super(ChangePasswordAdminMixin, self).get_urls()
+ name='%s_%s_change_password' % info)
+ ] + super(ChangePasswordAdminMixin, self).get_urls()
@sensitive_post_parameters_m
def change_password(self, request, id, form_url=''):
diff --git a/orchestra/conf/project_template/project_name/urls.py b/orchestra/conf/project_template/project_name/urls.py
index bda27e97..8dbfad58 100644
--- a/orchestra/conf/project_template/project_name/urls.py
+++ b/orchestra/conf/project_template/project_name/urls.py
@@ -1,6 +1,6 @@
-from django.conf.urls import patterns, include, url
+from django.conf.urls import include, url
-urlpatterns = patterns('',
+urlpatterns = [
url(r'', include('orchestra.urls')),
-)
+]
diff --git a/orchestra/contrib/accounts/actions.py b/orchestra/contrib/accounts/actions.py
index 27f00bf6..983aa80e 100644
--- a/orchestra/contrib/accounts/actions.py
+++ b/orchestra/contrib/accounts/actions.py
@@ -10,7 +10,7 @@ from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.html import format_html
from django.utils.text import capfirst
-from django.utils.translation import ungettext, ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _
from orchestra.core import services
@@ -69,7 +69,7 @@ def delete_related_services(modeladmin, request, queryset):
user = request.user
admin_site = modeladmin.admin_site
- def format(obj):
+ def format(obj, account=False):
has_admin = obj.__class__ in admin_site._registry
opts = obj._meta
no_edit_link = '%s: %s' % (capfirst(opts.verbose_name), force_text(obj))
@@ -87,7 +87,11 @@ def delete_related_services(modeladmin, request, queryset):
if not user.has_perm(p):
perms_needed.add(opts.verbose_name)
# Display a link to the admin page.
- return format_html('{}: {}', capfirst(opts.verbose_name), admin_url, obj)
+ context = (capfirst(opts.verbose_name), admin_url, obj)
+ if account:
+ context += (_("services to delete:"),)
+ return format_html('{} {} {}', *context)
+ return format_html('{}: {}', *context)
else:
# Don't display link to edit, because it either has no
# admin or is edited inline.
@@ -102,11 +106,12 @@ def delete_related_services(modeladmin, request, queryset):
else:
result.append(format(objs))
- for account in collector.nested():
- if isinstance(account, list):
+ for nested in collector.nested():
+ if isinstance(nested, list):
+ # Is lists of objects
current = []
is_service = False
- for service in account:
+ for service in nested:
if type(service) in registered_services:
if service == main_systemuser:
continue
@@ -121,10 +126,11 @@ def delete_related_services(modeladmin, request, queryset):
else:
is_service = False
related_services.append(current)
- elif isinstance(account, modeladmin.model):
+ elif isinstance(nested, modeladmin.model):
+ # Is account
# Prevent the deletion of the main system user, which will delete the account
- main_systemuser = account.main_systemuser
- related_services.append(format(account))
+ main_systemuser = nested.main_systemuser
+ related_services.append(format(nested, account=True))
# The user has already confirmed the deletion.
# Do the deletion and return a None to display the change list view again.
diff --git a/orchestra/contrib/accounts/admin.py b/orchestra/contrib/accounts/admin.py
index e0a7a61e..5e6a221b 100644
--- a/orchestra/contrib/accounts/admin.py
+++ b/orchestra/contrib/accounts/admin.py
@@ -3,7 +3,7 @@ import re
from urllib.parse import parse_qsl
from django import forms
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from django.contrib import admin, messages
from django.contrib.admin.utils import unquote
from django.contrib.auth import admin as auth
@@ -310,11 +310,11 @@ class SelectAccountAdminMixin(AccountAdminMixin):
opts = self.model._meta
info = opts.app_label, opts.model_name
account_list = AccountListAdmin(Account, admin_site).changelist_view
- select_urls = patterns("",
+ select_urls = [
url("/select-account/$",
wrap_admin_view(self, account_list),
name='%s_%s_select_account' % info),
- )
+ ]
return select_urls + urls
def add_view(self, request, form_url='', extra_context=None):
diff --git a/orchestra/contrib/accounts/settings.py b/orchestra/contrib/accounts/settings.py
index 7dfab167..9ec510e7 100644
--- a/orchestra/contrib/accounts/settings.py
+++ b/orchestra/contrib/accounts/settings.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.settings import Setting
diff --git a/orchestra/contrib/bills/admin.py b/orchestra/contrib/bills/admin.py
index 478d7db8..f834a15b 100644
--- a/orchestra/contrib/bills/admin.py
+++ b/orchestra/contrib/bills/admin.py
@@ -1,10 +1,10 @@
from django import forms
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from django.contrib import admin
from django.contrib.admin.utils import unquote
from django.core.urlresolvers import reverse
from django.db import models
-from django.db.models import F, Sum, Prefetch
+from django.db.models import F, Sum
from django.db.models.functions import Coalesce
from django.templatetags.static import static
from django.utils.safestring import mark_safe
@@ -17,7 +17,7 @@ from orchestra.forms.widgets import paddingCheckboxSelectMultiple
from . import settings, actions
from .filters import BillTypeListFilter, HasBillContactListFilter
-from .models import Bill, Invoice, AmendmentInvoice, Fee, AmendmentFee, ProForma, BillLine, BillSubline, BillContact
+from .models import Bill, Invoice, AmendmentInvoice, Fee, AmendmentFee, ProForma, BillLine, BillContact
PAYMENT_STATE_COLORS = {
@@ -229,11 +229,11 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
""" Hook bill lines management URLs on bill admin """
urls = super(BillAdmin, self).get_urls()
admin_site = self.admin_site
- extra_urls = patterns("",
+ extra_urls = [
url("^manage-lines/$",
admin_site.admin_view(BillLineManagerAdmin(BillLine, admin_site).changelist_view),
name='bills_bill_manage_lines'),
- )
+ ]
return extra_urls + urls
def get_readonly_fields(self, request, obj=None):
diff --git a/orchestra/contrib/bills/settings.py b/orchestra/contrib/bills/settings.py
index 0f131b2d..611a749a 100644
--- a/orchestra/contrib/bills/settings.py
+++ b/orchestra/contrib/bills/settings.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django_countries import data
from orchestra.contrib.settings import Setting
diff --git a/orchestra/contrib/databases/admin.py b/orchestra/contrib/databases/admin.py
index 6d90ede1..184968e4 100644
--- a/orchestra/contrib/databases/admin.py
+++ b/orchestra/contrib/databases/admin.py
@@ -1,4 +1,4 @@
-from django.conf.urls import patterns
+from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _
@@ -103,10 +103,10 @@ class DatabaseUserAdmin(SelectAccountAdminMixin, ChangePasswordAdminMixin, Exten
def get_urls(self):
useradmin = UserAdmin(DatabaseUser, self.admin_site)
- return patterns('',
- (r'^(\d+)/password/$',
- self.admin_site.admin_view(useradmin.user_change_password))
- ) + super(DatabaseUserAdmin, self).get_urls()
+ return [
+ url(r'^(\d+)/password/$',
+ self.admin_site.admin_view(useradmin.user_change_password))
+ ] + super(DatabaseUserAdmin, self).get_urls()
def save_model(self, request, obj, form, change):
""" set password """
diff --git a/orchestra/contrib/databases/backends.py b/orchestra/contrib/databases/backends.py
index 8c216b61..204b4b8f 100644
--- a/orchestra/contrib/databases/backends.py
+++ b/orchestra/contrib/databases/backends.py
@@ -150,11 +150,12 @@ class MysqlDisk(ServiceMonitor):
if db.type != db.MYSQL:
return
context = self.get_context(db)
- self.append('echo %(db_id)s $(monitor "%(db_name)s")' % context)
+ self.append('echo %(db_id)s $(monitor "%(db_dirname)s")' % context)
def get_context(self, db):
context = {
'db_name': db.name,
+ 'db_dirname': db.name.replace('-', '@003f'),
'db_id': db.pk,
}
return replace(replace(context, "'", '"'), ';', '')
diff --git a/orchestra/contrib/databases/serializers.py b/orchestra/contrib/databases/serializers.py
index 0ac90f08..7f556193 100644
--- a/orchestra/contrib/databases/serializers.py
+++ b/orchestra/contrib/databases/serializers.py
@@ -1,6 +1,3 @@
-from django.forms import widgets
-from django.shortcuts import get_object_or_404
-from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from orchestra.api.serializers import (HyperlinkedModelSerializer,
diff --git a/orchestra/contrib/domains/admin.py b/orchestra/contrib/domains/admin.py
index cfe14696..f2ce1a53 100644
--- a/orchestra/contrib/domains/admin.py
+++ b/orchestra/contrib/domains/admin.py
@@ -1,5 +1,3 @@
-import re
-
from django import forms
from django.contrib import admin
from django.db.models.functions import Concat, Coalesce
diff --git a/orchestra/contrib/issues/admin.py b/orchestra/contrib/issues/admin.py
index d837366d..b6d702ac 100644
--- a/orchestra/contrib/issues/admin.py
+++ b/orchestra/contrib/issues/admin.py
@@ -1,5 +1,5 @@
from django import forms
-from django.conf.urls import patterns
+from django.conf.urls import url
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.db import models
@@ -244,11 +244,10 @@ class TicketAdmin(ChangeListDefaultFilter, ExtendedModelAdmin):
def get_urls(self):
""" add markdown preview url """
- urls = super(TicketAdmin, self).get_urls()
- my_urls = patterns('',
- (r'^preview/$', wrap_admin_view(self, self.message_preview_view))
- )
- return my_urls + urls
+ return [
+ url(r'^preview/$',
+ wrap_admin_view(self, self.message_preview_view))
+ ] + super(TicketAdmin, self).get_urls()
def add_view(self, request, form_url='', extra_context=None):
""" Do not sow message inlines """
diff --git a/orchestra/contrib/issues/serializers.py b/orchestra/contrib/issues/serializers.py
index cc578a4d..37d53cce 100644
--- a/orchestra/contrib/issues/serializers.py
+++ b/orchestra/contrib/issues/serializers.py
@@ -19,13 +19,9 @@ class MessageSerializer(serializers.HyperlinkedModelSerializer):
def get_identity(self, data):
return data.get('id')
- def create(self, validated_data):
- validated_data['account'] = self.account
- return super(AccountSerializerMixin, self).create(validated_data)
-
def create(self, validated_data):
validated_data['author'] = self.context['request'].user
- super(MessageSerializer, self).create(validated_data)
+ return super(MessageSerializer, self).create(validated_data)
class TicketSerializer(serializers.HyperlinkedModelSerializer):
diff --git a/orchestra/contrib/lists/admin.py b/orchestra/contrib/lists/admin.py
index dcf9592b..f4861270 100644
--- a/orchestra/contrib/lists/admin.py
+++ b/orchestra/contrib/lists/admin.py
@@ -1,5 +1,5 @@
from django.contrib import admin
-from django.conf.urls import patterns
+from django.conf.urls import url
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _
@@ -59,10 +59,10 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
def get_urls(self):
useradmin = UserAdmin(List, self.admin_site)
- return patterns('',
- (r'^(\d+)/password/$',
- self.admin_site.admin_view(useradmin.user_change_password))
- ) + super(ListAdmin, self).get_urls()
+ return [
+ url(r'^(\d+)/password/$',
+ self.admin_site.admin_view(useradmin.user_change_password))
+ ] + super(ListAdmin, self).get_urls()
admin.site.register(List, ListAdmin)
diff --git a/orchestra/contrib/lists/backends.py b/orchestra/contrib/lists/backends.py
index f50aeeef..be2fd868 100644
--- a/orchestra/contrib/lists/backends.py
+++ b/orchestra/contrib/lists/backends.py
@@ -1,9 +1,7 @@
-import re
import textwrap
from django.utils.translation import ugettext_lazy as _
-from orchestra.contrib.domains.models import Domain, Record
from orchestra.contrib.orchestration import ServiceController, replace
from orchestra.contrib.resources import ServiceMonitor
diff --git a/orchestra/contrib/lists/serializers.py b/orchestra/contrib/lists/serializers.py
index 22676841..ad6f2381 100644
--- a/orchestra/contrib/lists/serializers.py
+++ b/orchestra/contrib/lists/serializers.py
@@ -1,7 +1,6 @@
from django.core.validators import RegexValidator
from django.forms import widgets
from django.utils.translation import ugettext_lazy as _
-from django.shortcuts import get_object_or_404
from rest_framework import serializers
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
diff --git a/orchestra/contrib/mailboxes/backends.py b/orchestra/contrib/mailboxes/backends.py
index e007c9f1..1993a7e5 100644
--- a/orchestra/contrib/mailboxes/backends.py
+++ b/orchestra/contrib/mailboxes/backends.py
@@ -6,10 +6,8 @@ import textwrap
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
-from orchestra.contrib.domains.models import Domain, Record
from orchestra.contrib.orchestration import ServiceController, replace
from orchestra.contrib.resources import ServiceMonitor
-#from orchestra.utils.humanize import unit_to_bytes
from . import settings
from .models import Address
@@ -63,9 +61,12 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
context = self.get_context(mailbox)
self.append(textwrap.dedent("""
if [[ $( id %(user)s ) ]]; then
- usermod %(user)s --password '%(password)s' --shell %(initial_shell)s
+ # Fucking postfix SASL caches credentials
+ old_password=$(grep "^%(user)s:" /etc/shadow|cut -d':' -f2)
+ usermod %(user)s --password '%(password)s' --shell %(initial_shell)s
+ [[ "$old_password" != "%(password)s" ]] && RESTART_POSTFIX=1
else
- useradd %(user)s --home %(home)s --password '%(password)s'
+ useradd %(user)s --home %(home)s --password '%(password)s'
fi
mkdir -p %(home)s
chmod 751 %(home)s
@@ -95,10 +96,15 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
self.append(textwrap.dedent("""
nohup bash -c '{ sleep 2 && killall -u %(user)s -s KILL; }' &> /dev/null &
killall -u %(user)s || true
- userdel %(user)s || true
+ # Fucking postfix SASL caches credentials
+ userdel %(user)s || true && RESTART_POSTFIX=1
groupdel %(user)s || true""") % context
)
+ def commit(self):
+ self.append('[[ $RESTART_POSTFIX -eq 1 ]] && service postfix restart')
+ super(UNIXUserMaildirBackend, self).commit()
+
def get_context(self, mailbox):
context = {
'user': mailbox.name,
diff --git a/orchestra/contrib/mailboxes/serializers.py b/orchestra/contrib/mailboxes/serializers.py
index a6ac948c..18bc09ce 100644
--- a/orchestra/contrib/mailboxes/serializers.py
+++ b/orchestra/contrib/mailboxes/serializers.py
@@ -1,6 +1,3 @@
-from django.forms import widgets
-from django.shortcuts import get_object_or_404
-from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
diff --git a/orchestra/contrib/mailboxes/tests/functional_tests/tests.py b/orchestra/contrib/mailboxes/tests/functional_tests/tests.py
index c9d35c30..57a6bec8 100644
--- a/orchestra/contrib/mailboxes/tests/functional_tests/tests.py
+++ b/orchestra/contrib/mailboxes/tests/functional_tests/tests.py
@@ -280,11 +280,6 @@ class RESTMailboxMixin(MailboxMixin):
mailbox = self.rest.mailboxes.retrieve(name=username).get()
self.rest.addresses.delete()
- @save_response_on_error
- def change_password(self, username, password):
- mailbox = self.rest.mailboxes.retrieve(name=username).get()
- mailbox.set_password(password=password)
-
@save_response_on_error
def disable(self, username):
mailbox = self.rest.mailboxes.retrieve(name=username).get()
diff --git a/orchestra/contrib/mailboxes/validators.py b/orchestra/contrib/mailboxes/validators.py
index 26ecee88..447a5feb 100644
--- a/orchestra/contrib/mailboxes/validators.py
+++ b/orchestra/contrib/mailboxes/validators.py
@@ -2,7 +2,6 @@ import hashlib
import os
import re
-from django.core.management.base import CommandError
from django.core.validators import ValidationError, EmailValidator
from django.utils.translation import ugettext_lazy as _
diff --git a/orchestra/contrib/mailer/admin.py b/orchestra/contrib/mailer/admin.py
index fc786de5..17938e0a 100644
--- a/orchestra/contrib/mailer/admin.py
+++ b/orchestra/contrib/mailer/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from django.core.urlresolvers import reverse
-from django.db.models import Count, Prefetch
+from django.db.models import Count
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
diff --git a/orchestra/contrib/mailer/backends.py b/orchestra/contrib/mailer/backends.py
index af5efc0c..65de5cdf 100644
--- a/orchestra/contrib/mailer/backends.py
+++ b/orchestra/contrib/mailer/backends.py
@@ -14,8 +14,9 @@ class EmailBackend(BaseEmailBackend):
return
num_sent = 0
is_bulk = len(email_messages) > 1
+ default_priority = Message.NORMAL if is_bulk else Message.CRITICAL
for message in email_messages:
- priority = message.extra_headers.get('X-Mail-Priority', Message.NORMAL)
+ priority = message.extra_headers.get('X-Mail-Priority', default_priority)
content = message.message().as_string()
for to_email in message.recipients():
message = Message.objects.create(
@@ -25,7 +26,7 @@ class EmailBackend(BaseEmailBackend):
subject=message.subject,
content=content,
)
- if not is_bulk or priority == Message.CRITICAL:
+ if priority == Message.CRITICAL:
# send immidiately
send_message.apply_async(message)
num_sent += 1
diff --git a/orchestra/contrib/mailer/management/commands/sendpendingmessages.py b/orchestra/contrib/mailer/management/commands/sendpendingmessages.py
index 5bb413cf..23ba00cf 100644
--- a/orchestra/contrib/mailer/management/commands/sendpendingmessages.py
+++ b/orchestra/contrib/mailer/management/commands/sendpendingmessages.py
@@ -1,6 +1,4 @@
-import json
-
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
from orchestra.contrib.tasks.decorators import keep_state
diff --git a/orchestra/contrib/orchestration/backends.py b/orchestra/contrib/orchestration/backends.py
index 6b3c5bb6..2de392ab 100644
--- a/orchestra/contrib/orchestration/backends.py
+++ b/orchestra/contrib/orchestration/backends.py
@@ -1,4 +1,3 @@
-import re
from functools import partial
from django.apps import apps
diff --git a/orchestra/contrib/orchestration/manager.py b/orchestra/contrib/orchestration/manager.py
index 65159cff..cf66e212 100644
--- a/orchestra/contrib/orchestration/manager.py
+++ b/orchestra/contrib/orchestration/manager.py
@@ -2,7 +2,6 @@ import logging
import threading
import traceback
from collections import OrderedDict
-from functools import partial
from django.core.mail import mail_admins
diff --git a/orchestra/contrib/orchestration/methods.py b/orchestra/contrib/orchestration/methods.py
index 8ff5ed38..c51e372b 100644
--- a/orchestra/contrib/orchestration/methods.py
+++ b/orchestra/contrib/orchestration/methods.py
@@ -1,13 +1,10 @@
-import hashlib
import json
import logging
-import os
import socket
import sys
import select
from celery.datastructures import ExceptionInfo
-from django.conf import settings as djsettings
from orchestra.utils.sys import sshrun
from orchestra.utils.python import CaptureStdout, import_class
diff --git a/orchestra/contrib/orders/apps.py b/orchestra/contrib/orders/apps.py
index 2e54e2b2..5f8faedb 100644
--- a/orchestra/contrib/orders/apps.py
+++ b/orchestra/contrib/orders/apps.py
@@ -1,7 +1,6 @@
from django.apps import AppConfig
from orchestra.core import accounts
-from orchestra.utils.db import database_ready
class OrdersConfig(AppConfig):
diff --git a/orchestra/contrib/orders/billing.py b/orchestra/contrib/orders/billing.py
index fb9aa7b4..328e59ef 100644
--- a/orchestra/contrib/orders/billing.py
+++ b/orchestra/contrib/orders/billing.py
@@ -1,5 +1,3 @@
-import datetime
-
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.bills.models import Invoice, Fee, ProForma
diff --git a/orchestra/contrib/orders/filters.py b/orchestra/contrib/orders/filters.py
index aa8cd972..1e05166d 100644
--- a/orchestra/contrib/orders/filters.py
+++ b/orchestra/contrib/orders/filters.py
@@ -1,4 +1,4 @@
-from datetime import timedelta, datetime
+from datetime import timedelta
from django.contrib.admin import SimpleListFilter
from django.db.models import Q, Prefetch, F
@@ -6,7 +6,7 @@ from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
-from .models import MetricStorage, Order
+from .models import MetricStorage
class ActiveOrderListFilter(SimpleListFilter):
diff --git a/orchestra/contrib/orders/models.py b/orchestra/contrib/orders/models.py
index 744f8f37..6d20672f 100644
--- a/orchestra/contrib/orders/models.py
+++ b/orchestra/contrib/orders/models.py
@@ -10,7 +10,6 @@ from django.contrib.contenttypes.models import ContentType
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
-from orchestra.core import services
from orchestra.models import queryset
from orchestra.utils.python import import_class
diff --git a/orchestra/contrib/orders/signals.py b/orchestra/contrib/orders/signals.py
index 58f5cc84..568aa5e2 100644
--- a/orchestra/contrib/orders/signals.py
+++ b/orchestra/contrib/orders/signals.py
@@ -1,4 +1,4 @@
-from django.db.models.signals import post_delete, post_save, pre_delete
+from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from orchestra.core import services
diff --git a/orchestra/contrib/resources/admin.py b/orchestra/contrib/resources/admin.py
index afefa72d..46d8c3ca 100644
--- a/orchestra/contrib/resources/admin.py
+++ b/orchestra/contrib/resources/admin.py
@@ -1,4 +1,4 @@
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from django.contrib import admin, messages
from django.contrib.admin.utils import unquote
from django.contrib import contenttypes
@@ -121,12 +121,12 @@ class ResourceDataAdmin(ExtendedModelAdmin):
urls = super(ResourceDataAdmin, self).get_urls()
admin_site = self.admin_site
opts = self.model._meta
- return patterns('',
+ return [
url('^(\d+)/used-monitordata/$',
admin_site.admin_view(self.used_monitordata_view),
name='%s_%s_used_monitordata' % (opts.app_label, opts.model_name)
)
- ) + urls
+ ] + urls
def display_unit(self, data):
return data.unit
diff --git a/orchestra/contrib/saas/api.py b/orchestra/contrib/saas/api.py
index 2d968524..de226b38 100644
--- a/orchestra/contrib/saas/api.py
+++ b/orchestra/contrib/saas/api.py
@@ -3,7 +3,6 @@ from rest_framework import viewsets
from orchestra.api import router, LogApiMixin
from orchestra.contrib.accounts.api import AccountApiMixin
-from . import settings
from .models import SaaS
from .serializers import SaaSSerializer
diff --git a/orchestra/contrib/saas/serializers.py b/orchestra/contrib/saas/serializers.py
index c5c787de..6992e5f7 100644
--- a/orchestra/contrib/saas/serializers.py
+++ b/orchestra/contrib/saas/serializers.py
@@ -1,5 +1,4 @@
from django.forms import widgets
-from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
diff --git a/orchestra/contrib/services/admin.py b/orchestra/contrib/services/admin.py
index 0bddbb2a..7afb0263 100644
--- a/orchestra/contrib/services/admin.py
+++ b/orchestra/contrib/services/admin.py
@@ -1,5 +1,5 @@
from django import forms
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.template.response import TemplateResponse
@@ -46,12 +46,12 @@ class ServiceAdmin(ChangeViewActionsMixin, admin.ModelAdmin):
urls = super(ServiceAdmin, self).get_urls()
admin_site = self.admin_site
opts = self.model._meta
- return patterns('',
+ return [
url('^add/help/$',
admin_site.admin_view(self.help_view),
name='%s_%s_help' % (opts.app_label, opts.model_name)
)
- ) + urls
+ ] + urls
def formfield_for_dbfield(self, db_field, **kwargs):
""" Improve performance of account field and filter by account """
diff --git a/orchestra/contrib/services/apps.py b/orchestra/contrib/services/apps.py
index 43b2f55c..0b6d76e9 100644
--- a/orchestra/contrib/services/apps.py
+++ b/orchestra/contrib/services/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-from orchestra.core import administration, accounts
+from orchestra.core import administration
from orchestra.core.translations import ModelTranslation
diff --git a/orchestra/contrib/settings/__init__.py b/orchestra/contrib/settings/__init__.py
index 3be25c92..da705064 100644
--- a/orchestra/contrib/settings/__init__.py
+++ b/orchestra/contrib/settings/__init__.py
@@ -1,11 +1,9 @@
import re
-import sys
from collections import OrderedDict
from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.functional import Promise
-from django.utils.translation import ugettext_lazy as _
from orchestra.core import validators
from orchestra.utils.python import import_class, format_exception
diff --git a/orchestra/contrib/settings/admin.py b/orchestra/contrib/settings/admin.py
index 0f73fca2..27a94be1 100644
--- a/orchestra/contrib/settings/admin.py
+++ b/orchestra/contrib/settings/admin.py
@@ -1,14 +1,10 @@
-from functools import partial
-
from django.contrib import admin, messages
-from django.db import models
from django.shortcuts import render_to_response
from django.views import generic
from django.utils.translation import ngettext, ugettext_lazy as _
-from orchestra.admin.dashboard import OrchestraIndexDashboard
from orchestra.contrib.settings import Setting
-from orchestra.utils import sys, paths
+from orchestra.utils import sys
from . import parser
from .forms import SettingFormSet
@@ -66,7 +62,8 @@ class SettingView(generic.edit.FormView):
if not self.request.POST.get('confirmation'):
settings_file = parser.get_settings_file()
new_content = parser.apply(changes)
- diff = sys.run("cat <