Exemplo n.º 1
0
    def _get_or_create_section(self, name, parent):
        if name in self.data['section_by_name']:
            return self.data['section_by_name'][name].tree.get()
        else:
            section = Section(name=name, slug=urlify(name))
            section.save()

            section_tree_item = TreeItem(parent=parent, content_object=section)
            section_tree_item.save()

            self.data['section_by_name'].update({section.name: section})

            logging.debug('[S] === %s ===' % section)
            return section_tree_item
Exemplo n.º 2
0
def import_section(name, path):
    with open(os.path.join(path, name, 'data'), 'rb') as f:
        data = pickle.load(f)

        s = Section()
        copy_seo_data(s, data)

        if data.title_color == 'black':
            s.title_color = '#000000'
        else:
            s.title_color = '#ffffff'

        translation.activate('en')
        s.title = data.title_en
        translation.deactivate()

        translation.activate('fr')
        s.title = data.title_fr
        translation.deactivate()

        if hasattr(data, 'background'):
            img = make_master_image(
                path,
                data.background,
                '{}-background'.format(data.title_en)
            )
            s.background = img

        s.save()
Exemplo n.º 3
0
    def _get_or_create_section(self, name, parent):
        if name in self.data['section_by_name']:
            return self.data['section_by_name'][name].tree.get()
        else:
            section = Section(
                name=name, slug = urlify(name)
            )
            section.save()

            section_tree_item  = TreeItem(parent=parent, content_object=section)
            section_tree_item.save()

            self.data['section_by_name'].update({section.name: section})
            
            logging.debug('[S] === %s ===' % section)
            return section_tree_item
Exemplo n.º 4
0
    def create_item(self, item_params):
        try:
            target_tree_item = TreeItem.objects.get(name=u'Импорт')
        except TreeItem.DoesNotExist:
            target_tree_item = TreeItem(parent_id=None, name=u'Импорт')
            target_tree_item.save()
            target_section = Section(is_meta_item=False)
            target_section.save()
            target_tree_item.section = target_section
            target_tree_item.save()

        new_tree_item = TreeItem(name=item_params['name'][:200],
                                 parent=target_tree_item)
        new_item = Item(
            price=item_params['price'],
            identifier=item_params['identifier'],
            quantity=item_params['quantity'],
        )
        new_tree_item.save()
        new_item.save()
        new_tree_item.item = new_item
        new_tree_item.save()
Exemplo n.º 5
0
 def create_item(self, item_params):
     try:
         target_tree_item = TreeItem.objects.get(name=u'Импорт')
     except TreeItem.DoesNotExist:
         target_tree_item = TreeItem(parent_id=None, name=u'Импорт')
         target_tree_item.save()
         target_section = Section(is_meta_item=False)
         target_section.save()
         target_tree_item.section = target_section
         target_tree_item.save()
         
     new_tree_item = TreeItem(name = item_params['name'][:200],
         parent=target_tree_item)
     new_item = Item(
         price = item_params['price'],
         identifier = item_params['identifier'],
         quantity = item_params['quantity'],
     )
     new_tree_item.save()
     new_item.save()
     new_tree_item.item = new_item
     new_tree_item.save()