Fixes on orchestra deployment
This commit is contained in:
parent
d44adc957b
commit
2c6bd0469b
|
@ -39,10 +39,9 @@ Django-orchestra can be installed on any Linux system, however it is **strongly
|
|||
5. Create and configure a Postgres database
|
||||
```bash
|
||||
sudo python3 manage.py setuppostgres --db_password <password>
|
||||
python3 manage.py migrate auth
|
||||
# admin_tools needs accounts and does not have migrations
|
||||
python3 manage.py migrate accounts
|
||||
python3 manage.py migrate
|
||||
python3 manage.py syncdb
|
||||
```
|
||||
|
||||
7. Configure celeryd
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -296,3 +296,5 @@ https://code.djangoproject.com/ticket/24576
|
|||
|
||||
# admin edit relevant djanog settings
|
||||
# django SITE_NAME vs ORCHESTRA_SITE_NAME ?
|
||||
|
||||
# accounts.migrations link to last auth migration instead of first
|
||||
|
|
|
@ -70,4 +70,3 @@ LOCALE_PATHS = (
|
|||
|
||||
|
||||
ORCHESTRA_SITE_NAME = '{{ project_name }}'
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import django.contrib.auth.models
|
|||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '__first__'),
|
||||
('contenttypes', '__first__'),
|
||||
# Permissions and contenttypes
|
||||
('auth', '0006_require_contenttypes_0002'),
|
||||
('systemusers', '0001_initial'),
|
||||
]
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ class DomainSerializer(AccountSerializerMixin, HyperlinkedModelSerializer):
|
|||
def clean_name(self, attrs, source):
|
||||
""" prevent users creating subdomains of other users domains """
|
||||
name = attrs[source]
|
||||
top = Domain.get_parent_domain(name)
|
||||
if top and top.account != self.account:
|
||||
parent = Domain.get_parent_domain(name)
|
||||
if parent and parent.account != self.account:
|
||||
raise ValidationError(_("Can not create subdomains of other users domains"))
|
||||
return attrs
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class AutoresponseInline(admin.StackedInline):
|
|||
|
||||
class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||
list_display = (
|
||||
'name', 'account_link', 'filtering', 'display_addresses', 'display_active',
|
||||
'name', 'account_link', 'display_filtering', 'display_addresses', 'display_active',
|
||||
)
|
||||
list_filter = (IsActiveListFilter, HasAddressListFilter, 'filtering')
|
||||
search_fields = ('account__username', 'account__short_name', 'account__full_name', 'name')
|
||||
|
@ -75,6 +75,13 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
|
|||
display_addresses.short_description = _("Addresses")
|
||||
display_addresses.allow_tags = True
|
||||
|
||||
def display_filtering(self, mailbox):
|
||||
""" becacuse of allow_tags = True """
|
||||
return mailbox.get_filtering_display()
|
||||
display_filtering.short_description = _("Filtering")
|
||||
display_filtering.admin_order_field = 'filtering'
|
||||
display_filtering.allow_tags = True
|
||||
|
||||
def get_actions(self, request):
|
||||
if settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN:
|
||||
self.actions = (SendMailboxEmail(),)
|
||||
|
|
|
@ -75,13 +75,13 @@ MAILBOXES_MAILBOX_FILTERINGS = Setting('MAILBOXES_MAILBOX_FILTERINGS',
|
|||
{
|
||||
# value: (verbose_name, filter)
|
||||
'DISABLE': (_("Disable"), ''),
|
||||
'REJECT': (mark_safe_lazy(_("Reject spam (X-Spam-Score≥9)")), textwrap.dedent("""
|
||||
'REJECT': (mark_safe_lazy(_("Reject spam (Score≥9)")), textwrap.dedent("""
|
||||
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
||||
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
||||
discard;
|
||||
stop;
|
||||
}""")),
|
||||
'REDIRECT': (mark_safe_lazy(_("Archive spam (X-Spam-Score≥9)")), textwrap.dedent("""
|
||||
'REDIRECT': (mark_safe_lazy(_("Archive spam (Score≥9)")), textwrap.dedent("""
|
||||
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
||||
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
||||
fileinto "Spam";
|
||||
|
|
|
@ -67,7 +67,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
|||
form = WebsiteAdminForm
|
||||
filter_by_account_fields = ['domains']
|
||||
list_prefetch_related = ('domains', 'content_set__webapp')
|
||||
search_fields = ('name', 'account__username', 'domains__name')
|
||||
search_fields = ('name', 'account__username', 'domains__name', 'content__webapp__name')
|
||||
|
||||
def display_domains(self, website):
|
||||
domains = []
|
||||
|
@ -84,7 +84,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
|||
for content in website.content_set.all():
|
||||
webapp = content.webapp
|
||||
url = change_url(webapp)
|
||||
name = "%s on %s" % (webapp.get_type_display(), content.path or '/')
|
||||
name = "%s on %s" % (webapp.name, content.path or '/')
|
||||
webapps.append('<a href="%s">%s</a>' % (url, name))
|
||||
return '<br>'.join(webapps)
|
||||
display_webapps.allow_tags = True
|
||||
|
|
|
@ -44,7 +44,7 @@ def running_syncdb():
|
|||
|
||||
|
||||
def database_ready():
|
||||
return not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv
|
||||
return not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv and 'celerybeat' not in sys.argv
|
||||
|
||||
|
||||
def dict_setting_to_choices(choices):
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
# This script is safe to run several times, for example in order to upgrade your deployment
|
||||
|
||||
set -u
|
||||
set -e
|
||||
set -ue
|
||||
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
|
@ -46,10 +45,18 @@ CURRENT_VERSION=$($PYTHON_BIN -c "from orchestra import get_version; print(get_v
|
|||
if [[ ! $CURRENT_VERSION ]]; then
|
||||
# First Orchestra installation
|
||||
run "apt-get -y install git python3-pip"
|
||||
surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" || surun "export GIT_DIR=~/django-orchestra/.git; git pull"
|
||||
surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" || {
|
||||
# Finishing partial installation
|
||||
surun "export GIT_DIR=~/django-orchestra/.git; git pull"
|
||||
}
|
||||
PYTHON_PATH=$($PYTHON_BIN -c "import sys; print([path for path in sys.path if path.startswith('/usr/local/lib/python')][0]);")
|
||||
echo $HOME/django-orchestra/ | sudo tee "$PYTHON_PATH/orchestra.pth"
|
||||
run "cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/"
|
||||
else
|
||||
# Upgrade and relay on postguprade for finishing up the installation
|
||||
export GIT_DIR=~/django-orchestra/.git; git pull
|
||||
$PYTHON_BIN $MANAGE migrate postupgradeorchestra --from $CURRENT_VERSION
|
||||
exit
|
||||
fi
|
||||
|
||||
sudo orchestra-admin install_requirements --testing
|
||||
|
@ -58,6 +65,8 @@ if [[ ! -e $BASE_DIR ]]; then
|
|||
cd $HOME
|
||||
surun "orchestra-admin startproject $PROJECT_NAME"
|
||||
cd -
|
||||
else
|
||||
echo "$BASE_DIT already existis, doing nothing."
|
||||
fi
|
||||
|
||||
MANAGE="$BASE_DIR/manage.py"
|
||||
|
@ -78,24 +87,23 @@ if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$
|
|||
sudo su postgres -c 'psql -c "ALTER USER orchestra CREATEDB;"'
|
||||
fi
|
||||
|
||||
run "$PYTHON_BIN $MANAGE migrate --noinput auth"
|
||||
# admin_tools needs accounts and does not have migrations
|
||||
run "$PYTHON_BIN $MANAGE migrate --noinput accounts"
|
||||
run "$PYTHON_BIN $MANAGE migrate --noinput"
|
||||
run "$PYTHON_BIN $MANAGE syncdb --noinput"
|
||||
|
||||
sudo $PYTHON_BIN $MANAGE setupcelery --username $USER --processes 2
|
||||
|
||||
# Install and configure Nginx web server
|
||||
# Install and configure Nginx+uwsgi web services
|
||||
surun "mkdir -p $BASE_DIR/static"
|
||||
surun "$PYTHON_BIN $MANAGE collectstatic --noinput"
|
||||
run "apt-get install -y nginx uwsgi uwsgi-plugin-python3"
|
||||
run "$PYTHON_BIN $MANAGE setupnginx"
|
||||
run "service nginx start"
|
||||
|
||||
# Apply changes
|
||||
# Apply changes on related services
|
||||
run "$PYTHON_BIN $MANAGE restartservices"
|
||||
|
||||
# Create a orchestra user
|
||||
# Create orchestra superuser
|
||||
cat <<- EOF | $PYTHON_BIN $MANAGE shell
|
||||
from orchestra.contrib.accounts.models import Account
|
||||
if not Account.objects.filter(username="$USER").exists():
|
||||
|
|
Loading…
Reference in a new issue