From 83831edf0b420d0c0864ff201b2eae6e1c73fac7 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Thu, 30 Apr 2015 09:51:55 +0000 Subject: [PATCH] Added ID to serializers --- README.md | 3 +-- orchestra/conf/base_settings.py | 1 + orchestra/contrib/accounts/serializers.py | 2 +- orchestra/contrib/bills/serializers.py | 2 +- orchestra/contrib/contacts/serializers.py | 2 +- orchestra/contrib/databases/serializers.py | 8 ++++---- orchestra/contrib/domains/serializers.py | 2 +- orchestra/contrib/issues/serializers.py | 4 ++-- orchestra/contrib/lists/serializers.py | 4 ++-- orchestra/contrib/mailboxes/serializers.py | 10 +++++----- orchestra/contrib/orders/serializers.py | 2 +- orchestra/contrib/payments/serializers.py | 2 +- orchestra/contrib/saas/serializers.py | 2 +- orchestra/contrib/systemusers/serializers.py | 4 ++-- orchestra/contrib/webapps/serializers.py | 2 +- orchestra/contrib/websites/serializers.py | 6 +++--- orchestra/management/commands/postupgradeorchestra.py | 2 +- orchestra/utils/options.py | 7 ++++++- scripts/container/deploy.sh | 2 ++ 19 files changed, 37 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index dea9e3f2..ac162b6e 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,8 @@ If you are planing to do some development or perhaps just checking out this proj sshfs orchestra@: ~/orchestra ``` -5. To upgrade to current master just +5. To upgrade to current master just re-run the deploy script ```bash - cd ~orchestra/django-orchestra/ sudo ~orchestra/django-orchestra/scripts/container/deploy.sh ``` diff --git a/orchestra/conf/base_settings.py b/orchestra/conf/base_settings.py index 17ad8178..3d085706 100644 --- a/orchestra/conf/base_settings.py +++ b/orchestra/conf/base_settings.py @@ -89,6 +89,7 @@ INSTALLED_APPS = ( 'orchestra.contrib.miscellaneous', 'orchestra.contrib.bills', 'orchestra.contrib.payments', + 'orchestra.contrib.tasks', # Third-party apps 'django_extensions', diff --git a/orchestra/contrib/accounts/serializers.py b/orchestra/contrib/accounts/serializers.py index 3b95a59d..0579d9e0 100644 --- a/orchestra/contrib/accounts/serializers.py +++ b/orchestra/contrib/accounts/serializers.py @@ -7,7 +7,7 @@ class AccountSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Account fields = ( - 'url', 'username', 'type', 'language', 'short_name', 'full_name', 'date_joined', + 'url', 'id', 'username', 'type', 'language', 'short_name', 'full_name', 'date_joined', 'is_active' ) diff --git a/orchestra/contrib/bills/serializers.py b/orchestra/contrib/bills/serializers.py index b74d8f2e..f73380b3 100644 --- a/orchestra/contrib/bills/serializers.py +++ b/orchestra/contrib/bills/serializers.py @@ -19,7 +19,7 @@ class BillSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSeriali class Meta: model = Bill fields = ( - 'url', 'number', 'type', 'total', 'is_sent', 'created_on', 'due_on', + 'url', 'id', 'number', 'type', 'total', 'is_sent', 'created_on', 'due_on', 'comments', # 'lines' ) diff --git a/orchestra/contrib/contacts/serializers.py b/orchestra/contrib/contacts/serializers.py index cd478a6d..54538ccd 100644 --- a/orchestra/contrib/contacts/serializers.py +++ b/orchestra/contrib/contacts/serializers.py @@ -12,6 +12,6 @@ class ContactSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSeri class Meta: model = Contact fields = ( - 'url', 'short_name', 'full_name', 'email', 'email_usage', 'phone', + 'url', 'id', 'short_name', 'full_name', 'email', 'email_usage', 'phone', 'phone2', 'address', 'city', 'zipcode', 'country' ) diff --git a/orchestra/contrib/databases/serializers.py b/orchestra/contrib/databases/serializers.py index fbc9ede6..2c653704 100644 --- a/orchestra/contrib/databases/serializers.py +++ b/orchestra/contrib/databases/serializers.py @@ -12,7 +12,7 @@ from .models import Database, DatabaseUser class RelatedDatabaseUserSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = DatabaseUser - fields = ('url', 'username') + fields = ('url', 'id', 'username') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -24,7 +24,7 @@ class DatabaseSerializer(AccountSerializerMixin, HyperlinkedModelSerializer): class Meta: model = Database - fields = ('url', 'name', 'type', 'users') + fields = ('url', 'id', 'name', 'type', 'users') postonly_fields = ('name', 'type') def validate(self, attrs): @@ -38,7 +38,7 @@ class DatabaseSerializer(AccountSerializerMixin, HyperlinkedModelSerializer): class RelatedDatabaseSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Database - fields = ('url', 'name',) + fields = ('url', 'id', 'name',) def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -50,7 +50,7 @@ class DatabaseUserSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSeria class Meta: model = DatabaseUser - fields = ('url', 'username', 'password', 'type', 'databases') + fields = ('url', 'id', 'username', 'password', 'type', 'databases') postonly_fields = ('username', 'type', 'password') def validate(self, attrs): diff --git a/orchestra/contrib/domains/serializers.py b/orchestra/contrib/domains/serializers.py index 0853d045..b0a87f0f 100644 --- a/orchestra/contrib/domains/serializers.py +++ b/orchestra/contrib/domains/serializers.py @@ -25,7 +25,7 @@ class DomainSerializer(AccountSerializerMixin, HyperlinkedModelSerializer): class Meta: model = Domain - fields = ('url', 'name', 'records') + fields = ('url', 'id', 'name', 'records') postonly_fields = ('name',) def clean_name(self, attrs, source): diff --git a/orchestra/contrib/issues/serializers.py b/orchestra/contrib/issues/serializers.py index 1518c504..cc578a4d 100644 --- a/orchestra/contrib/issues/serializers.py +++ b/orchestra/contrib/issues/serializers.py @@ -6,14 +6,14 @@ from .models import Ticket, Message, Queue class QueueSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Queue - fields = ('url', 'name', 'default', 'notify') + fields = ('url', 'id', 'name', 'default', 'notify') read_only_fields = ('name', 'default', 'notify') class MessageSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Message - fields = ('id', 'author', 'author_name', 'content', 'created_on') + fields = ('url', 'id', 'author', 'author_name', 'content', 'created_on') read_only_fields = ('author', 'author_name', 'created_on') def get_identity(self, data): diff --git a/orchestra/contrib/lists/serializers.py b/orchestra/contrib/lists/serializers.py index bbd5781d..b3624e87 100644 --- a/orchestra/contrib/lists/serializers.py +++ b/orchestra/contrib/lists/serializers.py @@ -14,7 +14,7 @@ from .models import List class RelatedDomainSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = List.address_domain.field.rel.to - fields = ('url', 'name') + fields = ('url', 'id', 'name') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -36,7 +36,7 @@ class ListSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSerializer): class Meta: model = List - fields = ('url', 'name', 'password', 'address_name', 'address_domain', 'admin_email') + fields = ('url', 'id', 'name', 'password', 'address_name', 'address_domain', 'admin_email') postonly_fields = ('name', 'password') def validate_address_domain(self, attrs, source): diff --git a/orchestra/contrib/mailboxes/serializers.py b/orchestra/contrib/mailboxes/serializers.py index c7ab4c17..cc834981 100644 --- a/orchestra/contrib/mailboxes/serializers.py +++ b/orchestra/contrib/mailboxes/serializers.py @@ -12,7 +12,7 @@ from .models import Mailbox, Address class RelatedDomainSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Address.domain.field.rel.to - fields = ('url', 'name') + fields = ('url', 'id', 'name') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -24,7 +24,7 @@ class RelatedAddressSerializer(AccountSerializerMixin, serializers.HyperlinkedMo class Meta: model = Address - fields = ('url', 'name', 'domain', 'forward') + fields = ('url', 'id', 'name', 'domain', 'forward') # # def from_native(self, data, files=None): # queryset = self.opts.model.objects.filter(account=self.account) @@ -37,7 +37,7 @@ class MailboxSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSerializer class Meta: model = Mailbox fields = ( - 'url', 'name', 'password', 'filtering', 'custom_filtering', 'addresses', 'is_active' + 'url', 'id', 'name', 'password', 'filtering', 'custom_filtering', 'addresses', 'is_active' ) postonly_fields = ('name', 'password') @@ -45,7 +45,7 @@ class MailboxSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSerializer class RelatedMailboxSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Mailbox - fields = ('url', 'name') + fields = ('url', 'id', 'name') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -58,7 +58,7 @@ class AddressSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSeri class Meta: model = Address - fields = ('url', 'name', 'domain', 'mailboxes', 'forward') + fields = ('url', 'id', 'name', 'domain', 'mailboxes', 'forward') def validate(self, attrs): attrs = super(AddressSerializer, self).validate(attrs) diff --git a/orchestra/contrib/orders/serializers.py b/orchestra/contrib/orders/serializers.py index a98e367b..ea30240d 100644 --- a/orchestra/contrib/orders/serializers.py +++ b/orchestra/contrib/orders/serializers.py @@ -9,6 +9,6 @@ class OrderSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerial class Meta: model = Order fields = ( - 'url', 'registered_on', 'cancelled_on', 'billed_on', 'billed_until', + 'url', 'id', 'registered_on', 'cancelled_on', 'billed_on', 'billed_until', 'description' ) diff --git a/orchestra/contrib/payments/serializers.py b/orchestra/contrib/payments/serializers.py index 7287cd78..b026e6c2 100644 --- a/orchestra/contrib/payments/serializers.py +++ b/orchestra/contrib/payments/serializers.py @@ -9,7 +9,7 @@ from .models import PaymentSource, Transaction class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = PaymentSource - fields = ('url', 'method', 'data', 'is_active') + fields = ('url', 'id', 'method', 'data', 'is_active') def validate_data(self, attrs, source): plugin = PaymentMethod.get(attrs['method']) diff --git a/orchestra/contrib/saas/serializers.py b/orchestra/contrib/saas/serializers.py index 06887ab1..c5c787de 100644 --- a/orchestra/contrib/saas/serializers.py +++ b/orchestra/contrib/saas/serializers.py @@ -25,5 +25,5 @@ class SaaSSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSerializer): class Meta: model = SaaS - fields = ('url', 'name', 'service', 'is_active', 'data', 'password') + fields = ('url', 'id', 'name', 'service', 'is_active', 'data', 'password') postonly_fields = ('name', 'service', 'password') diff --git a/orchestra/contrib/systemusers/serializers.py b/orchestra/contrib/systemusers/serializers.py index f6f54b66..25282d3e 100644 --- a/orchestra/contrib/systemusers/serializers.py +++ b/orchestra/contrib/systemusers/serializers.py @@ -13,7 +13,7 @@ from .validators import validate_home class GroupSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = SystemUser - fields = ('url', 'username',) + fields = ('url', 'id', 'username',) def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -26,7 +26,7 @@ class SystemUserSerializer(AccountSerializerMixin, SetPasswordHyperlinkedSeriali class Meta: model = SystemUser fields = ( - 'url', 'username', 'password', 'home', 'directory', 'shell', 'groups', 'is_active', + 'url', 'id', 'username', 'password', 'home', 'directory', 'shell', 'groups', 'is_active', ) postonly_fields = ('username', 'password') diff --git a/orchestra/contrib/webapps/serializers.py b/orchestra/contrib/webapps/serializers.py index db289338..e73d14fa 100644 --- a/orchestra/contrib/webapps/serializers.py +++ b/orchestra/contrib/webapps/serializers.py @@ -23,7 +23,7 @@ class WebAppSerializer(AccountSerializerMixin, HyperlinkedModelSerializer): class Meta: model = WebApp - fields = ('url', 'name', 'type', 'options') + fields = ('url', 'id', 'name', 'type', 'options') postonly_fields = ('name', 'type') def create(self, validated_data): diff --git a/orchestra/contrib/websites/serializers.py b/orchestra/contrib/websites/serializers.py index 80f09d1b..5620ce9f 100644 --- a/orchestra/contrib/websites/serializers.py +++ b/orchestra/contrib/websites/serializers.py @@ -12,7 +12,7 @@ from .validators import validate_domain_protocol class RelatedDomainSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Website.domains.field.rel.to - fields = ('url', 'name') + fields = ('url', 'id', 'name') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -22,7 +22,7 @@ class RelatedDomainSerializer(AccountSerializerMixin, serializers.HyperlinkedMod class RelatedWebAppSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Content.webapp.field.rel.to - fields = ('url', 'name', 'type') + fields = ('url', 'id', 'name', 'type') def from_native(self, data, files=None): queryset = self.opts.model.objects.filter(account=self.account) @@ -60,7 +60,7 @@ class WebsiteSerializer(AccountSerializerMixin, HyperlinkedModelSerializer): class Meta: model = Website - fields = ('url', 'name', 'protocol', 'domains', 'is_active', 'contents', 'directives') + fields = ('url', 'id', 'name', 'protocol', 'domains', 'is_active', 'contents', 'directives') postonly_fileds = ('name',) def full_clean(self, instance): diff --git a/orchestra/management/commands/postupgradeorchestra.py b/orchestra/management/commands/postupgradeorchestra.py index 1bade75c..d769d495 100644 --- a/orchestra/management/commands/postupgradeorchestra.py +++ b/orchestra/management/commands/postupgradeorchestra.py @@ -68,7 +68,7 @@ class Command(BaseCommand): manage_path = os.path.join(get_site_dir(), 'manage.py') run("python %s collectstatic --noinput" % manage_path) - run("python %s syncdb --noinput" % manage_path) + run("python %s migrate --noinput accounts" % manage_path) run("python %s migrate --noinput" % manage_path) if options.get('restart'): run("python %s restartservices" % manage_path) diff --git a/orchestra/utils/options.py b/orchestra/utils/options.py index 121d277e..7d58de9b 100644 --- a/orchestra/utils/options.py +++ b/orchestra/utils/options.py @@ -44,7 +44,12 @@ def running_syncdb(): def database_ready(): - return not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv and 'celerybeat' 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 and + len(sys.argv) <= 1 and + '--help' in sys.argv) def dict_setting_to_choices(choices): diff --git a/scripts/container/deploy.sh b/scripts/container/deploy.sh index 6aa94d16..0dcae250 100755 --- a/scripts/container/deploy.sh +++ b/scripts/container/deploy.sh @@ -55,6 +55,8 @@ if [[ ! $CURRENT_VERSION ]]; then else # Upgrade and relay on postguprade for finishing up the installation surun "export GIT_DIR=~/django-orchestra/.git && git checkout master && git pull origin" + # TODO pass testing to postupgrade instead of running his here + sudo orchestra-admin install_requirements --testing $PYTHON_BIN $MANAGE migrate postupgradeorchestra --from $CURRENT_VERSION exit fi