Removed unused imports and patterns

This commit is contained in:
Marc Aymerich 2015-05-19 13:27:04 +00:00
parent 907250d2e7
commit 21b3544895
64 changed files with 121 additions and 171 deletions

16
TODO.md
View file

@ -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

View file

@ -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):

View file

@ -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=''):

View file

@ -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')),
)
]

View file

@ -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('{}: <a href="{}">{}</a>', capfirst(opts.verbose_name), admin_url, obj)
context = (capfirst(opts.verbose_name), admin_url, obj)
if account:
context += (_("services to delete:"),)
return format_html('{} <a href="{}">{}</a> {}', *context)
return format_html('{}: <a href="{}">{}</a>', *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.

View file

@ -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):

View file

@ -1,4 +1,3 @@
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.settings import Setting

View file

@ -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):

View file

@ -1,4 +1,3 @@
from django.conf import settings
from django_countries import data
from orchestra.contrib.settings import Setting

View file

@ -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/$',
return [
url(r'^(\d+)/password/$',
self.admin_site.admin_view(useradmin.user_change_password))
) + super(DatabaseUserAdmin, self).get_urls()
] + super(DatabaseUserAdmin, self).get_urls()
def save_model(self, request, obj, form, change):
""" set password """

View file

@ -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, "'", '"'), ';', '')

View file

@ -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,

View file

@ -1,5 +1,3 @@
import re
from django import forms
from django.contrib import admin
from django.db.models.functions import Concat, Coalesce

View file

@ -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 """

View file

@ -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):

View file

@ -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/$',
return [
url(r'^(\d+)/password/$',
self.admin_site.admin_view(useradmin.user_change_password))
) + super(ListAdmin, self).get_urls()
] + super(ListAdmin, self).get_urls()
admin.site.register(List, ListAdmin)

View file

@ -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

View file

@ -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

View file

@ -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,7 +61,10 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
context = self.get_context(mailbox)
self.append(textwrap.dedent("""
if [[ $( id %(user)s ) ]]; then
# 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'
fi
@ -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,

View file

@ -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

View file

@ -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()

View file

@ -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 _

View file

@ -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 _

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,3 @@
import re
from functools import partial
from django.apps import apps

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,6 @@
from django.apps import AppConfig
from orchestra.core import accounts
from orchestra.utils.db import database_ready
class OrdersConfig(AppConfig):

View file

@ -1,5 +1,3 @@
import datetime
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.bills.models import Invoice, Fee, ProForma

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 """

View file

@ -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

View file

@ -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

View file

@ -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 <<EOF | diff %s -\n%s\nEOF" % (settings_file, new_content), valid_codes=(1, 0)).stdout
cmd = "cat <<EOF | diff %s -\n%s\nEOF" % (settings_file, new_content)
diff = sys.run(cmd, valid_codes=(1, 0)).stdout
context = self.get_context_data(form=form)
context['diff'] = diff
return self.render_to_response(context)

View file

@ -1,7 +1,7 @@
from django.apps import AppConfig
from django.core.checks import register, Error
from django.core.exceptions import ValidationError
from django.utils.translation import ngettext, ugettext_lazy as _
from django.utils.translation import ugettext_lazy as _
from orchestra.core import administration

View file

@ -6,6 +6,7 @@ from django import forms
from django.core.exceptions import ValidationError
from django.forms.formsets import formset_factory
from django.utils.functional import Promise
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from orchestra.forms import ReadOnlyFormMixin, widgets
@ -13,18 +14,17 @@ from orchestra.utils.python import format_exception
from . import parser
from django import forms
from django.utils.safestring import mark_safe
class SettingForm(ReadOnlyFormMixin, forms.Form):
TEXTAREA = partial(forms.CharField,
TEXTAREA = partial(
forms.CharField,
widget=forms.Textarea(attrs={
'cols': 65,
'rows': 2,
'style': 'font-family: monospace',
}))
CHARFIELD = partial(forms.CharField,
CHARFIELD = partial(
forms.CharField,
widget=forms.TextInput(attrs={
'size': 65,
'style': 'font-family: monospace',
@ -66,7 +66,9 @@ class SettingForm(ReadOnlyFormMixin, forms.Form):
field = forms.ChoiceField
multiple = setting.multiple
if multiple:
field = partial(forms.MultipleChoiceField, widget=forms.CheckboxSelectMultiple)
field = partial(
forms.MultipleChoiceField,
widget=forms.CheckboxSelectMultiple)
if choices:
# Lazy loading
if callable(choices):
@ -75,7 +77,8 @@ class SettingForm(ReadOnlyFormMixin, forms.Form):
choices = tuple((parser.serialize(val), verb) for val, verb in choices)
field = partial(field, choices=choices)
else:
field = self.FORMFIELD_FOR_SETTING_TYPE.get(self.setting_type, self.NON_EDITABLE)
field = self.FORMFIELD_FOR_SETTING_TYPE.get(
self.setting_type, self.NON_EDITABLE)
field = deepcopy(field)
real_field = field
while isinstance(real_field, partial):

View file

@ -1,12 +1,10 @@
import os
from django import forms
from django.contrib import messages, admin
from django.core.exceptions import PermissionDenied
from django.template.response import TemplateResponse
from django.utils.translation import ungettext, ugettext_lazy as _
from orchestra.admin.decorators import action_with_confirmation
from orchestra.contrib.orchestration import Operation, helpers
from .forms import PermissionForm

View file

@ -3,7 +3,7 @@ import textwrap
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ngettext, ugettext_lazy as _
from django.utils.translation import ugettext_lazy as _
from orchestra.forms import UserCreationForm, UserChangeForm

View file

@ -1,5 +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

View file

@ -11,7 +11,7 @@ from django.core.mail import mail_admins
from django.utils import timezone
from orchestra.utils.db import close_connection
from orchestra.utils.python import AttrDict, OrderedSet
from orchestra.utils.python import AttrDict
from .utils import get_name, get_id

View file

@ -1,4 +1,4 @@
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from ... import beat

View file

@ -1,4 +1,4 @@
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from orchestra.utils.python import import_class

View file

@ -1,7 +1,7 @@
import json
from celery import current_app
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from django.utils import timezone
from djcelery.models import PeriodicTask

View file

@ -1,4 +1,4 @@
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from djcelery.app import app
from djcelery.schedulers import DatabaseScheduler

View file

@ -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 _
@ -40,10 +40,10 @@ class VPSAdmin(AccountAdminMixin, ExtendedModelAdmin):
def get_urls(self):
useradmin = UserAdmin(VPS, self.admin_site)
return patterns('',
(r'^(\d+)/password/$',
return [
url(r'^(\d+)/password/$',
self.admin_site.admin_view(useradmin.user_change_password))
) + super(VPSAdmin, self).get_urls()
] + super(VPSAdmin, self).get_urls()
admin.site.register(VPS, VPSAdmin)

View file

@ -1,7 +1,6 @@
import os
import textwrap
from django.template import Template, Context
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.orchestration import ServiceController, replace

View file

@ -1,13 +1,10 @@
import os
import re
from collections import OrderedDict
from django import forms
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from orchestra.plugins.forms import PluginDataForm
from orchestra.utils.functional import cached
from .. import settings
from ..options import AppOption

View file

@ -1,5 +1,4 @@
from django.apps import AppConfig
from django.contrib.contenttypes.fields import GenericRelation
from orchestra.core import services
from orchestra.utils.db import database_ready

View file

@ -9,6 +9,7 @@ from orchestra.utils.functional import cached
from orchestra.utils.python import import_class
from . import settings
from .utils import normurlpath
class SiteDirective(Plugin):
@ -58,7 +59,7 @@ class SiteDirective(Plugin):
# location uniqueness
location = None
if self.unique_location:
location = directive['value'].split()[0]
location = normurlpath(directive['value'].split()[0])
if location is not None and location in locations:
errors['value'].append(ValidationError(
"Location '%s' already in use by other content/directive." % location

View file

@ -2,10 +2,8 @@ from collections import defaultdict
from django import forms
from django.core.exceptions import ValidationError
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from .directives import SiteDirective
from .utils import normurlpath
from .validators import validate_domain_protocol
@ -33,7 +31,7 @@ class WebsiteDirectiveInlineFormSet(forms.models.BaseInlineFormSet):
for form in self.content_formset.forms:
location = form.cleaned_data.get('path')
if location is not None:
locations.add(location)
locations.add(normurlpath(location))
directives = []
values = defaultdict(list)

View file

@ -1,5 +1,4 @@
from django.core.exceptions import ValidationError
from django.shortcuts import get_object_or_404
from rest_framework import serializers
from orchestra.api.serializers import HyperlinkedModelSerializer, RelatedHyperlinkedModelSerializer
@ -7,6 +6,7 @@ from orchestra.contrib.accounts.serializers import AccountSerializerMixin
from .directives import SiteDirective
from .models import Website, Content, WebsiteDirective
from .utils import normurlpath
from .validators import validate_domain_protocol
@ -66,7 +66,7 @@ class WebsiteSerializer(AccountSerializerMixin, HyperlinkedModelSerializer):
for content in data.get('content_set', []):
location = content.get('path')
if location is not None:
locations.add(location)
locations.add(normurlpath(location))
values = defaultdict(list)
for name, value in directives.items():
directive = {

View file

@ -3,7 +3,6 @@ import textwrap
from django import forms
from django.utils.safestring import mark_safe
from django.utils.encoding import force_text
from django.contrib.admin.templatetags.admin_static import static

View file

@ -1,6 +1,6 @@
import os
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from orchestra.utils.paths import get_site_dir
from orchestra.utils.sys import run, check_non_root

View file

@ -7,7 +7,7 @@ from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from orchestra.utils import paths
from orchestra.utils.sys import run, check_root, get_default_celeryd_username
from orchestra.utils.sys import run, check_root
class Command(BaseCommand):

View file

@ -9,4 +9,4 @@ class Command(BaseCommand):
def handle(self, *filenames, **options):
flake = run('flake8 {%s,%s} | grep -v "W293\|E501"' % (get_orchestra_dir(), get_site_dir()))
self.stdout.write(flake.stdout)
self.stdout.write(flake.stdout.decode('utf8'))

View file

@ -1,6 +1,7 @@
from django.contrib.auth.backends import ModelBackend
from django.apps import apps
class OrchestraPermissionBackend(ModelBackend):
supports_object_permissions = True
supports_anonymous_user = False
@ -43,5 +44,3 @@ class OrchestraPermissionBackend(ModelBackend):
if has_perm:
return True
return False

View file

@ -1,6 +1,6 @@
import re
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.admin.utils import unquote
from django.shortcuts import render, redirect
from django.utils.translation import ugettext_lazy as _
@ -39,11 +39,11 @@ class SelectPluginAdminMixin(object):
urls = super(SelectPluginAdminMixin, self).get_urls()
opts = self.model._meta
info = opts.app_label, opts.model_name
select_urls = patterns("",
select_urls = [
url("/select-plugin/$",
wrap_admin_view(self, self.select_plugin_view),
name='%s_%s_select_plugin' % info),
)
]
return select_urls + urls
def select_plugin_view(self, request):

View file

@ -1,6 +1,6 @@
from django.contrib import admin
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from . import api
from .utils.apps import isinstalled
@ -10,7 +10,7 @@ admin.autodiscover()
api.autodiscover()
urlpatterns = patterns('',
urlpatterns = [
# Admin
url(r'^admin/', include(admin.site.urls)),
url(r'^admin_tools/', include('admin_tools.urls')),
@ -26,11 +26,11 @@ urlpatterns = patterns('',
'document_root': settings.MEDIA_ROOT,
'show_indexes': True
})
)
]
if isinstalled('debug_toolbar'):
import debug_toolbar
urlpatterns += patterns('',
urlpatterns.append(
url(r'^__debug__/', include(debug_toolbar.urls)),
)