Cleanup admin.py
diff --git a/xos/helloworldservice/admin.py b/xos/helloworldservice/admin.py
index b77cc40..fffaae2 100644
--- a/xos/helloworldservice/admin.py
+++ b/xos/helloworldservice/admin.py
@@ -1,22 +1,9 @@
from django.contrib import admin
-from helloworldservice.models import *
+from helloworldservice.models import HelloWorldService, HelloWorldTenant
from django import forms
-from django.utils.safestring import mark_safe
-from django.contrib.auth.admin import UserAdmin
-from django.contrib.admin.widgets import FilteredSelectMultiple
-from django.contrib.auth.forms import ReadOnlyPasswordHashField
-from django.contrib.auth.signals import user_logged_in
-from django.utils import timezone
-from django.contrib.contenttypes import generic
-from suit.widgets import LinkedSelect
-from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
-from core.middleware import get_request
from core.models import User
-from functools import update_wrapper
-from django.contrib.admin.views.main import ChangeList
-from django.core.urlresolvers import reverse
-from django.contrib.admin.utils import quote
+from core.admin import SliceInline, ServiceAttrAsTabInline, ReadOnlyAwareAdmin, ServicePrivilegeInline
class HelloWorldServiceAdmin(ReadOnlyAwareAdmin):
model = HelloWorldService
@@ -26,7 +13,7 @@
list_display_links = ('backend_status_icon', 'name', )
fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', )
- inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
+ inlines = [SliceInline, ServiceAttrAsTabInline, ServicePrivilegeInline]
extracontext_registered_admins = True
diff --git a/xos/helloworldservice/models.py b/xos/helloworldservice/models.py
index 2ca7f00..3cace69 100644
--- a/xos/helloworldservice/models.py
+++ b/xos/helloworldservice/models.py
@@ -17,7 +17,12 @@
KIND = HELLO_WORLD_KIND
default_attributes = {'display_message': 'Hello World!'}
def __init__(self, *args, **kwargs):
- super(HelloWorldTenant, self).__init__(*args, **kwargs)
+ helloworld_services = HelloWorldService.get_service_objects().all();
+ if helloworld_services:
+ self._meta.get_field("provider_service").default = helloworld_services[0].id
+
+ self.instance = (helloworld_services[0].slices.all()[0].instances.all()[0])
+ super(HelloWorldTenant, self).__init__(*args, **kwargs)
def save(self, *args, **kwargs):
super(HelloWorldTenant, self).save(*args, **kwargs)
diff --git a/xos/observers/helloworldservice/steps/sync_helloworldtenant.py b/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
index c117ccd..9adddd2 100644
--- a/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
+++ b/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
@@ -19,9 +19,21 @@
requested_interval=0
template_name = "sync_helloworldtenant.yaml"
service_key_name = "/opt/xos/observers/helloworldservice/helloworldservice_private_key"
+
+ def __init__(self, *args, **kwargs):
+ super(SyncHelloWorldServiceTenant, self).__init__(*args, **kwargs)
+
+ def fetch_pending(self, deleted):
+ if (not deleted):
+ objs = HelloWorldTenant.get_tenant_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
+ else:
+ objs = HelloWorldTenant.get_deleted_tenant_objects()
+
+ return objs
def get_extra_attributes(self, o):
+ self.get_instance(o)
return {"display_message": o.display_message}
def delete_record(self, m):
- return
+ pass