Removed unused imports and patterns
This commit is contained in:
parent
907250d2e7
commit
21b3544895
16
TODO.md
16
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
|
# 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=?????
|
# password validation cracklib on change password form=?????
|
||||||
# reset setting button
|
# reset setting button
|
||||||
|
|
||||||
# periodic cleaning of spam mailboxes
|
|
||||||
|
|
||||||
# admin edit relevant djanog settings
|
# admin edit relevant djanog settings
|
||||||
# django SITE_NAME vs ORCHESTRA_SITE_NAME ?
|
# 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
|
# 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!
|
# BUG Delete related services also deletes account!
|
||||||
# auto apend trailing slash
|
# 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
|
# 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
|
# change mailer.message.priority by, queue/sent inmediatelly or rename critical to noq
|
||||||
|
|
||||||
|
|
||||||
# method(
|
method(
|
||||||
arg, arg, arg)
|
arg, arg, arg)
|
||||||
|
|
||||||
|
|
||||||
|
# Restart postfix on user pwd change/disabling
|
||||||
# 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
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ from django.utils.text import capfirst
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.core import services, accounts, administration
|
from orchestra.core import services, accounts, administration
|
||||||
from orchestra.utils.apps import isinstalled
|
|
||||||
|
|
||||||
|
|
||||||
def api_link(context):
|
def api_link(context):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django import forms
|
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 import admin, messages
|
||||||
from django.contrib.admin.options import IS_POPUP_VAR
|
from django.contrib.admin.options import IS_POPUP_VAR
|
||||||
from django.contrib.admin.utils import unquote
|
from django.contrib.admin.utils import unquote
|
||||||
|
@ -68,9 +68,9 @@ class ChangeViewActionsMixin(object):
|
||||||
urls = super(ChangeViewActionsMixin, self).get_urls()
|
urls = super(ChangeViewActionsMixin, self).get_urls()
|
||||||
admin_site = self.admin_site
|
admin_site = self.admin_site
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
new_urls = patterns('')
|
new_urls = []
|
||||||
for action in self.get_change_view_actions():
|
for action in self.get_change_view_actions():
|
||||||
new_urls += patterns('',
|
new_urls.append(
|
||||||
url('^(\d+)/%s/$' % action.url_name,
|
url('^(\d+)/%s/$' % action.url_name,
|
||||||
admin_site.admin_view(action),
|
admin_site.admin_view(action),
|
||||||
name='%s_%s_%s' % (opts.app_label, opts.model_name, action.url_name)
|
name='%s_%s_%s' % (opts.app_label, opts.model_name, action.url_name)
|
||||||
|
@ -187,11 +187,11 @@ class ChangePasswordAdminMixin(object):
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
info = opts.app_label, opts.model_name
|
info = opts.app_label, opts.model_name
|
||||||
return patterns('',
|
return [
|
||||||
url(r'^(\d+)/password/$',
|
url(r'^(\d+)/password/$',
|
||||||
self.admin_site.admin_view(self.change_password),
|
self.admin_site.admin_view(self.change_password),
|
||||||
name='%s_%s_change_password' % info),
|
name='%s_%s_change_password' % info)
|
||||||
) + super(ChangePasswordAdminMixin, self).get_urls()
|
] + super(ChangePasswordAdminMixin, self).get_urls()
|
||||||
|
|
||||||
@sensitive_post_parameters_m
|
@sensitive_post_parameters_m
|
||||||
def change_password(self, request, id, form_url=''):
|
def change_password(self, request, id, form_url=''):
|
||||||
|
|
|
@ -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')),
|
url(r'', include('orchestra.urls')),
|
||||||
)
|
]
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from django.utils import timezone
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.text import capfirst
|
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
|
from orchestra.core import services
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ def delete_related_services(modeladmin, request, queryset):
|
||||||
user = request.user
|
user = request.user
|
||||||
admin_site = modeladmin.admin_site
|
admin_site = modeladmin.admin_site
|
||||||
|
|
||||||
def format(obj):
|
def format(obj, account=False):
|
||||||
has_admin = obj.__class__ in admin_site._registry
|
has_admin = obj.__class__ in admin_site._registry
|
||||||
opts = obj._meta
|
opts = obj._meta
|
||||||
no_edit_link = '%s: %s' % (capfirst(opts.verbose_name), force_text(obj))
|
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):
|
if not user.has_perm(p):
|
||||||
perms_needed.add(opts.verbose_name)
|
perms_needed.add(opts.verbose_name)
|
||||||
# Display a link to the admin page.
|
# 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:
|
else:
|
||||||
# Don't display link to edit, because it either has no
|
# Don't display link to edit, because it either has no
|
||||||
# admin or is edited inline.
|
# admin or is edited inline.
|
||||||
|
@ -102,11 +106,12 @@ def delete_related_services(modeladmin, request, queryset):
|
||||||
else:
|
else:
|
||||||
result.append(format(objs))
|
result.append(format(objs))
|
||||||
|
|
||||||
for account in collector.nested():
|
for nested in collector.nested():
|
||||||
if isinstance(account, list):
|
if isinstance(nested, list):
|
||||||
|
# Is lists of objects
|
||||||
current = []
|
current = []
|
||||||
is_service = False
|
is_service = False
|
||||||
for service in account:
|
for service in nested:
|
||||||
if type(service) in registered_services:
|
if type(service) in registered_services:
|
||||||
if service == main_systemuser:
|
if service == main_systemuser:
|
||||||
continue
|
continue
|
||||||
|
@ -121,10 +126,11 @@ def delete_related_services(modeladmin, request, queryset):
|
||||||
else:
|
else:
|
||||||
is_service = False
|
is_service = False
|
||||||
related_services.append(current)
|
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
|
# Prevent the deletion of the main system user, which will delete the account
|
||||||
main_systemuser = account.main_systemuser
|
main_systemuser = nested.main_systemuser
|
||||||
related_services.append(format(account))
|
related_services.append(format(nested, account=True))
|
||||||
|
|
||||||
# The user has already confirmed the deletion.
|
# The user has already confirmed the deletion.
|
||||||
# Do the deletion and return a None to display the change list view again.
|
# Do the deletion and return a None to display the change list view again.
|
||||||
|
|
|
@ -3,7 +3,7 @@ import re
|
||||||
from urllib.parse import parse_qsl
|
from urllib.parse import parse_qsl
|
||||||
|
|
||||||
from django import forms
|
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 import admin, messages
|
||||||
from django.contrib.admin.utils import unquote
|
from django.contrib.admin.utils import unquote
|
||||||
from django.contrib.auth import admin as auth
|
from django.contrib.auth import admin as auth
|
||||||
|
@ -310,11 +310,11 @@ class SelectAccountAdminMixin(AccountAdminMixin):
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
info = opts.app_label, opts.model_name
|
info = opts.app_label, opts.model_name
|
||||||
account_list = AccountListAdmin(Account, admin_site).changelist_view
|
account_list = AccountListAdmin(Account, admin_site).changelist_view
|
||||||
select_urls = patterns("",
|
select_urls = [
|
||||||
url("/select-account/$",
|
url("/select-account/$",
|
||||||
wrap_admin_view(self, account_list),
|
wrap_admin_view(self, account_list),
|
||||||
name='%s_%s_select_account' % info),
|
name='%s_%s_select_account' % info),
|
||||||
)
|
]
|
||||||
return select_urls + urls
|
return select_urls + urls
|
||||||
|
|
||||||
def add_view(self, request, form_url='', extra_context=None):
|
def add_view(self, request, form_url='', extra_context=None):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.contrib.settings import Setting
|
from orchestra.contrib.settings import Setting
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from django import forms
|
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 import admin
|
||||||
from django.contrib.admin.utils import unquote
|
from django.contrib.admin.utils import unquote
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
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.db.models.functions import Coalesce
|
||||||
from django.templatetags.static import static
|
from django.templatetags.static import static
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
@ -17,7 +17,7 @@ from orchestra.forms.widgets import paddingCheckboxSelectMultiple
|
||||||
|
|
||||||
from . import settings, actions
|
from . import settings, actions
|
||||||
from .filters import BillTypeListFilter, HasBillContactListFilter
|
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 = {
|
PAYMENT_STATE_COLORS = {
|
||||||
|
@ -229,11 +229,11 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
||||||
""" Hook bill lines management URLs on bill admin """
|
""" Hook bill lines management URLs on bill admin """
|
||||||
urls = super(BillAdmin, self).get_urls()
|
urls = super(BillAdmin, self).get_urls()
|
||||||
admin_site = self.admin_site
|
admin_site = self.admin_site
|
||||||
extra_urls = patterns("",
|
extra_urls = [
|
||||||
url("^manage-lines/$",
|
url("^manage-lines/$",
|
||||||
admin_site.admin_view(BillLineManagerAdmin(BillLine, admin_site).changelist_view),
|
admin_site.admin_view(BillLineManagerAdmin(BillLine, admin_site).changelist_view),
|
||||||
name='bills_bill_manage_lines'),
|
name='bills_bill_manage_lines'),
|
||||||
)
|
]
|
||||||
return extra_urls + urls
|
return extra_urls + urls
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
def get_readonly_fields(self, request, obj=None):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from django.conf import settings
|
|
||||||
from django_countries import data
|
from django_countries import data
|
||||||
|
|
||||||
from orchestra.contrib.settings import Setting
|
from orchestra.contrib.settings import Setting
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.conf.urls import patterns
|
from django.conf.urls import url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
@ -103,10 +103,10 @@ class DatabaseUserAdmin(SelectAccountAdminMixin, ChangePasswordAdminMixin, Exten
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
useradmin = UserAdmin(DatabaseUser, self.admin_site)
|
useradmin = UserAdmin(DatabaseUser, self.admin_site)
|
||||||
return patterns('',
|
return [
|
||||||
(r'^(\d+)/password/$',
|
url(r'^(\d+)/password/$',
|
||||||
self.admin_site.admin_view(useradmin.user_change_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):
|
def save_model(self, request, obj, form, change):
|
||||||
""" set password """
|
""" set password """
|
||||||
|
|
|
@ -150,11 +150,12 @@ class MysqlDisk(ServiceMonitor):
|
||||||
if db.type != db.MYSQL:
|
if db.type != db.MYSQL:
|
||||||
return
|
return
|
||||||
context = self.get_context(db)
|
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):
|
def get_context(self, db):
|
||||||
context = {
|
context = {
|
||||||
'db_name': db.name,
|
'db_name': db.name,
|
||||||
|
'db_dirname': db.name.replace('-', '@003f'),
|
||||||
'db_id': db.pk,
|
'db_id': db.pk,
|
||||||
}
|
}
|
||||||
return replace(replace(context, "'", '"'), ';', '')
|
return replace(replace(context, "'", '"'), ';', '')
|
||||||
|
|
|
@ -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 rest_framework import serializers
|
||||||
|
|
||||||
from orchestra.api.serializers import (HyperlinkedModelSerializer,
|
from orchestra.api.serializers import (HyperlinkedModelSerializer,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import re
|
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.db.models.functions import Concat, Coalesce
|
from django.db.models.functions import Concat, Coalesce
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf.urls import patterns
|
from django.conf.urls import url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -244,11 +244,10 @@ class TicketAdmin(ChangeListDefaultFilter, ExtendedModelAdmin):
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
""" add markdown preview url """
|
""" add markdown preview url """
|
||||||
urls = super(TicketAdmin, self).get_urls()
|
return [
|
||||||
my_urls = patterns('',
|
url(r'^preview/$',
|
||||||
(r'^preview/$', wrap_admin_view(self, self.message_preview_view))
|
wrap_admin_view(self, self.message_preview_view))
|
||||||
)
|
] + super(TicketAdmin, self).get_urls()
|
||||||
return my_urls + urls
|
|
||||||
|
|
||||||
def add_view(self, request, form_url='', extra_context=None):
|
def add_view(self, request, form_url='', extra_context=None):
|
||||||
""" Do not sow message inlines """
|
""" Do not sow message inlines """
|
||||||
|
|
|
@ -19,13 +19,9 @@ class MessageSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
def get_identity(self, data):
|
def get_identity(self, data):
|
||||||
return data.get('id')
|
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):
|
def create(self, validated_data):
|
||||||
validated_data['author'] = self.context['request'].user
|
validated_data['author'] = self.context['request'].user
|
||||||
super(MessageSerializer, self).create(validated_data)
|
return super(MessageSerializer, self).create(validated_data)
|
||||||
|
|
||||||
|
|
||||||
class TicketSerializer(serializers.HyperlinkedModelSerializer):
|
class TicketSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.contrib import admin
|
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.contrib.auth.admin import UserAdmin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
useradmin = UserAdmin(List, self.admin_site)
|
useradmin = UserAdmin(List, self.admin_site)
|
||||||
return patterns('',
|
return [
|
||||||
(r'^(\d+)/password/$',
|
url(r'^(\d+)/password/$',
|
||||||
self.admin_site.admin_view(useradmin.user_change_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)
|
admin.site.register(List, ListAdmin)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import re
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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.orchestration import ServiceController, replace
|
||||||
from orchestra.contrib.resources import ServiceMonitor
|
from orchestra.contrib.resources import ServiceMonitor
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.forms import widgets
|
from django.forms import widgets
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
|
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
|
||||||
|
|
|
@ -6,10 +6,8 @@ import textwrap
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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.orchestration import ServiceController, replace
|
||||||
from orchestra.contrib.resources import ServiceMonitor
|
from orchestra.contrib.resources import ServiceMonitor
|
||||||
#from orchestra.utils.humanize import unit_to_bytes
|
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
from .models import Address
|
from .models import Address
|
||||||
|
@ -63,7 +61,10 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
|
||||||
context = self.get_context(mailbox)
|
context = self.get_context(mailbox)
|
||||||
self.append(textwrap.dedent("""
|
self.append(textwrap.dedent("""
|
||||||
if [[ $( id %(user)s ) ]]; then
|
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
|
usermod %(user)s --password '%(password)s' --shell %(initial_shell)s
|
||||||
|
[[ "$old_password" != "%(password)s" ]] && RESTART_POSTFIX=1
|
||||||
else
|
else
|
||||||
useradd %(user)s --home %(home)s --password '%(password)s'
|
useradd %(user)s --home %(home)s --password '%(password)s'
|
||||||
fi
|
fi
|
||||||
|
@ -95,10 +96,15 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
|
||||||
self.append(textwrap.dedent("""
|
self.append(textwrap.dedent("""
|
||||||
nohup bash -c '{ sleep 2 && killall -u %(user)s -s KILL; }' &> /dev/null &
|
nohup bash -c '{ sleep 2 && killall -u %(user)s -s KILL; }' &> /dev/null &
|
||||||
killall -u %(user)s || true
|
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
|
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):
|
def get_context(self, mailbox):
|
||||||
context = {
|
context = {
|
||||||
'user': mailbox.name,
|
'user': mailbox.name,
|
||||||
|
|
|
@ -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 rest_framework import serializers
|
||||||
|
|
||||||
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
|
from orchestra.api.serializers import SetPasswordHyperlinkedSerializer, RelatedHyperlinkedModelSerializer
|
||||||
|
|
|
@ -280,11 +280,6 @@ class RESTMailboxMixin(MailboxMixin):
|
||||||
mailbox = self.rest.mailboxes.retrieve(name=username).get()
|
mailbox = self.rest.mailboxes.retrieve(name=username).get()
|
||||||
self.rest.addresses.delete()
|
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
|
@save_response_on_error
|
||||||
def disable(self, username):
|
def disable(self, username):
|
||||||
mailbox = self.rest.mailboxes.retrieve(name=username).get()
|
mailbox = self.rest.mailboxes.retrieve(name=username).get()
|
||||||
|
|
|
@ -2,7 +2,6 @@ import hashlib
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.core.management.base import CommandError
|
|
||||||
from django.core.validators import ValidationError, EmailValidator
|
from django.core.validators import ValidationError, EmailValidator
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.core.urlresolvers import reverse
|
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.shortcuts import redirect
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ class EmailBackend(BaseEmailBackend):
|
||||||
return
|
return
|
||||||
num_sent = 0
|
num_sent = 0
|
||||||
is_bulk = len(email_messages) > 1
|
is_bulk = len(email_messages) > 1
|
||||||
|
default_priority = Message.NORMAL if is_bulk else Message.CRITICAL
|
||||||
for message in email_messages:
|
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()
|
content = message.message().as_string()
|
||||||
for to_email in message.recipients():
|
for to_email in message.recipients():
|
||||||
message = Message.objects.create(
|
message = Message.objects.create(
|
||||||
|
@ -25,7 +26,7 @@ class EmailBackend(BaseEmailBackend):
|
||||||
subject=message.subject,
|
subject=message.subject,
|
||||||
content=content,
|
content=content,
|
||||||
)
|
)
|
||||||
if not is_bulk or priority == Message.CRITICAL:
|
if priority == Message.CRITICAL:
|
||||||
# send immidiately
|
# send immidiately
|
||||||
send_message.apply_async(message)
|
send_message.apply_async(message)
|
||||||
num_sent += 1
|
num_sent += 1
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import json
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
|
||||||
|
|
||||||
from orchestra.contrib.tasks.decorators import keep_state
|
from orchestra.contrib.tasks.decorators import keep_state
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import re
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
|
@ -2,7 +2,6 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from django.core.mail import mail_admins
|
from django.core.mail import mail_admins
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import select
|
import select
|
||||||
|
|
||||||
from celery.datastructures import ExceptionInfo
|
from celery.datastructures import ExceptionInfo
|
||||||
from django.conf import settings as djsettings
|
|
||||||
|
|
||||||
from orchestra.utils.sys import sshrun
|
from orchestra.utils.sys import sshrun
|
||||||
from orchestra.utils.python import CaptureStdout, import_class
|
from orchestra.utils.python import CaptureStdout, import_class
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
from orchestra.core import accounts
|
from orchestra.core import accounts
|
||||||
from orchestra.utils.db import database_ready
|
|
||||||
|
|
||||||
|
|
||||||
class OrdersConfig(AppConfig):
|
class OrdersConfig(AppConfig):
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import datetime
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.contrib.bills.models import Invoice, Fee, ProForma
|
from orchestra.contrib.bills.models import Invoice, Fee, ProForma
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta
|
||||||
|
|
||||||
from django.contrib.admin import SimpleListFilter
|
from django.contrib.admin import SimpleListFilter
|
||||||
from django.db.models import Q, Prefetch, F
|
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.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from .models import MetricStorage, Order
|
from .models import MetricStorage
|
||||||
|
|
||||||
|
|
||||||
class ActiveOrderListFilter(SimpleListFilter):
|
class ActiveOrderListFilter(SimpleListFilter):
|
||||||
|
|
|
@ -10,7 +10,6 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.core import services
|
|
||||||
from orchestra.models import queryset
|
from orchestra.models import queryset
|
||||||
from orchestra.utils.python import import_class
|
from orchestra.utils.python import import_class
|
||||||
|
|
||||||
|
|
|
@ -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 django.dispatch import receiver
|
||||||
|
|
||||||
from orchestra.core import services
|
from orchestra.core import services
|
||||||
|
|
|
@ -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 import admin, messages
|
||||||
from django.contrib.admin.utils import unquote
|
from django.contrib.admin.utils import unquote
|
||||||
from django.contrib import contenttypes
|
from django.contrib import contenttypes
|
||||||
|
@ -121,12 +121,12 @@ class ResourceDataAdmin(ExtendedModelAdmin):
|
||||||
urls = super(ResourceDataAdmin, self).get_urls()
|
urls = super(ResourceDataAdmin, self).get_urls()
|
||||||
admin_site = self.admin_site
|
admin_site = self.admin_site
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
return patterns('',
|
return [
|
||||||
url('^(\d+)/used-monitordata/$',
|
url('^(\d+)/used-monitordata/$',
|
||||||
admin_site.admin_view(self.used_monitordata_view),
|
admin_site.admin_view(self.used_monitordata_view),
|
||||||
name='%s_%s_used_monitordata' % (opts.app_label, opts.model_name)
|
name='%s_%s_used_monitordata' % (opts.app_label, opts.model_name)
|
||||||
)
|
)
|
||||||
) + urls
|
] + urls
|
||||||
|
|
||||||
def display_unit(self, data):
|
def display_unit(self, data):
|
||||||
return data.unit
|
return data.unit
|
||||||
|
|
|
@ -3,7 +3,6 @@ from rest_framework import viewsets
|
||||||
from orchestra.api import router, LogApiMixin
|
from orchestra.api import router, LogApiMixin
|
||||||
from orchestra.contrib.accounts.api import AccountApiMixin
|
from orchestra.contrib.accounts.api import AccountApiMixin
|
||||||
|
|
||||||
from . import settings
|
|
||||||
from .models import SaaS
|
from .models import SaaS
|
||||||
from .serializers import SaaSSerializer
|
from .serializers import SaaSSerializer
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from django.forms import widgets
|
from django.forms import widgets
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django import forms
|
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 import admin
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
@ -46,12 +46,12 @@ class ServiceAdmin(ChangeViewActionsMixin, admin.ModelAdmin):
|
||||||
urls = super(ServiceAdmin, self).get_urls()
|
urls = super(ServiceAdmin, self).get_urls()
|
||||||
admin_site = self.admin_site
|
admin_site = self.admin_site
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
return patterns('',
|
return [
|
||||||
url('^add/help/$',
|
url('^add/help/$',
|
||||||
admin_site.admin_view(self.help_view),
|
admin_site.admin_view(self.help_view),
|
||||||
name='%s_%s_help' % (opts.app_label, opts.model_name)
|
name='%s_%s_help' % (opts.app_label, opts.model_name)
|
||||||
)
|
)
|
||||||
) + urls
|
] + urls
|
||||||
|
|
||||||
def formfield_for_dbfield(self, db_field, **kwargs):
|
def formfield_for_dbfield(self, db_field, **kwargs):
|
||||||
""" Improve performance of account field and filter by account """
|
""" Improve performance of account field and filter by account """
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
from orchestra.core import administration, accounts
|
from orchestra.core import administration
|
||||||
from orchestra.core.translations import ModelTranslation
|
from orchestra.core.translations import ModelTranslation
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
|
|
||||||
from orchestra.core import validators
|
from orchestra.core import validators
|
||||||
from orchestra.utils.python import import_class, format_exception
|
from orchestra.utils.python import import_class, format_exception
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from django.contrib import admin, messages
|
from django.contrib import admin, messages
|
||||||
from django.db import models
|
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django.utils.translation import ngettext, ugettext_lazy as _
|
from django.utils.translation import ngettext, ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.admin.dashboard import OrchestraIndexDashboard
|
|
||||||
from orchestra.contrib.settings import Setting
|
from orchestra.contrib.settings import Setting
|
||||||
from orchestra.utils import sys, paths
|
from orchestra.utils import sys
|
||||||
|
|
||||||
from . import parser
|
from . import parser
|
||||||
from .forms import SettingFormSet
|
from .forms import SettingFormSet
|
||||||
|
@ -66,7 +62,8 @@ class SettingView(generic.edit.FormView):
|
||||||
if not self.request.POST.get('confirmation'):
|
if not self.request.POST.get('confirmation'):
|
||||||
settings_file = parser.get_settings_file()
|
settings_file = parser.get_settings_file()
|
||||||
new_content = parser.apply(changes)
|
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 = self.get_context_data(form=form)
|
||||||
context['diff'] = diff
|
context['diff'] = diff
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.core.checks import register, Error
|
from django.core.checks import register, Error
|
||||||
from django.core.exceptions import ValidationError
|
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
|
from orchestra.core import administration
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.forms.formsets import formset_factory
|
from django.forms.formsets import formset_factory
|
||||||
from django.utils.functional import Promise
|
from django.utils.functional import Promise
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.forms import ReadOnlyFormMixin, widgets
|
from orchestra.forms import ReadOnlyFormMixin, widgets
|
||||||
|
@ -13,18 +14,17 @@ from orchestra.utils.python import format_exception
|
||||||
|
|
||||||
from . import parser
|
from . import parser
|
||||||
|
|
||||||
from django import forms
|
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
|
|
||||||
|
|
||||||
class SettingForm(ReadOnlyFormMixin, forms.Form):
|
class SettingForm(ReadOnlyFormMixin, forms.Form):
|
||||||
TEXTAREA = partial(forms.CharField,
|
TEXTAREA = partial(
|
||||||
|
forms.CharField,
|
||||||
widget=forms.Textarea(attrs={
|
widget=forms.Textarea(attrs={
|
||||||
'cols': 65,
|
'cols': 65,
|
||||||
'rows': 2,
|
'rows': 2,
|
||||||
'style': 'font-family: monospace',
|
'style': 'font-family: monospace',
|
||||||
}))
|
}))
|
||||||
CHARFIELD = partial(forms.CharField,
|
CHARFIELD = partial(
|
||||||
|
forms.CharField,
|
||||||
widget=forms.TextInput(attrs={
|
widget=forms.TextInput(attrs={
|
||||||
'size': 65,
|
'size': 65,
|
||||||
'style': 'font-family: monospace',
|
'style': 'font-family: monospace',
|
||||||
|
@ -66,7 +66,9 @@ class SettingForm(ReadOnlyFormMixin, forms.Form):
|
||||||
field = forms.ChoiceField
|
field = forms.ChoiceField
|
||||||
multiple = setting.multiple
|
multiple = setting.multiple
|
||||||
if multiple:
|
if multiple:
|
||||||
field = partial(forms.MultipleChoiceField, widget=forms.CheckboxSelectMultiple)
|
field = partial(
|
||||||
|
forms.MultipleChoiceField,
|
||||||
|
widget=forms.CheckboxSelectMultiple)
|
||||||
if choices:
|
if choices:
|
||||||
# Lazy loading
|
# Lazy loading
|
||||||
if callable(choices):
|
if callable(choices):
|
||||||
|
@ -75,7 +77,8 @@ class SettingForm(ReadOnlyFormMixin, forms.Form):
|
||||||
choices = tuple((parser.serialize(val), verb) for val, verb in choices)
|
choices = tuple((parser.serialize(val), verb) for val, verb in choices)
|
||||||
field = partial(field, choices=choices)
|
field = partial(field, choices=choices)
|
||||||
else:
|
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)
|
field = deepcopy(field)
|
||||||
real_field = field
|
real_field = field
|
||||||
while isinstance(real_field, partial):
|
while isinstance(real_field, partial):
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django import forms
|
|
||||||
from django.contrib import messages, admin
|
from django.contrib import messages, admin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.translation import ungettext, ugettext_lazy as _
|
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 orchestra.contrib.orchestration import Operation, helpers
|
||||||
|
|
||||||
from .forms import PermissionForm
|
from .forms import PermissionForm
|
||||||
|
|
|
@ -3,7 +3,7 @@ import textwrap
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
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
|
from orchestra.forms import UserCreationForm, UserChangeForm
|
||||||
|
|
||||||
|
|
|
@ -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 django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.core.mail import mail_admins
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from orchestra.utils.db import close_connection
|
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
|
from .utils import get_name, get_id
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from ... import beat
|
from ... import beat
|
||||||
|
|
||||||
|
|
|
@ -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
|
from orchestra.utils.python import import_class
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from celery import current_app
|
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 django.utils import timezone
|
||||||
from djcelery.models import PeriodicTask
|
from djcelery.models import PeriodicTask
|
||||||
|
|
||||||
|
|
|
@ -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.app import app
|
||||||
from djcelery.schedulers import DatabaseScheduler
|
from djcelery.schedulers import DatabaseScheduler
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.conf.urls import patterns
|
from django.conf.urls import url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
@ -40,10 +40,10 @@ class VPSAdmin(AccountAdminMixin, ExtendedModelAdmin):
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
useradmin = UserAdmin(VPS, self.admin_site)
|
useradmin = UserAdmin(VPS, self.admin_site)
|
||||||
return patterns('',
|
return [
|
||||||
(r'^(\d+)/password/$',
|
url(r'^(\d+)/password/$',
|
||||||
self.admin_site.admin_view(useradmin.user_change_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)
|
admin.site.register(VPS, VPSAdmin)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from django.template import Template, Context
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.contrib.orchestration import ServiceController, replace
|
from orchestra.contrib.orchestration import ServiceController, replace
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from orchestra.plugins.forms import PluginDataForm
|
from orchestra.plugins.forms import PluginDataForm
|
||||||
from orchestra.utils.functional import cached
|
|
||||||
|
|
||||||
from .. import settings
|
from .. import settings
|
||||||
from ..options import AppOption
|
from ..options import AppOption
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.contrib.contenttypes.fields import GenericRelation
|
|
||||||
|
|
||||||
from orchestra.core import services
|
from orchestra.core import services
|
||||||
from orchestra.utils.db import database_ready
|
from orchestra.utils.db import database_ready
|
||||||
|
|
|
@ -9,6 +9,7 @@ from orchestra.utils.functional import cached
|
||||||
from orchestra.utils.python import import_class
|
from orchestra.utils.python import import_class
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
|
from .utils import normurlpath
|
||||||
|
|
||||||
|
|
||||||
class SiteDirective(Plugin):
|
class SiteDirective(Plugin):
|
||||||
|
@ -58,7 +59,7 @@ class SiteDirective(Plugin):
|
||||||
# location uniqueness
|
# location uniqueness
|
||||||
location = None
|
location = None
|
||||||
if self.unique_location:
|
if self.unique_location:
|
||||||
location = directive['value'].split()[0]
|
location = normurlpath(directive['value'].split()[0])
|
||||||
if location is not None and location in locations:
|
if location is not None and location in locations:
|
||||||
errors['value'].append(ValidationError(
|
errors['value'].append(ValidationError(
|
||||||
"Location '%s' already in use by other content/directive." % location
|
"Location '%s' already in use by other content/directive." % location
|
||||||
|
|
|
@ -2,10 +2,8 @@ from collections import defaultdict
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
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
|
from .validators import validate_domain_protocol
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +31,7 @@ class WebsiteDirectiveInlineFormSet(forms.models.BaseInlineFormSet):
|
||||||
for form in self.content_formset.forms:
|
for form in self.content_formset.forms:
|
||||||
location = form.cleaned_data.get('path')
|
location = form.cleaned_data.get('path')
|
||||||
if location is not None:
|
if location is not None:
|
||||||
locations.add(location)
|
locations.add(normurlpath(location))
|
||||||
directives = []
|
directives = []
|
||||||
|
|
||||||
values = defaultdict(list)
|
values = defaultdict(list)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from orchestra.api.serializers import HyperlinkedModelSerializer, RelatedHyperlinkedModelSerializer
|
from orchestra.api.serializers import HyperlinkedModelSerializer, RelatedHyperlinkedModelSerializer
|
||||||
|
@ -7,6 +6,7 @@ from orchestra.contrib.accounts.serializers import AccountSerializerMixin
|
||||||
|
|
||||||
from .directives import SiteDirective
|
from .directives import SiteDirective
|
||||||
from .models import Website, Content, WebsiteDirective
|
from .models import Website, Content, WebsiteDirective
|
||||||
|
from .utils import normurlpath
|
||||||
from .validators import validate_domain_protocol
|
from .validators import validate_domain_protocol
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class WebsiteSerializer(AccountSerializerMixin, HyperlinkedModelSerializer):
|
||||||
for content in data.get('content_set', []):
|
for content in data.get('content_set', []):
|
||||||
location = content.get('path')
|
location = content.get('path')
|
||||||
if location is not None:
|
if location is not None:
|
||||||
locations.add(location)
|
locations.add(normurlpath(location))
|
||||||
values = defaultdict(list)
|
values = defaultdict(list)
|
||||||
for name, value in directives.items():
|
for name, value in directives.items():
|
||||||
directive = {
|
directive = {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import textwrap
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.encoding import force_text
|
|
||||||
|
|
||||||
from django.contrib.admin.templatetags.admin_static import static
|
from django.contrib.admin.templatetags.admin_static import static
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
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.paths import get_site_dir
|
||||||
from orchestra.utils.sys import run, check_non_root
|
from orchestra.utils.sys import run, check_non_root
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
from orchestra.utils import paths
|
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):
|
class Command(BaseCommand):
|
||||||
|
|
|
@ -9,4 +9,4 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, *filenames, **options):
|
def handle(self, *filenames, **options):
|
||||||
flake = run('flake8 {%s,%s} | grep -v "W293\|E501"' % (get_orchestra_dir(), get_site_dir()))
|
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'))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
|
|
||||||
class OrchestraPermissionBackend(ModelBackend):
|
class OrchestraPermissionBackend(ModelBackend):
|
||||||
supports_object_permissions = True
|
supports_object_permissions = True
|
||||||
supports_anonymous_user = False
|
supports_anonymous_user = False
|
||||||
|
@ -43,5 +44,3 @@ class OrchestraPermissionBackend(ModelBackend):
|
||||||
if has_perm:
|
if has_perm:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.conf.urls import patterns, url
|
from django.conf.urls import url
|
||||||
from django.contrib.admin.utils import unquote
|
from django.contrib.admin.utils import unquote
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
@ -39,11 +39,11 @@ class SelectPluginAdminMixin(object):
|
||||||
urls = super(SelectPluginAdminMixin, self).get_urls()
|
urls = super(SelectPluginAdminMixin, self).get_urls()
|
||||||
opts = self.model._meta
|
opts = self.model._meta
|
||||||
info = opts.app_label, opts.model_name
|
info = opts.app_label, opts.model_name
|
||||||
select_urls = patterns("",
|
select_urls = [
|
||||||
url("/select-plugin/$",
|
url("/select-plugin/$",
|
||||||
wrap_admin_view(self, self.select_plugin_view),
|
wrap_admin_view(self, self.select_plugin_view),
|
||||||
name='%s_%s_select_plugin' % info),
|
name='%s_%s_select_plugin' % info),
|
||||||
)
|
]
|
||||||
return select_urls + urls
|
return select_urls + urls
|
||||||
|
|
||||||
def select_plugin_view(self, request):
|
def select_plugin_view(self, request):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import include, url
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .utils.apps import isinstalled
|
from .utils.apps import isinstalled
|
||||||
|
@ -10,7 +10,7 @@ admin.autodiscover()
|
||||||
api.autodiscover()
|
api.autodiscover()
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = [
|
||||||
# Admin
|
# Admin
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^admin_tools/', include('admin_tools.urls')),
|
url(r'^admin_tools/', include('admin_tools.urls')),
|
||||||
|
@ -26,11 +26,11 @@ urlpatterns = patterns('',
|
||||||
'document_root': settings.MEDIA_ROOT,
|
'document_root': settings.MEDIA_ROOT,
|
||||||
'show_indexes': True
|
'show_indexes': True
|
||||||
})
|
})
|
||||||
)
|
]
|
||||||
|
|
||||||
|
|
||||||
if isinstalled('debug_toolbar'):
|
if isinstalled('debug_toolbar'):
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
urlpatterns += patterns('',
|
urlpatterns.append(
|
||||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue