remove Person model from sync as it never exist
This commit is contained in:
1 parent
4c0e968e5e
commit
ebd6290ccf
4 files changed
-164
No files matched your search
@@ -41,15 +41,6 @@ database_uri = value('database_uri') # env('MONGO_URI')
|
|||||||
|
|
||||||
skip_unchanged = value('skip_unchanged')
|
skip_unchanged = value('skip_unchanged')
|
||||||
|
|
||||||
person_uri = {
|
|
||||||
'Н.В.Андреева': 'nv-andreeva',
|
|
||||||
'И.Н.Втюрина': 'in-vturina',
|
|
||||||
'О.Д.Гоголева': 'od-gogoleva',
|
|
||||||
'В.А.Саржин': 'va-sarzhin',
|
|
||||||
'Р.К.Тимашев': 'rk-timashev',
|
|
||||||
'А.С.Тимашева': 'as-timasheva',
|
|
||||||
}
|
|
||||||
|
|
||||||
image_processing_enabled = value('image_processing')
|
image_processing_enabled = value('image_processing')
|
||||||
|
|
||||||
album_html_img_class = 'hudozka-product'
|
album_html_img_class = 'hudozka-product'
|
||||||
@@ -104,7 +95,6 @@ collection_images = 'images'
|
|||||||
collection_documents = 'documents'
|
collection_documents = 'documents'
|
||||||
collection_schedules = 'schedules'
|
collection_schedules = 'schedules'
|
||||||
collection_articles = 'articles'
|
collection_articles = 'articles'
|
||||||
collection_collective = 'collective'
|
|
||||||
collection_albums = 'albums'
|
collection_albums = 'albums'
|
||||||
collection_pages = 'pages'
|
collection_pages = 'pages'
|
||||||
|
|
||||||
@@ -113,7 +103,6 @@ hash_salt_pages = '4'
|
|||||||
hash_salt_albums = '1'
|
hash_salt_albums = '1'
|
||||||
hash_salt_documents = '4'
|
hash_salt_documents = '4'
|
||||||
hash_salt_images = '5'
|
hash_salt_images = '5'
|
||||||
hash_salt_person = '4'
|
|
||||||
|
|
||||||
provider_name = value('provider')['name'] # env('SYNC_PROVIDER', 'fs')
|
provider_name = value('provider')['name'] # env('SYNC_PROVIDER', 'fs')
|
||||||
provider_root = value('provider')['root'] # env('SYNC_PROVIDER', 'fs')
|
provider_root = value('provider')['root'] # env('SYNC_PROVIDER', 'fs')
|
||||||
@@ -124,7 +113,6 @@ dir_settings = './Settings'
|
|||||||
dir_documents = './Documents'
|
dir_documents = './Documents'
|
||||||
dir_schedules = './Schedules'
|
dir_schedules = './Schedules'
|
||||||
dir_articles = './Articles'
|
dir_articles = './Articles'
|
||||||
dir_persons = './Collective'
|
|
||||||
dir_albums = './Gallery'
|
dir_albums = './Gallery'
|
||||||
dir_pages = './Pages'
|
dir_pages = './Pages'
|
||||||
dir_images = './Images'
|
dir_images = './Images'
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from sync.models.Image import Image
|
|||||||
from sync.models.Album import Album
|
from sync.models.Album import Album
|
||||||
from sync.models.Article import Article
|
from sync.models.Article import Article
|
||||||
from sync.models.Page import Page
|
from sync.models.Page import Page
|
||||||
from sync.models.Person import Person
|
|
||||||
from sync.models.Schedule import Schedule
|
from sync.models.Schedule import Schedule
|
||||||
from sync.models.Settings import Settings
|
from sync.models.Settings import Settings
|
||||||
|
|
||||||
@@ -58,13 +57,6 @@ async def run(run_interval=0):
|
|||||||
)
|
)
|
||||||
sync_pages.set_options(True, True, True)
|
sync_pages.set_options(True, True, True)
|
||||||
|
|
||||||
sync_persons = Sync(
|
|
||||||
provider=io(settings.provider_root),
|
|
||||||
model=Person,
|
|
||||||
)
|
|
||||||
sync_persons.set_options(True, True, True)
|
|
||||||
sync_persons.validate_urls = False
|
|
||||||
|
|
||||||
sync_articles = Sync(
|
sync_articles = Sync(
|
||||||
provider=io(settings.provider_root),
|
provider=io(settings.provider_root),
|
||||||
model=Article,
|
model=Article,
|
||||||
@@ -105,7 +97,6 @@ async def run(run_interval=0):
|
|||||||
await asyncio.wait([
|
await asyncio.wait([
|
||||||
run_sync(sync_documents),
|
run_sync(sync_documents),
|
||||||
run_sync(sync_pages),
|
run_sync(sync_pages),
|
||||||
run_sync(sync_persons),
|
|
||||||
run_sync(sync_articles),
|
run_sync(sync_articles),
|
||||||
run_sync(sync_schedules),
|
run_sync(sync_schedules),
|
||||||
run_sync(sync_albums),
|
run_sync(sync_albums),
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import settings
|
|
||||||
from db import collection
|
|
||||||
from sync import create_post
|
|
||||||
from sync.data import Provider
|
|
||||||
from sync.models import Model
|
|
||||||
from sync.models.Image import Image
|
|
||||||
|
|
||||||
from utils.fn import swap_ext
|
|
||||||
from utils.hash import hash_str
|
|
||||||
from utils.io import read_yaml_md, parse_yaml_front_matter
|
|
||||||
from utils.text.transform import url_encode_text
|
|
||||||
|
|
||||||
logger = logging.getLogger(settings.name + '.Person')
|
|
||||||
store = collection(settings.collection_collective)
|
|
||||||
|
|
||||||
|
|
||||||
class Person(Model):
|
|
||||||
@staticmethod
|
|
||||||
async def find(query):
|
|
||||||
return store.find(query)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
async def delete(query):
|
|
||||||
return store.find_one_and_delete(query)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
async def scan(provider):
|
|
||||||
scan_dir = settings.dir_persons
|
|
||||||
documents = provider.type_filter(scan_dir, '.md')
|
|
||||||
documents = [Person.read(provider, i) for i in documents]
|
|
||||||
return documents
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def read(provider, path):
|
|
||||||
params = get_manifest(provider, path)
|
|
||||||
|
|
||||||
return Person(
|
|
||||||
provider,
|
|
||||||
path,
|
|
||||||
params=params,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, provider, file, params=None):
|
|
||||||
self.__hash_salt = settings.hash_salt_person
|
|
||||||
self.__hash_keys = ['id', 'url']
|
|
||||||
|
|
||||||
self.__id_template: str = '{category}-{file}'
|
|
||||||
self.__url_template: str = settings.document_url_template
|
|
||||||
self.__url_preview_template: str = settings.document_url_preview_template
|
|
||||||
|
|
||||||
self.picture = None
|
|
||||||
self.preview = None
|
|
||||||
self.post = None
|
|
||||||
self.images = None
|
|
||||||
self.documents = None
|
|
||||||
|
|
||||||
super().__init__(provider, store, file, params)
|
|
||||||
|
|
||||||
def init(self):
|
|
||||||
pass
|
|
||||||
self.__set_id()
|
|
||||||
self.__set_hash()
|
|
||||||
|
|
||||||
async def build(self, **kwargs):
|
|
||||||
sizes = kwargs['sizes']
|
|
||||||
image_path = self._get_relpath(self.get_param('picture'))
|
|
||||||
|
|
||||||
self.picture = await Image.new(self.provider, image_path, sizes)
|
|
||||||
|
|
||||||
markdown_post = self.get_param('content')
|
|
||||||
post, images, documents = await create_post(self.provider, self.get_param('folder'), markdown_post, sizes)
|
|
||||||
self.post = post
|
|
||||||
self.images = images
|
|
||||||
self.documents = documents
|
|
||||||
|
|
||||||
if self.has_param('preview'):
|
|
||||||
preview = self.get_param('preview')
|
|
||||||
preview = self._get_relpath(preview)
|
|
||||||
self.preview = await Image.new(self.provider, preview, sizes)
|
|
||||||
|
|
||||||
def bake(self):
|
|
||||||
return {
|
|
||||||
**self.params,
|
|
||||||
'post': self.post,
|
|
||||||
'images': [x.ref for x in self.images],
|
|
||||||
'documents': [x.ref for x in self.documents],
|
|
||||||
'id': self.id,
|
|
||||||
'hash': self.hash,
|
|
||||||
'file': self.file,
|
|
||||||
'picture': self.picture.ref,
|
|
||||||
'preview': self.preview.ref if self.preview else None,
|
|
||||||
}
|
|
||||||
|
|
||||||
def __set_id(self):
|
|
||||||
if 'id' in self.params:
|
|
||||||
self.id = self.params['id']
|
|
||||||
else:
|
|
||||||
self.id = url_encode_text(self.params['name'])
|
|
||||||
|
|
||||||
def __set_hash(self):
|
|
||||||
files = [self.file]
|
|
||||||
files.append(self._get_relpath(self.get_param('picture')))
|
|
||||||
|
|
||||||
if self.has_param('preview'):
|
|
||||||
files.append(self._get_relpath(self.get_param('preview')))
|
|
||||||
|
|
||||||
hashes = [self.provider.hash(x) for x in files]
|
|
||||||
self.hash = hash_str(
|
|
||||||
self.__hash_salt + ''.join(hashes)
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f'<Person file={self.file} id={self.id}>'
|
|
||||||
|
|
||||||
|
|
||||||
def get_manifest(provider: Provider, path: str) -> dict:
|
|
||||||
data = provider.read(path).read().decode('utf-8')
|
|
||||||
|
|
||||||
manifest = parse_yaml_front_matter(data)
|
|
||||||
return {
|
|
||||||
**manifest,
|
|
||||||
'picture': manifest['picture'] if 'picture' in manifest else os.path.basename(swap_ext('.jpg')(path)),
|
|
||||||
'preview': manifest['preview'] if 'preview' in manifest else os.path.basename(swap_ext('.jpg')(path)),
|
|
||||||
'folder': os.path.dirname(path),
|
|
||||||
'hidden': manifest['hidden'] if 'hidden' in manifest else False,
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import settings
|
import settings
|
||||||
from db import collection
|
from db import collection
|
||||||
from sync.core.person import SyncPerson
|
|
||||||
from utils.text.transform import interpolate_swift
|
from utils.text.transform import interpolate_swift
|
||||||
|
|
||||||
|
|
||||||
@@ -15,14 +14,6 @@ def resolve_value(param, store):
|
|||||||
return store(i)
|
return store(i)
|
||||||
|
|
||||||
|
|
||||||
def resolve_teacher(i):
|
|
||||||
sync = SyncPerson(
|
|
||||||
collection(settings.collection_collective),
|
|
||||||
None,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
return resolve_value(i, lambda teacher_id: sync.read({'id': teacher_id}))
|
|
||||||
|
|
||||||
|
|
||||||
def create_product(doc):
|
def create_product(doc):
|
||||||
# author, image, title, awards, teacher, date
|
# author, image, title, awards, teacher, date
|
||||||
@@ -33,8 +24,4 @@ def create_product(doc):
|
|||||||
product = {**doc}
|
product = {**doc}
|
||||||
# unpop_image(product)
|
# unpop_image(product)
|
||||||
|
|
||||||
# product['teacher'] = resolve_teacher(doc['teacher'])
|
|
||||||
# if (product['teacher']):
|
|
||||||
# unpop_teacher(product)
|
|
||||||
|
|
||||||
return product
|
return product
|
||||||
Reference in new issue
Block a user