P5-3538 do not create eSales importfile after saving a category
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# coding=UTF-8
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.slugify import slugify
|
||||
from api.models.locale import Locale
|
||||
|
||||
|
||||
@@ -13,16 +12,6 @@ class Category(db.Model):
|
||||
texts = db.relationship(
|
||||
'CategoryTexts', backref='category', lazy='dynamic')
|
||||
|
||||
def path(self, locale='sv_SE'):
|
||||
row = CategoryTreeI18n.query.filter_by(
|
||||
category_id=self.id, locale=locale).first()
|
||||
if not row:
|
||||
raise Exception(
|
||||
'Could not find a path for category: {}, locale: {}'.format(self.id, locale))
|
||||
path = row.path.split('/', 1)[-1] # get all text after the first /
|
||||
path = slugify(path)
|
||||
return path
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
@@ -62,13 +51,3 @@ class CategoryTexts(db.Model):
|
||||
'design_wallpaper_h1': self.design_wallpaper_h1,
|
||||
'design_wallpaper_description': self.design_wallpaper_description,
|
||||
}
|
||||
|
||||
|
||||
class CategoryTreeI18n(db.Model):
|
||||
__tablename__ = 'v_categorytree_i18n'
|
||||
|
||||
category_id = db.Column('id', db.Integer)
|
||||
path = db.Column(db.String(250))
|
||||
locale = db.Column(db.String(250))
|
||||
|
||||
__table_args__ = (db.PrimaryKeyConstraint(category_id, locale),)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from api import db, tasks
|
||||
from api import db
|
||||
from api.models import Category
|
||||
from api.helpers import pagination_to_dict, check_api_key
|
||||
|
||||
@@ -35,5 +35,4 @@ def update(id):
|
||||
setattr(category, k, v)
|
||||
db.session.add(category)
|
||||
db.session.commit()
|
||||
tasks.esales.update_category(category)
|
||||
return jsonify(category.to_json())
|
||||
|
||||
@@ -27,24 +27,3 @@ def update_designer(designer):
|
||||
|
||||
directory = current_app.config.get("ESALES_IMPORT_DIR")
|
||||
importfile.write(directory)
|
||||
|
||||
|
||||
def update_category(category):
|
||||
importfile = ImportFile()
|
||||
for text in category.texts:
|
||||
locale = text.locale
|
||||
tree = CategoryTree("categories_{}".format(locale.value))
|
||||
tree.add_category(Category(
|
||||
key='root/{}'.format(category.path(locale.value)),
|
||||
display_name=category.name,
|
||||
wallpaper_description=text.wallpaper_description,
|
||||
wallpaper_h1=text.wallpaper_h1,
|
||||
canvas_description=text.canvas_description,
|
||||
canvas_h1=text.canvas_h1,
|
||||
design_wallpaper_description=text.design_wallpaper_description,
|
||||
design_wallpaper_h1=text.design_wallpaper_h1
|
||||
))
|
||||
importfile.add_operation("update", tree)
|
||||
|
||||
directory = current_app.config.get("ESALES_IMPORT_DIR")
|
||||
importfile.write(directory)
|
||||
|
||||
Reference in New Issue
Block a user