Пример #1
0
 def save_to_axilent(self,instance):
     """
     Saves the instance to the appropriate Axilent content type.
     """
     # sanity check
     if not utils.project:
         raise Exception('You must define AXILENT_PROJECT in order to use content mappings.')
     
     binding = None
     app_label = instance._meta.app_label
     model_name = instance.__name__
     client = utils.resource('axilent.airtower','content')
     
     # populate field data
     data = self.on_save({},instance)
     
     try:
         binding = ContentBinding.objects.for_model(instance)
         # this is an update to existing content
         client.put(data={'project':project,
                          'content_type':self.content_type,
                          'key':binding.axilent_content_key,
                          'content':data})
         
     except ContentBinding.DoesNotExist:
         # No binding, content is being inserted into Axilent for the first time
         response = client.post(data={'project':project,
                                      'content_type':self.content_type,
                                      'content':data})
         response_content_type, response_content_key = response['created_content'].split(':')
         ContentBinding.objects.create_for_model(instance,response_content_type,response_content_key)
Пример #2
0
"""
Loads content from Axilent, syncing local models according to thier content mappings.
"""
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from axilent.registry import get_content_mappings
from axilent import utils
from axilent.models import ContentBinding
from django.template.defaultfilters import slugify

resource = utils.resource('axilent.content','content')
client = utils.client('axilent.content')


class Command(BaseCommand):
    """
    Command class.
    """
    
    def handle(self,*args,**kwargs):
        """
        Handler method.
        """
        if len(args):
            self.sync_app(args[0])
        else:
            # sync all the apps
            for app_path in settings.INSTALLED_APPS:
                if app_path != 'axilent' and not app_path.startswith('django'): # don't sync yourself or django contrib apps
                    self.sync_app(app_path)
            
Пример #3
0
"""
Loads content from Axilent, syncing local models according to thier content mappings.
"""
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from axilent.registry import get_content_mappings
from axilent import utils
from axilent.models import ContentBinding
from django.template.defaultfilters import slugify

resource = utils.resource('axilent.content', 'content')
client = utils.client('axilent.content')


class Command(BaseCommand):
    """
    Command class.
    """
    def handle(self, *args, **kwargs):
        """
        Handler method.
        """
        if len(args):
            self.sync_app(args[0])
        else:
            # sync all the apps
            for app_path in settings.INSTALLED_APPS:
                if app_path != 'axilent' and not app_path.startswith(
                        'django'
                ):  # don't sync yourself or django contrib apps
                    self.sync_app(app_path)