Compare commits

..

No commits in common. "rebuild-history-with-pangea-latest" and "master" have entirely different histories.

399 changed files with 6125 additions and 608 deletions

View File

@ -170,10 +170,10 @@ django-admin.py compilemessages -l ca
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#joining-strings-string-concat https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#joining-strings-string-concat
from django.utils.translation import gettext from django.utils.translation import ugettext
from django.utils import translation from django.utils import translation
translation.activate('ca') translation.activate('ca')
gettext("Description") ugettext("Description")
* saas validate_creation generic approach, for all backends. standard output * saas validate_creation generic approach, for all backends. standard output

View File

@ -59,7 +59,7 @@
```python ```python
import os import os
import textwrap import textwrap
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
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

View File

@ -6,7 +6,7 @@ from django.contrib import admin
from django.urls import reverse from django.urls import reverse
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .dashboard import * from .dashboard import *
from .options import * from .options import *

View File

@ -3,7 +3,7 @@ from functools import partial
from django.contrib import admin from django.contrib import admin
from django.core.mail import send_mass_mail from django.core.mail import send_mass_mail
from django.shortcuts import render from django.shortcuts import render
from django.utils.translation import ngettext, gettext_lazy as _ from django.utils.translation import ungettext, ugettext_lazy as _
from .. import settings from .. import settings
@ -81,7 +81,7 @@ class SendEmail(object):
if extra_to: if extra_to:
emails.append((subject, message, email_from, extra_to)) emails.append((subject, message, email_from, extra_to))
send_mass_mail(emails, fail_silently=False) send_mass_mail(emails, fail_silently=False)
msg = ngettext( msg = ungettext(
_("Message has been sent to one %s.") % self.opts.verbose_name_plural, _("Message has been sent to one %s.") % self.opts.verbose_name_plural,
_("Message has been sent to %i %s.") % (num, self.opts.verbose_name_plural), _("Message has been sent to %i %s.") % (num, self.opts.verbose_name_plural),
num num
@ -124,7 +124,7 @@ def base_disable(modeladmin, request, queryset, disable=True):
'verbose_name_plural': opts.verbose_name_plural, 'verbose_name_plural': opts.verbose_name_plural,
'num': num 'num': num
} }
msg = ngettext( msg = ungettext(
_("Selected %(verbose_name)s and related services has been %(action_name)s.") % context, _("Selected %(verbose_name)s and related services has been %(action_name)s.") % context,
_("%(num)s selected %(verbose_name_plural)s and related services have been %(action_name)s.") % context, _("%(num)s selected %(verbose_name_plural)s and related services have been %(action_name)s.") % context,
num) num)

View File

@ -1,5 +1,5 @@
from django.urls import reverse from django.urls import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from fluent_dashboard import dashboard, appsettings from fluent_dashboard import dashboard, appsettings
from fluent_dashboard.modules import CmsAppIconList from fluent_dashboard.modules import CmsAppIconList

View File

@ -4,10 +4,11 @@ from django.contrib import messages
from django.contrib.admin import helpers from django.contrib.admin import helpers
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.utils.encoding import force_str from django.utils.decorators import available_attrs
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 gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
def admin_field(method): def admin_field(method):
@ -49,7 +50,7 @@ def action_with_confirmation(action_name=None, extra_context=None, validator=Non
""" """
def decorator(func, extra_context=extra_context, template=template, action_name=action_name, validatior=validator): def decorator(func, extra_context=extra_context, template=template, action_name=action_name, validatior=validator):
@wraps(func) @wraps(func, assigned=available_attrs(func))
def inner(modeladmin, request, queryset, action_name=action_name, extra_context=extra_context, validator=validator): def inner(modeladmin, request, queryset, action_name=action_name, extra_context=extra_context, validator=validator):
if validator is not None: if validator is not None:
try: try:
@ -68,10 +69,10 @@ def action_with_confirmation(action_name=None, extra_context=None, validator=Non
action_value = func.__name__ action_value = func.__name__
if len(queryset) == 1: if len(queryset) == 1:
objects_name = force_str(opts.verbose_name) objects_name = force_text(opts.verbose_name)
obj = queryset.get() obj = queryset.get()
else: else:
objects_name = force_str(opts.verbose_name_plural) objects_name = force_text(opts.verbose_name_plural)
obj = None obj = None
if not action_name: if not action_name:
action_name = func.__name__ action_name = func.__name__

View File

@ -5,8 +5,8 @@ from django import forms
from django.contrib.admin import helpers from django.contrib.admin import helpers
from django.core import validators from django.core import validators
from django.forms.models import modelformset_factory, BaseModelFormSet from django.forms.models import modelformset_factory, BaseModelFormSet
from django.template import Template, Context from django.template import Template
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.forms.widgets import SpanWidget from orchestra.forms.widgets import SpanWidget
@ -31,7 +31,7 @@ class AdminFormMixin(object):
context = { context = {
'adminform': adminform 'adminform': adminform
} }
return template.render(Context(context)) return template.render(context)
class AdminFormSet(BaseModelFormSet): class AdminFormSet(BaseModelFormSet):
@ -74,7 +74,7 @@ class AdminFormSet(BaseModelFormSet):
context = { context = {
'formset': self 'formset': self
} }
return template.render(Context(context)) return template.render(context)
class AdminPasswordChangeForm(forms.Form): class AdminPasswordChangeForm(forms.Form):

View File

@ -3,7 +3,7 @@ from copy import deepcopy
from admin_tools.menu import items, Menu from admin_tools.menu import items, Menu
from django.urls import reverse from django.urls import reverse
from django.utils.text import capfirst from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import services, accounts, administration from orchestra.core import services, accounts, administration
@ -73,7 +73,7 @@ class OrchestraMenu(Menu):
self.children = [ self.children = [
# items.MenuItem( # items.MenuItem(
# mark_safe('{site_name} <span style="{version_style}">v{version}</span>'.format( # mark_safe('{site_name} <span style="{version_style}">v{version}</span>'.format(
# site_name=force_str(settings.SITE_VERBOSE_NAME), # site_name=force_text(settings.SITE_VERBOSE_NAME),
# version_style="text-transform:none; float:none; font-size:smaller; background:none;", # version_style="text-transform:none; float:none; font-size:smaller; background:none;",
# version=get_version())), # version=get_version())),
# reverse('admin:index') # reverse('admin:index')

View File

@ -1,7 +1,7 @@
from urllib import parse from urllib import parse
from django import forms from django import forms
from django.urls import re_path as 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
@ -12,9 +12,9 @@ from django.forms.models import BaseInlineFormSet
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.encoding import force_str from django.utils.encoding import force_text
from django.utils.html import escape from django.utils.html import escape
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_post_parameters from django.views.decorators.debug import sensitive_post_parameters
from orchestra.models.utils import has_db_field from orchestra.models.utils import has_db_field
@ -230,7 +230,7 @@ class ExtendedModelAdmin(ChangeViewActionsMixin,
if obj is None: if obj is None:
opts = self.model._meta opts = self.model._meta
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % { raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {
'name': force_str(opts.verbose_name), 'key': escape(object_id)}) 'name': force_text(opts.verbose_name), 'key': escape(object_id)})
return obj return obj

View File

@ -1,8 +1,8 @@
from django.contrib.admin.options import get_content_type_for_model from django.contrib.admin.options import get_content_type_for_model
from django.conf import settings as django_settings from django.conf import settings as django_settings
from django.utils.encoding import force_str from django.utils.encoding import force_text
from django.utils.module_loading import autodiscover_modules from django.utils.module_loading import autodiscover_modules
from django.utils.translation import gettext as _ from django.utils.translation import ugettext as _
from rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from orchestra import settings from orchestra import settings
@ -52,7 +52,7 @@ class LogApiMixin(object):
user_id=request.user.pk, user_id=request.user.pk,
content_type_id=get_content_type_for_model(instance).pk, content_type_id=get_content_type_for_model(instance).pk,
object_id=instance.pk, object_id=instance.pk,
object_repr=force_str(instance), object_repr=force_text(instance),
action_flag=action, action_flag=action,
change_message=message, change_message=message,
) )

View File

@ -3,7 +3,7 @@ import copy
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.forms import widgets from django.forms import widgets
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers from rest_framework import serializers
from rest_framework.utils import model_meta from rest_framework.utils import model_meta

0
orchestra/bin/celerybeat Normal file → Executable file
View File

0
orchestra/bin/celeryd Normal file → Executable file
View File

0
orchestra/bin/celeryevcam Normal file → Executable file
View File

0
orchestra/bin/django_bash_completion.sh Normal file → Executable file
View File

0
orchestra/bin/orchestra-admin Normal file → Executable file
View File

0
orchestra/bin/orchestra-beat Normal file → Executable file
View File

0
orchestra/bin/sieve-test Normal file → Executable file
View File

0
orchestra/conf/project_template/manage.py Normal file → Executable file
View File

View File

@ -9,10 +9,10 @@ from django.db import router
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.utils import timezone from django.utils import timezone
from django.utils.encoding import force_str 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 ngettext, gettext_lazy as _ from django.utils.translation import ungettext, ugettext_lazy as _
from orchestra.core import services from orchestra.core import services
@ -84,7 +84,7 @@ def delete_related_services(modeladmin, request, queryset):
def format(obj, account=False): 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_str(obj)) no_edit_link = '%s: %s' % (capfirst(opts.verbose_name), force_text(obj))
if has_admin: if has_admin:
try: try:
@ -154,7 +154,7 @@ def delete_related_services(modeladmin, request, queryset):
if accounts: if accounts:
relateds = len(to_delete) relateds = len(to_delete)
for obj in to_delete: for obj in to_delete:
obj_display = force_str(obj) obj_display = force_text(obj)
modeladmin.log_deletion(request, obj, obj_display) modeladmin.log_deletion(request, obj, obj_display)
obj.delete() obj.delete()
context = { context = {
@ -167,9 +167,9 @@ def delete_related_services(modeladmin, request, queryset):
return None return None
if len(queryset) == 1: if len(queryset) == 1:
objects_name = force_str(opts.verbose_name) objects_name = force_text(opts.verbose_name)
else: else:
objects_name = force_str(opts.verbose_name_plural) objects_name = force_text(opts.verbose_name_plural)
model_count = {} model_count = {}
for model, objs in collector.model_objs.items(): for model, objs in collector.model_objs.items():
@ -214,7 +214,7 @@ def disable_selected(modeladmin, request, queryset, disable=True):
account.disable() if disable else account.enable() account.disable() if disable else account.enable()
modeladmin.log_change(request, account, verbose_action_name.capitalize()) modeladmin.log_change(request, account, verbose_action_name.capitalize())
n += 1 n += 1
modeladmin.message_user(request, ngettext( modeladmin.message_user(request, ungettext(
_("One account has been successfully %s.") % verbose_action_name, _("One account has been successfully %s.") % verbose_action_name,
_("%i accounts have been successfully %s.") % (n, verbose_action_name), _("%i accounts have been successfully %s.") % (n, verbose_action_name),
n) n)
@ -227,7 +227,7 @@ def disable_selected(modeladmin, request, queryset, disable=True):
def format(obj): def format(obj):
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_str(obj)) no_edit_link = '%s: %s' % (capfirst(opts.verbose_name), force_text(obj))
if has_admin: if has_admin:
try: try:
admin_url = reverse( admin_url = reverse(
@ -258,9 +258,9 @@ def disable_selected(modeladmin, request, queryset, disable=True):
display.append([format(account), current]) display.append([format(account), current])
if len(queryset) == 1: if len(queryset) == 1:
objects_name = force_str(opts.verbose_name) objects_name = force_text(opts.verbose_name)
else: else:
objects_name = force_str(opts.verbose_name_plural) objects_name = force_text(opts.verbose_name_plural)
context = dict( context = dict(
admin_site.each_context(request), admin_site.each_context(request),

View File

@ -4,7 +4,7 @@ from urllib.parse import parse_qsl
from django import forms from django import forms
from django.apps import apps from django.apps import apps
from django.urls import re_path as 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
@ -12,7 +12,7 @@ from django.urls import reverse
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
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
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin
from orchestra.admin.actions import SendEmail from orchestra.admin.actions import SendEmail

View File

@ -1,4 +1,4 @@
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import viewsets, exceptions from rest_framework import viewsets, exceptions
from orchestra.api import router, SetPasswordApiMixin, LogApiMixin from orchestra.api import router, SetPasswordApiMixin, LogApiMixin

View File

@ -1,6 +1,6 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.db.models.signals import post_migrate from django.db.models.signals import post_migrate
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import services, accounts from orchestra.core import services, accounts

View File

@ -1,6 +1,6 @@
from django.contrib.admin import SimpleListFilter from django.contrib.admin import SimpleListFilter
from django.db.models import Q from django.db.models import Q
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class IsActiveListFilter(SimpleListFilter): class IsActiveListFilter(SimpleListFilter):

View File

@ -4,7 +4,7 @@ from collections import OrderedDict
from django import forms from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.apps import apps from django.apps import apps
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.forms import UserCreationForm from orchestra.forms import UserCreationForm

View File

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.validators
import django.db.models.deletion
import django.utils.timezone
import django.contrib.auth.models
class Migration(migrations.Migration):
dependencies = [
# Permissions and contenttypes
('auth', '0006_require_contenttypes_0002'),
('systemusers', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('password', models.CharField(verbose_name='password', max_length=128)),
('last_login', models.DateTimeField(blank=True, verbose_name='last login', null=True)),
('username', models.CharField(help_text='Required. 64 characters or fewer. Letters, digits and ./-/_ only.', unique=True, validators=[django.core.validators.RegexValidator('^[\\w.-]+$', 'Enter a valid username.', 'invalid')], max_length=32, verbose_name='username')),
('short_name', models.CharField(blank=True, verbose_name='short name', max_length=64)),
('full_name', models.CharField(verbose_name='full name', max_length=256)),
('email', models.EmailField(help_text='Used for password recovery', max_length=254, verbose_name='email address')),
('type', models.CharField(verbose_name='type', choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('COMPANY', 'Company'), ('PUBLICBODY', 'Public body'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], max_length=32, default='INDIVIDUAL')),
('language', models.CharField(verbose_name='language', choices=[('EN', 'English')], max_length=2, default='EN')),
('comments', models.TextField(blank=True, verbose_name='comments', max_length=256)),
('is_superuser', models.BooleanField(help_text='Designates that this user has all permissions without explicitly assigning them.', default=False, verbose_name='superuser status')),
('is_active', models.BooleanField(help_text='Designates whether this account should be treated as active. Unselect this instead of deleting accounts.', default=True, verbose_name='active')),
('date_joined', models.DateTimeField(verbose_name='date joined', default=django.utils.timezone.now)),
('main_systemuser', models.ForeignKey(to='systemusers.SystemUser', editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='accounts_main')),
],
options={
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]

View File

@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2021-04-22 11:08
from __future__ import unicode_literals
import django.contrib.auth.models
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import orchestra.contrib.accounts.models
class Migration(migrations.Migration):
replaces = [('accounts', '0001_initial'), ('accounts', '0002_auto_20170528_2005'), ('accounts', '0003_auto_20210330_1049'), ('accounts', '0004_auto_20210422_1108')]
initial = True
dependencies = [
('systemusers', '0001_initial'),
('auth', '0006_require_contenttypes_0002'),
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('username', models.CharField(help_text='Required. 64 characters or fewer. Letters, digits and ./-/_ only.', max_length=32, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.-]+$', 'Enter a valid username.', 'invalid')], verbose_name='username')),
('short_name', models.CharField(blank=True, max_length=64, verbose_name='short name')),
('full_name', models.CharField(max_length=256, verbose_name='full name')),
('email', models.EmailField(help_text='Used for password recovery', max_length=254, verbose_name='email address')),
('type', models.CharField(choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('COMPANY', 'Company'), ('PUBLICBODY', 'Public body'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], default='INDIVIDUAL', max_length=32, verbose_name='type')),
('language', models.CharField(choices=[('EN', 'English')], default='EN', max_length=2, verbose_name='language')),
('comments', models.TextField(blank=True, max_length=256, verbose_name='comments')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this account should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('main_systemuser', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='accounts_main', to='systemusers.SystemUser')),
],
options={
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
migrations.AlterModelManagers(
name='account',
managers=[
('objects', orchestra.contrib.accounts.models.AccountManager()),
],
),
migrations.AlterField(
model_name='account',
name='language',
field=models.CharField(choices=[('CA', 'Catalan'), ('ES', 'Spanish'), ('EN', 'English')], default='CA', max_length=2, verbose_name='language'),
),
migrations.AlterField(
model_name='account',
name='type',
field=models.CharField(choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], default='INDIVIDUAL', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='account',
name='username',
field=models.CharField(help_text='Required. 32 characters or fewer. Letters, digits and ./-/_ only.', max_length=32, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.-]+$', 'Enter a valid username.', 'invalid')], verbose_name='username'),
),
migrations.AlterField(
model_name='account',
name='language',
field=models.CharField(choices=[('EN', 'English')], default='EN', max_length=2, verbose_name='language'),
),
migrations.AlterField(
model_name='account',
name='type',
field=models.CharField(choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('COMPANY', 'Company'), ('PUBLICBODY', 'Public body'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], default='INDIVIDUAL', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='account',
name='main_systemuser',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='accounts_main', to='systemusers.SystemUser'),
),
]

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-28 18:05
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import orchestra.contrib.accounts.models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
]
operations = [
migrations.AlterModelManagers(
name='account',
managers=[
('objects', orchestra.contrib.accounts.models.AccountManager()),
],
),
migrations.AlterField(
model_name='account',
name='language',
field=models.CharField(choices=[('CA', 'Catalan'), ('ES', 'Spanish'), ('EN', 'English')], default='CA', max_length=2, verbose_name='language'),
),
migrations.AlterField(
model_name='account',
name='type',
field=models.CharField(choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], default='INDIVIDUAL', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='account',
name='username',
field=models.CharField(help_text='Required. 32 characters or fewer. Letters, digits and ./-/_ only.', max_length=32, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.-]+$', 'Enter a valid username.', 'invalid')], verbose_name='username'),
),
]

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2021-03-30 10:49
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0002_auto_20170528_2005'),
]
operations = [
migrations.AlterField(
model_name='account',
name='language',
field=models.CharField(choices=[('EN', 'English')], default='EN', max_length=2, verbose_name='language'),
),
migrations.AlterField(
model_name='account',
name='type',
field=models.CharField(choices=[('INDIVIDUAL', 'Individual'), ('ASSOCIATION', 'Association'), ('CUSTOMER', 'Customer'), ('COMPANY', 'Company'), ('PUBLICBODY', 'Public body'), ('STAFF', 'Staff'), ('FRIEND', 'Friend')], default='INDIVIDUAL', max_length=32, verbose_name='type'),
),
]

View File

@ -5,7 +5,7 @@ from django.db import models
from django.db.models import signals from django.db.models import signals
from django.apps import apps from django.apps import apps
from django.utils import timezone, translation from django.utils import timezone, translation
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
#from orchestra.contrib.orchestration.middlewares import OperationsMiddleware #from orchestra.contrib.orchestration.middlewares import OperationsMiddleware
#from orchestra.contrib.orchestration import Operation #from orchestra.contrib.orchestration import Operation
@ -165,6 +165,7 @@ class Account(auth.AbstractBaseUser):
elif obj and getattr(obj, 'account', None) == self: elif obj and getattr(obj, 'account', None) == self:
return True return True
def has_perms(self, perm_list, obj=None): def has_perms(self, perm_list, obj=None):
""" """
Returns True if the user has each of the specified permissions. If Returns True if the user has each of the specified permissions. If

View File

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

View File

@ -1,5 +1,5 @@
{% extends "orchestra/admin/change_form.html" %} {% extends "orchestra/admin/change_form.html" %}
{% load i18n admin_urls static admin_modify %} {% load i18n admin_urls admin_static admin_modify %}
{% block breadcrumbs %} {% block breadcrumbs %}

View File

@ -12,7 +12,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.utils import translation, timezone from django.utils import translation, timezone
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ngettext, gettext_lazy as _ from django.utils.translation import ungettext, ugettext_lazy as _
from orchestra.admin.decorators import action_with_confirmation from orchestra.admin.decorators import action_with_confirmation
from orchestra.admin.forms import AdminFormSet from orchestra.admin.forms import AdminFormSet
@ -69,7 +69,7 @@ def close_bills(modeladmin, request, queryset, action='close_bills'):
'url': url, 'url': url,
'num': num, 'num': num,
} }
message = ngettext( message = ungettext(
_('<a href="%(url)s">One related transaction</a> has been created') % context, _('<a href="%(url)s">One related transaction</a> has been created') % context,
_('<a href="%(url)s">%(num)i related transactions</a> have been created') % context, _('<a href="%(url)s">%(num)i related transactions</a> have been created') % context,
num) num)
@ -111,7 +111,7 @@ def send_bills_action(modeladmin, request, queryset):
bill.send() bill.send()
modeladmin.log_change(request, bill, 'Sent') modeladmin.log_change(request, bill, 'Sent')
num += 1 num += 1
messages.success(request, ngettext( messages.success(request, ungettext(
_("One bill has been sent."), _("One bill has been sent."),
_("%i bills have been sent.") % num, _("%i bills have been sent.") % num,
num)) num))
@ -135,7 +135,7 @@ def download_bills(modeladmin, request, queryset):
pdf = bill.as_pdf() pdf = bill.as_pdf()
archive.writestr('%s.pdf' % bill.number, pdf) archive.writestr('%s.pdf' % bill.number, pdf)
archive.close() archive.close()
response = HttpResponse(bytesio.getvalue(), content_type='application/zip') response = HttpResponse(bytesio.getvalue(), content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="orchestra-bills.zip"' response['Content-Disposition'] = 'attachment; filename="orchestra-bills.zip"'
return response return response
bill = queryset[0] bill = queryset[0]
@ -299,7 +299,7 @@ def amend_bills(modeladmin, request, queryset):
'url': amend_url, 'url': amend_url,
'num': num, 'num': num,
} }
messages.success(request, mark_safe(ngettext( messages.success(request, mark_safe(ungettext(
_('<a href="%(url)s">One amendment bill</a> have been generated.') % context, _('<a href="%(url)s">One amendment bill</a> have been generated.') % context,
_('<a href="%(url)s">%(num)i amendment bills</a> have been generated.') % context, _('<a href="%(url)s">%(num)i amendment bills</a> have been generated.') % context,
num num

View File

@ -1,5 +1,5 @@
from django import forms from django import forms
from django.urls import re_path as 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.urls import reverse from django.urls import reverse
@ -9,7 +9,7 @@ from django.db.models.functions import Coalesce
from django.templatetags.static import static from django.templatetags.static import static
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.shortcuts import redirect from django.shortcuts import redirect
from orchestra.admin import ExtendedModelAdmin from orchestra.admin import ExtendedModelAdmin
@ -126,7 +126,7 @@ class ClosedBillLineInline(BillLineInline):
return line.compute_total() return line.compute_total()
display_total.short_description = _("Total") display_total.short_description = _("Total")
def has_add_permission(self, request, obj): def has_add_permission(self, request):
return False return False

View File

@ -2,7 +2,7 @@ from django.contrib.admin import SimpleListFilter
from django.urls import reverse from django.urls import reverse
from django.db.models import Q from django.db.models import Q
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from . models import Bill from . models import Bill

View File

@ -1,5 +1,5 @@
from django import forms from django import forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin.utils import admin_link from orchestra.admin.utils import admin_link
from orchestra.forms import SpanWidget from orchestra.forms import SpanWidget

View File

@ -1,10 +1,10 @@
from django.contrib import messages from django.contrib import messages
from django.urls import reverse from django.urls import reverse
from django.utils.encoding import force_str from django.utils.encoding import force_text
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.text import capfirst from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin.utils import change_url from orchestra.admin.utils import change_url
@ -16,14 +16,14 @@ def validate_contact(request, bill, error=True):
valid = True valid = True
send = messages.error if error else messages.warning send = messages.error if error else messages.warning
if not hasattr(bill.account, 'billcontact'): if not hasattr(bill.account, 'billcontact'):
account = force_str(bill.account) account = force_text(bill.account)
url = reverse('admin:accounts_account_change', args=(bill.account_id,)) url = reverse('admin:accounts_account_change', args=(bill.account_id,))
message = msg.format(relation=_("Related"), account=account, url=url) message = msg.format(relation=_("Related"), account=account, url=url)
send(request, mark_safe(message)) send(request, mark_safe(message))
valid = False valid = False
main = type(bill).account.field.related_model.objects.get_main() main = type(bill).account.field.related_model.objects.get_main()
if not hasattr(main, 'billcontact'): if not hasattr(main, 'billcontact'):
account = force_str(main) account = force_text(main)
url = reverse('admin:accounts_account_change', args=(main.id,)) url = reverse('admin:accounts_account_change', args=(main.id,))
message = msg.format(relation=_("Main"), account=account, url=url) message = msg.format(relation=_("Main"), account=account, url=url)
send(request, mark_safe(message)) send(request, mark_safe(message))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,9 +8,9 @@ from django.db.models import F, Sum
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
from django.template import loader from django.template import loader
from django.utils import timezone, translation from django.utils import timezone, translation
from django.utils.encoding import force_str from django.utils.encoding import force_text
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin.utils import change_url from orchestra.admin.utils import change_url
from orchestra.contrib.accounts.models import Account from orchestra.contrib.accounts.models import Account
@ -209,7 +209,7 @@ class Bill(models.Model):
def get_payment_state_display(self): def get_payment_state_display(self):
value = self.payment_state value = self.payment_state
return force_str(dict(self.PAYMENT_STATES).get(value, value)) return force_text(dict(self.PAYMENT_STATES).get(value, value))
def get_current_transaction(self): def get_current_transaction(self):
return self.transactions.exclude_rejected().first() return self.transactions.exclude_rejected().first()

View File

@ -1,6 +1,6 @@
from django import forms from django import forms
from django.contrib import admin from django.contrib import admin
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin import AtLeastOneRequiredInlineFormSet, ExtendedModelAdmin from orchestra.admin import AtLeastOneRequiredInlineFormSet, ExtendedModelAdmin
from orchestra.admin.actions import SendEmail from orchestra.admin.actions import SendEmail

View File

@ -1,5 +1,5 @@
from django.contrib.admin import SimpleListFilter from django.contrib.admin import SimpleListFilter
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .models import Contact from .models import Contact

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import validators from orchestra.core import validators
from orchestra.models.fields import MultiSelectField from orchestra.models.fields import MultiSelectField

View File

@ -1,9 +1,9 @@
from django.urls import re_path as url 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.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin
from orchestra.admin.utils import change_url from orchestra.admin.utils import change_url
@ -11,7 +11,7 @@ from orchestra.contrib.accounts.actions import list_accounts
from orchestra.contrib.accounts.admin import SelectAccountAdminMixin from orchestra.contrib.accounts.admin import SelectAccountAdminMixin
from .filters import HasUserListFilter, HasDatabaseListFilter from .filters import HasUserListFilter, HasDatabaseListFilter
from .forms import DatabaseCreationForm, DatabaseUserChangeForm, DatabaseUserCreationForm, DatabaseForm from .forms import DatabaseCreationForm, DatabaseUserChangeForm, DatabaseUserCreationForm
from .models import Database, DatabaseUser from .models import Database, DatabaseUser
def save_selected(modeladmin, request, queryset): def save_selected(modeladmin, request, queryset):
@ -23,18 +23,18 @@ class DatabaseAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
list_display = ('name', 'type', 'display_users', 'account_link') list_display = ('name', 'type', 'display_users', 'account_link')
list_filter = ('type', HasUserListFilter) list_filter = ('type', HasUserListFilter)
search_fields = ('name', 'account__username') search_fields = ('name', 'account__username')
change_readonly_fields = ('name', 'type', 'target_server') change_readonly_fields = ('name', 'type')
extra = 1 extra = 1
fieldsets = ( fieldsets = (
(None, { (None, {
'classes': ('extrapretty',), 'classes': ('extrapretty',),
'fields': ('account_link', 'name', 'type', 'users', 'display_users', 'comments', 'target_server'), 'fields': ('account_link', 'name', 'type', 'users', 'display_users', 'comments'),
}), }),
) )
add_fieldsets = ( add_fieldsets = (
(None, { (None, {
'classes': ('wide',), 'classes': ('wide',),
'fields': ('account_link', 'name', 'type', 'target_server') 'fields': ('account_link', 'name', 'type')
}), }),
(_("Create new user"), { (_("Create new user"), {
'classes': ('wide',), 'classes': ('wide',),
@ -45,12 +45,11 @@ class DatabaseAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
'fields': ('user',) 'fields': ('user',)
}), }),
) )
form = DatabaseForm
add_form = DatabaseCreationForm add_form = DatabaseCreationForm
readonly_fields = ('account_link', 'display_users',) readonly_fields = ('account_link', 'display_users',)
filter_horizontal = ['users'] filter_horizontal = ['users']
# filter_by_account_fields = ('users',) filter_by_account_fields = ('users',)
# list_prefetch_related = ('users',) list_prefetch_related = ('users',)
actions = (list_accounts, save_selected) actions = (list_accounts, save_selected)
@mark_safe @mark_safe
@ -72,7 +71,6 @@ class DatabaseAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
username=form.cleaned_data['username'], username=form.cleaned_data['username'],
type=obj.type, type=obj.type,
account_id=obj.account.pk, account_id=obj.account.pk,
target_server=form.cleaned_data['target_server'],
) )
user.set_password(form.cleaned_data["password1"]) user.set_password(form.cleaned_data["password1"])
user.save() user.save()
@ -80,22 +78,22 @@ class DatabaseAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
class DatabaseUserAdmin(SelectAccountAdminMixin, ChangePasswordAdminMixin, ExtendedModelAdmin): class DatabaseUserAdmin(SelectAccountAdminMixin, ChangePasswordAdminMixin, ExtendedModelAdmin):
list_display = ('username', 'target_server', 'type', 'display_databases', 'account_link') list_display = ('username', 'type', 'display_databases', 'account_link')
list_filter = ('type', HasDatabaseListFilter) list_filter = ('type', HasDatabaseListFilter)
search_fields = ('username', 'account__username') search_fields = ('username', 'account__username')
form = DatabaseUserChangeForm form = DatabaseUserChangeForm
add_form = DatabaseUserCreationForm add_form = DatabaseUserCreationForm
change_readonly_fields = ('username', 'type', 'target_server') change_readonly_fields = ('username', 'type')
fieldsets = ( fieldsets = (
(None, { (None, {
'classes': ('extrapretty',), 'classes': ('extrapretty',),
'fields': ('account_link', 'username', 'password', 'type', 'display_databases', 'target_server', 'permision') 'fields': ('account_link', 'username', 'password', 'type', 'display_databases')
}), }),
) )
add_fieldsets = ( add_fieldsets = (
(None, { (None, {
'classes': ('extrapretty',), 'classes': ('extrapretty',),
'fields': ('account_link', 'username', 'password1', 'password2', 'type', 'target_server', 'permision') 'fields': ('account_link', 'username', 'password1', 'password2', 'type')
}), }),
) )
readonly_fields = ('account_link', 'display_databases',) readonly_fields = ('account_link', 'display_databases',)

View File

@ -1,5 +1,5 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import services from orchestra.core import services

View File

@ -1,6 +1,6 @@
import textwrap import textwrap
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
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
@ -36,16 +36,10 @@ class MySQLController(ServiceController):
'username': user.username, 'username': user.username,
'grant': 'WITH GRANT OPTION' if user == context['owner'] else '' 'grant': 'WITH GRANT OPTION' if user == context['owner'] else ''
}) })
if user.permision == "ro": self.append(textwrap.dedent("""\
self.append(textwrap.dedent("""\ mysql -e 'GRANT ALL PRIVILEGES ON `%(database)s`.* TO "%(username)s"@"%(host)s" %(grant)s;'\
mysql -e 'GRANT SELECT ON `%(database)s`.* TO "%(username)s"@"%(host)s" %(grant)s;'\ """) % context
""") % context )
)
else:
self.append(textwrap.dedent("""\
mysql -e 'GRANT ALL PRIVILEGES ON `%(database)s`.* TO "%(username)s"@"%(host)s" %(grant)s;'\
""") % context
)
def delete(self, database): def delete(self, database):
if database.type != database.MYSQL: if database.type != database.MYSQL:
@ -89,20 +83,12 @@ class MySQLUserController(ServiceController):
if user.type != user.MYSQL: if user.type != user.MYSQL:
return return
context = self.get_context(user) context = self.get_context(user)
if user.target_server.name != "mysql.pangea.lan": self.append(textwrap.dedent("""\
self.append(textwrap.dedent("""\ # Create user %(username)s
# Create user %(username)s mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists
mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";' mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\
mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\ """) % context
""") % context )
)
else:
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists
mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\
""") % context
)
def delete(self, user): def delete(self, user):
if user.type != user.MYSQL: if user.type != user.MYSQL:
@ -186,7 +172,7 @@ class MysqlDisk(ServiceMonitor):
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('-', '@002d'), 'db_dirname': db.name.replace('-', '@003f'),
'db_id': db.pk, 'db_id': db.pk,
'db_type': db.type, 'db_type': db.type,
} }

View File

@ -1,5 +1,5 @@
from django.contrib.admin import SimpleListFilter from django.contrib.admin import SimpleListFilter
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class HasUserListFilter(SimpleListFilter): class HasUserListFilter(SimpleListFilter):

View File

@ -3,7 +3,7 @@ from django.contrib.auth.forms import ReadOnlyPasswordHashField
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import validators from orchestra.core import validators
@ -31,32 +31,6 @@ class DatabaseUserCreationForm(forms.ModelForm):
return password2 return password2
class DatabaseForm(forms.ModelForm):
class Meta:
model = Database
fields = ('name', 'users', 'type', 'account', 'target_server')
def __init__(self, *args, **kwargs):
super(DatabaseForm, self).__init__(*args, **kwargs)
# muestra solo los usuarios del mismo server
account_id = self.instance.account_id
database_server_id = self.instance.target_server_id
if account_id:
self.fields['users'].queryset = DatabaseUser.objects.filter(account=account_id, target_server=database_server_id)
def clean(self):
# verifica que los usuarios petenecen al servidor de la bbdd
database_server_id = self.instance.target_server_id
users = self.cleaned_data.get('users')
if users and database_server_id:
for user in users:
if user.target_server_id != database_server_id:
self.add_error("users", _(f"{user.username} does not belong to the database server"))
return self.cleaned_data
class DatabaseCreationForm(DatabaseUserCreationForm): class DatabaseCreationForm(DatabaseUserCreationForm):
username = forms.CharField(label=_("Username"), max_length=16, username = forms.CharField(label=_("Username"), max_length=16,
required=False, validators=[validators.validate_name], required=False, validators=[validators.validate_name],
@ -76,14 +50,13 @@ class DatabaseCreationForm(DatabaseUserCreationForm):
account_id = self.initial.get('account', self.initial_account) account_id = self.initial.get('account', self.initial_account)
if account_id: if account_id:
qs = self.fields['user'].queryset.filter(account=account_id).order_by('username') qs = self.fields['user'].queryset.filter(account=account_id).order_by('username')
choices = [ (u.pk, "%s (%s) (%s)" % (u, u.get_type_display(), str(u.target_server.name) )) for u in qs ] choices = [ (u.pk, "%s (%s)" % (u, u.get_type_display())) for u in qs ]
self.fields['user'].queryset = qs self.fields['user'].queryset = qs
self.fields['user'].choices = [(None, '--------'),] + choices self.fields['user'].choices = [(None, '--------'),] + choices
def clean_username(self): def clean_username(self):
username = self.cleaned_data.get('username') username = self.cleaned_data.get('username')
server = self.cleaned_data.get('target_server') if DatabaseUser.objects.filter(username=username).exists():
if DatabaseUser.objects.filter(username=username, target_server=server).exists():
raise ValidationError("Provided username already exists.") raise ValidationError("Provided username already exists.")
return username return username
@ -103,9 +76,6 @@ class DatabaseCreationForm(DatabaseUserCreationForm):
if user and user.type != self.cleaned_data.get('type'): if user and user.type != self.cleaned_data.get('type'):
msg = _("Database type and user type doesn't match") msg = _("Database type and user type doesn't match")
raise ValidationError(msg) raise ValidationError(msg)
if user and user.target_server != self.cleaned_data.get('target_server'):
msg = _("Database server and user server doesn't match")
raise ValidationError(msg)
return user return user
def clean(self): def clean(self):

View File

@ -1,46 +1,52 @@
# Generated by Django 2.2.28 on 2023-06-28 17:06 # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import orchestra.core.validators import orchestra.core.validators
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True
dependencies = [ dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
] ]
operations = [ operations = [
migrations.CreateModel(
name='Database',
fields=[
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
('name', models.CharField(verbose_name='name', max_length=64, validators=[orchestra.core.validators.validate_name])),
('type', models.CharField(default='mysql', choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], verbose_name='type', max_length=32)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databases', verbose_name='Account', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel( migrations.CreateModel(
name='DatabaseUser', name='DatabaseUser',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
('username', models.CharField(max_length=16, validators=[orchestra.core.validators.validate_name], verbose_name='username')), ('username', models.CharField(verbose_name='username', max_length=16, validators=[orchestra.core.validators.validate_name])),
('password', models.CharField(max_length=256, verbose_name='password')), ('password', models.CharField(verbose_name='password', max_length=256)),
('type', models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type')), ('type', models.CharField(default='mysql', choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], verbose_name='type', max_length=32)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databaseusers', to=settings.AUTH_USER_MODEL, verbose_name='Account')), ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databaseusers', verbose_name='Account', to=settings.AUTH_USER_MODEL)),
], ],
options={ options={
'verbose_name_plural': 'DB users', 'verbose_name_plural': 'DB users',
'unique_together': {('username', 'type')},
}, },
), ),
migrations.CreateModel( migrations.AddField(
name='Database', model_name='database',
fields=[ name='users',
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), field=models.ManyToManyField(related_name='databases', to='databases.DatabaseUser', verbose_name='users', blank=True),
('name', models.CharField(max_length=64, validators=[orchestra.core.validators.validate_name], verbose_name='name')), ),
('type', models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type')), migrations.AlterUniqueTogether(
('comments', models.TextField(blank=True, default='')), name='databaseuser',
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databases', to=settings.AUTH_USER_MODEL, verbose_name='Account')), unique_together=set([('username', 'type')]),
('users', models.ManyToManyField(blank=True, related_name='databases', to='databases.DatabaseUser', verbose_name='users')), ),
], migrations.AlterUniqueTogether(
options={ name='database',
'unique_together': {('name', 'type')}, unique_together=set([('name', 'type')]),
},
), ),
] ]

View File

@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2021-04-22 11:25
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import orchestra.core.validators
class Migration(migrations.Migration):
replaces = [('databases', '0001_initial'), ('databases', '0002_auto_20170528_2005'), ('databases', '0003_database_comments'), ('databases', '0004_auto_20210330_1049')]
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Database',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64, validators=[orchestra.core.validators.validate_name], verbose_name='name')),
('type', models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type')),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databases', to=settings.AUTH_USER_MODEL, verbose_name='Account')),
],
),
migrations.CreateModel(
name='DatabaseUser',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=16, validators=[orchestra.core.validators.validate_name], verbose_name='username')),
('password', models.CharField(max_length=256, verbose_name='password')),
('type', models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type')),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='databaseusers', to=settings.AUTH_USER_MODEL, verbose_name='Account')),
],
options={
'verbose_name_plural': 'DB users',
},
),
migrations.AddField(
model_name='database',
name='users',
field=models.ManyToManyField(blank=True, related_name='databases', to='databases.DatabaseUser', verbose_name='users'),
),
migrations.AlterUniqueTogether(
name='databaseuser',
unique_together=set([('username', 'type')]),
),
migrations.AlterUniqueTogether(
name='database',
unique_together=set([('name', 'type')]),
),
migrations.AlterField(
model_name='database',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='databaseuser',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type'),
),
migrations.AddField(
model_name='database',
name='comments',
field=models.TextField(blank=True, default=''),
),
migrations.AlterField(
model_name='database',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='databaseuser',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type'),
),
]

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-28 18:05
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('databases', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='database',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='databaseuser',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL')], default='mysql', max_length=32, verbose_name='type'),
),
]

View File

@ -1,20 +0,0 @@
# Generated by Django 2.2.28 on 2023-06-28 17:11
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('orchestration', '__first__'),
('databases', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='databaseuser',
name='target_server',
field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='orchestration.Server', verbose_name='Target Server'),
),
]

View File

@ -1,29 +0,0 @@
# Generated by Django 2.2.28 on 2023-06-29 16:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('orchestration', '__first__'),
('databases', '0002_databaseuser_target_server'),
]
operations = [
migrations.AddField(
model_name='databaseuser',
name='permision',
field=models.CharField(choices=[('all', 'all'), ('ro', 'read only')], default='all', max_length=20, verbose_name='Permisson'),
),
migrations.AlterField(
model_name='databaseuser',
name='target_server',
field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='orchestration.Server', verbose_name='Server'),
),
migrations.AlterUniqueTogether(
name='databaseuser',
unique_together={('username', 'type', 'target_server')},
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2020-02-04 11:21
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('databases', '0002_auto_20170528_2005'),
]
operations = [
migrations.AddField(
model_name='database',
name='comments',
field=models.TextField(default=''),
),
]

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2021-03-30 10:49
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('databases', '0003_database_comments'),
]
operations = [
migrations.AlterField(
model_name='database',
name='comments',
field=models.TextField(blank=True, default=''),
),
migrations.AlterField(
model_name='database',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type'),
),
migrations.AlterField(
model_name='databaseuser',
name='type',
field=models.CharField(choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], default='mysql', max_length=32, verbose_name='type'),
),
]

View File

@ -1,20 +0,0 @@
# Generated by Django 2.2.28 on 2023-06-29 16:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('orchestration', '__first__'),
('databases', '0003_auto_20230629_1838'),
]
operations = [
migrations.AddField(
model_name='database',
name='target_server',
field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='orchestration.Server', verbose_name='Server'),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 2.2.28 on 2023-07-05 10:08
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('orchestration', '__first__'),
('databases', '0004_database_target_server'),
]
operations = [
migrations.AlterUniqueTogether(
name='database',
unique_together={('name', 'type', 'target_server')},
),
]

View File

@ -1,19 +0,0 @@
# Generated by Django 2.2.28 on 2023-07-05 10:37
from django.db import migrations, models
import orchestra.core.validators
class Migration(migrations.Migration):
dependencies = [
('databases', '0005_auto_20230705_1208'),
]
operations = [
migrations.AlterField(
model_name='databaseuser',
name='username',
field=models.CharField(max_length=32, validators=[orchestra.core.validators.validate_name], verbose_name='username'),
),
]

View File

@ -1,7 +1,7 @@
import hashlib import hashlib
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.core import validators from orchestra.core import validators
@ -23,11 +23,9 @@ class Database(models.Model):
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE, account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
verbose_name=_("Account"), related_name='databases') verbose_name=_("Account"), related_name='databases')
comments = models.TextField(default="", blank=True) comments = models.TextField(default="", blank=True)
target_server = models.ForeignKey('orchestration.Server', on_delete=models.CASCADE,
verbose_name=_("Server"), default=3 )
class Meta: class Meta:
unique_together = ('name', 'type', 'target_server') unique_together = ('name', 'type')
def __str__(self): def __str__(self):
return "%s" % self.name return "%s" % self.name
@ -56,12 +54,7 @@ class DatabaseUser(models.Model):
MYSQL = Database.MYSQL MYSQL = Database.MYSQL
POSTGRESQL = Database.POSTGRESQL POSTGRESQL = Database.POSTGRESQL
typeOfPermision = [ username = models.CharField(_("username"), max_length=16, # MySQL usernames 16 char long
('all','all'),
('ro', 'read only'),
]
username = models.CharField(_("username"), max_length=32, # MySQL usernames 16 char long
validators=[validators.validate_name]) validators=[validators.validate_name])
password = models.CharField(_("password"), max_length=256) password = models.CharField(_("password"), max_length=256)
type = models.CharField(_("type"), max_length=32, type = models.CharField(_("type"), max_length=32,
@ -69,14 +62,10 @@ class DatabaseUser(models.Model):
default=settings.DATABASES_DEFAULT_TYPE) default=settings.DATABASES_DEFAULT_TYPE)
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE, account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
verbose_name=_("Account"), related_name='databaseusers') verbose_name=_("Account"), related_name='databaseusers')
target_server = models.ForeignKey('orchestration.Server', on_delete=models.CASCADE,
verbose_name=_("Server"), default=3 )
permision = models.CharField(verbose_name=_("Permisson"), max_length=20, choices=typeOfPermision, default='all')
class Meta: class Meta:
verbose_name_plural = _("DB users") verbose_name_plural = _("DB users")
unique_together = ('username', 'type', 'target_server') unique_together = ('username', 'type')
def __str__(self): def __str__(self):
return self.username return self.username

View File

@ -7,7 +7,7 @@ from django.db.models.functions import Concat, Coalesce
from django.forms.models import modelformset_factory from django.forms.models import modelformset_factory
from django.shortcuts import render from django.shortcuts import render
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ngettext, gettext_lazy as _ from django.utils.translation import ungettext, ugettext_lazy as _
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from orchestra.admin.utils import get_object_from_url, change_url, admin_link from orchestra.admin.utils import get_object_from_url, change_url, admin_link
@ -84,7 +84,7 @@ def edit_records(modeladmin, request, queryset):
change_message = modeladmin.construct_change_message(request, fake_form, [formset]) change_message = modeladmin.construct_change_message(request, fake_form, [formset])
modeladmin.log_change(request, formset.instance, change_message) modeladmin.log_change(request, formset.instance, change_message)
num = len(formsets) num = len(formsets)
message = ngettext( message = ungettext(
_("Records for one selected domain have been updated."), _("Records for one selected domain have been updated."),
_("Records for %i selected domains have been updated.") % num, _("Records for %i selected domains have been updated.") % num,
num) num)
@ -127,7 +127,7 @@ def set_soa(modeladmin, request, queryset):
modeladmin.log_change(request, domain, change_message) modeladmin.log_change(request, domain, change_message)
domain.save() domain.save()
num = len(queryset) num = len(queryset)
msg = ngettext( msg = ungettext(
_("SOA record for one domain has been updated."), _("SOA record for one domain has been updated."),
_("SOA record for %s domains has been updated.") % num, _("SOA record for %s domains has been updated.") % num,
num num

View File

@ -5,7 +5,7 @@ from django.db.models.functions import Concat, Coalesce
from django.templatetags.static import static from django.templatetags.static import static
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext, gettext_lazy as _ from django.utils.translation import ugettext, ugettext_lazy as _
from orchestra.admin import ExtendedModelAdmin from orchestra.admin import ExtendedModelAdmin
from orchestra.admin.utils import admin_link, change_url from orchestra.admin.utils import admin_link, change_url

View File

@ -2,7 +2,7 @@ import re
import socket import socket
import textwrap import textwrap
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.orchestration import ServiceController from orchestra.contrib.orchestration import ServiceController
from orchestra.contrib.orchestration import Operation from orchestra.contrib.orchestration import Operation

View File

@ -1,5 +1,5 @@
from django.contrib.admin import SimpleListFilter from django.contrib.admin import SimpleListFilter
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
class TopDomainListFilter(SimpleListFilter): class TopDomainListFilter(SimpleListFilter):

View File

@ -1,7 +1,7 @@
from django import forms from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.text import capfirst from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orchestra.admin.forms import AdminFormSet, AdminFormMixin from orchestra.admin.forms import AdminFormSet, AdminFormMixin

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
import orchestra.contrib.domains.utils
import orchestra.contrib.domains.validators
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Domain',
fields=[
('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')),
('name', models.CharField(unique=True, max_length=256, validators=[orchestra.contrib.domains.validators.validate_domain_name, orchestra.contrib.domains.validators.validate_allowed_domain], verbose_name='name', help_text='Domain or subdomain name.')),
('serial', models.IntegerField(default=orchestra.contrib.domains.utils.generate_zone_serial, verbose_name='serial', help_text='Serial number')),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='domains', help_text='Automatically selected for subdomains.', to=settings.AUTH_USER_MODEL, verbose_name='Account', blank=True)),
('top', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, null=True, to='domains.Domain', editable=False, related_name='subdomain_set')),
],
),
migrations.CreateModel(
name='Record',
fields=[
('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')),
('ttl', models.CharField(help_text='Record TTL, defaults to 1h', max_length=8, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='TTL', blank=True)),
('type', models.CharField(max_length=32, verbose_name='type', choices=[('MX', 'MX'), ('NS', 'NS'), ('CNAME', 'CNAME'), ('A', 'A (IPv4 address)'), ('AAAA', 'AAAA (IPv6 address)'), ('SRV', 'SRV'), ('TXT', 'TXT'), ('SOA', 'SOA')])),
('value', models.CharField(max_length=256, verbose_name='value')),
('domain', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='records', to='domains.Domain', verbose_name='domain')),
],
),
]

View File

@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2021-04-22 11:27
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import orchestra.contrib.domains.utils
import orchestra.contrib.domains.validators
class Migration(migrations.Migration):
replaces = [('domains', '0001_initial'), ('domains', '0002_auto_20150715_1017'), ('domains', '0003_auto_20150720_1121'), ('domains', '0004_auto_20150720_1121'), ('domains', '0005_auto_20160219_1034'), ('domains', '0006_auto_20170528_2011'), ('domains', '0007_auto_20190805_1134'), ('domains', '0008_domain_dns2136_address_match_list'), ('domains', '0009_auto_20200204_1217'), ('domains', '0010_auto_20210330_1049')]
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Domain',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Domain or subdomain name.', max_length=256, unique=True, validators=[orchestra.contrib.domains.validators.validate_domain_name, orchestra.contrib.domains.validators.validate_allowed_domain], verbose_name='name')),
('serial', models.IntegerField(default=orchestra.contrib.domains.utils.generate_zone_serial, help_text='Serial number', verbose_name='serial')),
('account', models.ForeignKey(blank=True, help_text='Automatically selected for subdomains.', on_delete=django.db.models.deletion.CASCADE, related_name='domains', to=settings.AUTH_USER_MODEL, verbose_name='Account')),
('top', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subdomain_set', to='domains.Domain')),
],
),
migrations.CreateModel(
name='Record',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ttl', models.CharField(blank=True, help_text='Record TTL, defaults to 1h', max_length=8, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='TTL')),
('type', models.CharField(choices=[('MX', 'MX'), ('NS', 'NS'), ('CNAME', 'CNAME'), ('A', 'A (IPv4 address)'), ('AAAA', 'AAAA (IPv6 address)'), ('SRV', 'SRV'), ('TXT', 'TXT'), ('SPF', 'SPF')], max_length=32, verbose_name='type')),
('value', models.CharField(help_text='MX, NS and CNAME records sould end with a dot.', max_length=1024, verbose_name='value')),
('domain', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='records', to='domains.Domain', verbose_name='domain')),
],
),
migrations.AlterField(
model_name='domain',
name='serial',
field=models.IntegerField(default=orchestra.contrib.domains.utils.generate_zone_serial, editable=False, help_text='A revision number that changes whenever this domain is updated.', verbose_name='serial'),
),
migrations.AddField(
model_name='domain',
name='expire',
field=models.CharField(blank=True, help_text='The time that a secondary server will keep trying to complete a zone transfer. If this time expires prior to a successful zone transfer, the secondary server will expire its zone file. This means the secondary will stop answering queries. The default value is <tt>4w</tt>.', max_length=16, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='expire'),
),
migrations.AddField(
model_name='domain',
name='min_ttl',
field=models.CharField(blank=True, help_text='The minimum time-to-live value applies to all resource records in the zone file. This value is supplied in query responses to inform other servers how long they should keep the data in cache. The default value is <tt>1h</tt>.', max_length=16, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='min TTL'),
),
migrations.AddField(
model_name='domain',
name='refresh',
field=models.CharField(blank=True, help_text="The time a secondary DNS server waits before querying the primary DNS server's SOA record to check for changes. When the refresh time expires, the secondary DNS server requests a copy of the current SOA record from the primary. The primary DNS server complies with this request. The secondary DNS server compares the serial number of the primary DNS server's current SOA record and the serial number in it's own SOA record. If they are different, the secondary DNS server will request a zone transfer from the primary DNS server. The default value is <tt>1d</tt>.", max_length=16, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='refresh'),
),
migrations.AddField(
model_name='domain',
name='retry',
field=models.CharField(blank=True, help_text='The time a secondary server waits before retrying a failed zone transfer. Normally, the retry time is less than the refresh time. The default value is <tt>2h</tt>.', max_length=16, validators=[orchestra.contrib.domains.validators.validate_zone_interval], verbose_name='retry'),
),
migrations.AlterField(
model_name='domain',
name='name',
field=models.CharField(db_index=True, help_text='Domain or subdomain name.', max_length=256, unique=True, validators=[orchestra.contrib.domains.validators.validate_domain_name, orchestra.contrib.domains.validators.validate_allowed_domain], verbose_name='name'),
),
migrations.AlterField(
model_name='domain',
name='top',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subdomain_set', to='domains.Domain', verbose_name='top domain'),
),
migrations.AddField(
model_name='domain',
name='dns2136_address_match_list',
field=models.CharField(blank=True, default='key pangea.key;', help_text="A bind-9 'address_match_list' that will be granted permission to perform dns2136 updates. Chiefly used to enable Let's Encrypt self-service validation.", max_length=80),
),
]

View File

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('domains', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='domain',
name='expire',
field=models.IntegerField(null=True, blank=True, help_text='The upper limit in seconds before a zone is considered no longer authoritative (4w by default).', verbose_name='expire'),
),
migrations.AddField(
model_name='domain',
name='min_ttl',
field=models.IntegerField(null=True, blank=True, help_text='The negative result TTL (for example, how long a resolver should consider a negative result for a subdomain to be valid before retrying) (1h by default).', verbose_name='refresh'),
),
migrations.AddField(
model_name='domain',
name='refresh',
field=models.IntegerField(null=True, blank=True, help_text='The number of seconds before the zone should be refreshed (1d by default).', verbose_name='refresh'),
),
migrations.AddField(
model_name='domain',
name='retry',
field=models.IntegerField(null=True, blank=True, help_text='The number of seconds before a failed refresh should be retried (2h by default).', verbose_name='retry'),
),
migrations.AlterField(
model_name='record',
name='value',
field=models.CharField(max_length=256, help_text='MX, NS and CNAME records sould end with a dot.', verbose_name='value'),
),
]

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import orchestra.contrib.domains.utils
class Migration(migrations.Migration):
dependencies = [
('domains', '0002_auto_20150715_1017'),
]
operations = [
migrations.RemoveField(
model_name='domain',
name='expire',
),
migrations.RemoveField(
model_name='domain',
name='min_ttl',
),
migrations.RemoveField(
model_name='domain',
name='refresh',
),
migrations.RemoveField(
model_name='domain',
name='retry',
),
migrations.AlterField(
model_name='domain',
name='serial',
field=models.IntegerField(editable=False, verbose_name='serial', default=orchestra.contrib.domains.utils.generate_zone_serial, help_text='A revision number that changes whenever this domain is updated.'),
),
]

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import orchestra.contrib.domains.validators
class Migration(migrations.Migration):
dependencies = [
('domains', '0003_auto_20150720_1121'),
]
operations = [
migrations.AddField(
model_name='domain',
name='expire',
field=models.CharField(validators=[orchestra.contrib.domains.validators.validate_zone_interval], blank=True, help_text='The time that a secondary server will keep trying to complete a zone transfer. If this time expires prior to a successful zone transfer, the secondary server will expire its zone file. This means the secondary will stop answering queries. The default value is <tt>4w</tt>.', verbose_name='expire', max_length=16),
),
migrations.AddField(
model_name='domain',
name='min_ttl',
field=models.CharField(validators=[orchestra.contrib.domains.validators.validate_zone_interval], blank=True, help_text='The minimum time-to-live value applies to all resource records in the zone file. This value is supplied in query responses to inform other servers how long they should keep the data in cache. The default value is <tt>1h</tt>.', verbose_name='min TTL', max_length=16),
),
migrations.AddField(
model_name='domain',
name='refresh',
field=models.CharField(validators=[orchestra.contrib.domains.validators.validate_zone_interval], blank=True, help_text="The time a secondary DNS server waits before querying the primary DNS server's SOA record to check for changes. When the refresh time expires, the secondary DNS server requests a copy of the current SOA record from the primary. The primary DNS server complies with this request. The secondary DNS server compares the serial number of the primary DNS server's current SOA record and the serial number in it's own SOA record. If they are different, the secondary DNS server will request a zone transfer from the primary DNS server. The default value is <tt>1d</tt>.", verbose_name='refresh', max_length=16),
),
migrations.AddField(
model_name='domain',
name='retry',
field=models.CharField(validators=[orchestra.contrib.domains.validators.validate_zone_interval], blank=True, help_text='The time a secondary server waits before retrying a failed zone transfer. Normally, the retry time is less than the refresh time. The default value is <tt>2h</tt>.', verbose_name='retry', max_length=16),
),
]

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import orchestra.contrib.domains.validators
class Migration(migrations.Migration):
dependencies = [
('domains', '0004_auto_20150720_1121'),
]
operations = [
migrations.AlterField(
model_name='domain',
name='name',
field=models.CharField(max_length=256, validators=[orchestra.contrib.domains.validators.validate_domain_name, orchestra.contrib.domains.validators.validate_allowed_domain], db_index=True, verbose_name='name', unique=True, help_text='Domain or subdomain name.'),
),
migrations.AlterField(
model_name='domain',
name='top',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, editable=False, verbose_name='top domain', related_name='subdomain_set', to='domains.Domain', null=True),
),
migrations.AlterField(
model_name='record',
name='type',
field=models.CharField(max_length=32, verbose_name='type', choices=[('MX', 'MX'), ('NS', 'NS'), ('CNAME', 'CNAME'), ('A', 'A (IPv4 address)'), ('AAAA', 'AAAA (IPv6 address)'), ('SRV', 'SRV'), ('TXT', 'TXT'), ('SPF', 'SPF'), ('SOA', 'SOA')]),
),
]

Some files were not shown because too many files have changed in this diff Show More