PR fixes
This commit is contained in:
parent
7bcefeb347
commit
1be947e946
13 changed files with 175 additions and 206 deletions
|
@ -1,7 +1,6 @@
|
|||
<div class='pool-input'>
|
||||
<div class='main-control'>
|
||||
<input type='text' placeholder='type to add…'/>
|
||||
<!-- <button>Add</button> -->
|
||||
</div>
|
||||
|
||||
<ul class='compact-pools'></ul>
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
<section>
|
||||
Aliases:<br/>
|
||||
<ul><!--
|
||||
--><% for (let name of ctx.pool.names.slice(1)) { %><!--
|
||||
--><li><%= ctx.makePoolLink(ctx.pool.id, false, false, ctx.pool, name) %></li><!--
|
||||
--><% } %><!--
|
||||
--></ul>
|
||||
<ul>
|
||||
<% for (let name of ctx.pool.names.slice(1)) { %>
|
||||
<li><%= ctx.makePoolLink(ctx.pool.id, false, false, ctx.pool, name) %></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ class PoolController {
|
|||
this._view.addEventListener('submit', e => this._evtUpdate(e));
|
||||
this._view.addEventListener('merge', e => this._evtMerge(e));
|
||||
this._view.addEventListener('delete', e => this._evtDelete(e));
|
||||
},
|
||||
error => {
|
||||
}, error => {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError(error.message);
|
||||
});
|
||||
|
@ -68,9 +67,7 @@ class PoolController {
|
|||
_evtSaved(e, section) {
|
||||
misc.disableExitConfirmation();
|
||||
if (this._name !== e.detail.pool.names[0]) {
|
||||
router.replace(
|
||||
uri.formatClientLink('pool', e.detail.pool.id, section),
|
||||
null, false);
|
||||
router.replace(uri.formatClientLink('pool', e.detail.pool.id, section), null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,9 +84,9 @@ class PoolController {
|
|||
e.detail.pool.description = e.detail.description;
|
||||
}
|
||||
if (e.detail.posts !== undefined) {
|
||||
e.detail.pool.posts.clear()
|
||||
e.detail.pool.posts.clear();
|
||||
for (let post_id of e.detail.posts) {
|
||||
e.detail.pool.posts.add(Post.fromResponse({ id: parseInt(post_id) }))
|
||||
e.detail.pool.posts.add(Post.fromResponse({ id: parseInt(post_id) }));
|
||||
}
|
||||
}
|
||||
e.detail.pool.save().then(() => {
|
||||
|
|
|
@ -16,8 +16,7 @@ class PoolCreateController {
|
|||
return;
|
||||
}
|
||||
|
||||
PoolCategoryList.get()
|
||||
.then(poolCategoriesResponse => {
|
||||
PoolCategoryList.get().then(poolCategoriesResponse => {
|
||||
const categories = {};
|
||||
for (let category of poolCategoriesResponse.results) {
|
||||
categories[category.name] = category.name;
|
||||
|
|
|
@ -3,7 +3,6 @@ script_location = szurubooru/migrations
|
|||
|
||||
# overriden by szurubooru's config
|
||||
sqlalchemy.url =
|
||||
revision_environment = true
|
||||
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# shown in the website title and on the front page
|
||||
name: szurubooru
|
||||
# full url to the homepage of this szurubooru site, with no trailing slash
|
||||
domain: localhost # example: http://example.com
|
||||
domain: # example: http://example.com
|
||||
# used to salt the users' password hashes and generate filenames for static content
|
||||
secret: change
|
||||
|
||||
|
@ -49,9 +49,6 @@ enable_safety: yes
|
|||
tag_name_regex: ^\S+$
|
||||
tag_category_name_regex: ^[^\s%+#/]+$
|
||||
|
||||
pool_name_regex: ^\S+$
|
||||
pool_category_name_regex: ^[^\s%+#/]+$
|
||||
|
||||
# don't make these more restrictive unless you want to annoy people; if you do
|
||||
# customize them, make sure to update the instructions in the registration form
|
||||
# template as well.
|
||||
|
|
|
@ -9,4 +9,3 @@ pillow>=4.3.0
|
|||
pynacl>=1.2.1
|
||||
pytz>=2018.3
|
||||
pyRFC3339>=1.0
|
||||
youtube_dl>=2020.5.3
|
||||
|
|
|
@ -34,22 +34,3 @@ def _bump_query_count() -> None:
|
|||
|
||||
|
||||
sa.event.listen(_engine, 'after_execute', lambda *args: _bump_query_count())
|
||||
|
||||
import time
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("myapp.sqltime")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
def before_cursor_execute(conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
conn.info.setdefault('query_start_time', []).append(time.time())
|
||||
logger.info("Start Query: %s" % statement)
|
||||
|
||||
def after_cursor_execute(conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
total = time.time() - conn.info['query_start_time'].pop(-1)
|
||||
logger.info("Total Time: %f" % total)
|
||||
|
||||
sa.event.listen(_engine, "before_cursor_execute", before_cursor_execute)
|
||||
sa.event.listen(_engine, "after_cursor_execute", after_cursor_execute)
|
||||
|
|
|
@ -195,5 +195,5 @@ def delete_category(category: model.PoolCategory) -> None:
|
|||
if (category.pool_count or 0) > 0:
|
||||
raise PoolCategoryIsInUseError(
|
||||
'Pool category has some usages and cannot be deleted. ' +
|
||||
'Please remove this category from relevant pools first..')
|
||||
'Please remove this category from relevant pools first.')
|
||||
db.session.delete(category)
|
||||
|
|
|
@ -77,6 +77,7 @@ def _duplicates(a: List[int]) -> List[int]:
|
|||
dupes.append(x)
|
||||
return dupes
|
||||
|
||||
|
||||
def sort_pools(pools: List[model.Pool]) -> List[model.Pool]:
|
||||
default_category_name = pool_categories.get_default_category_name()
|
||||
return sorted(
|
||||
|
@ -131,8 +132,7 @@ class PoolSerializer(serialization.BaseSerializer):
|
|||
|
||||
def serialize_posts(self) -> Any:
|
||||
return [post for post in
|
||||
[posts.serialize_micro_post(rel, None)
|
||||
for rel in self.pool.posts]]
|
||||
[posts.serialize_micro_post(rel, None) for rel in self.pool.posts]]
|
||||
|
||||
|
||||
def serialize_pool(
|
||||
|
@ -221,7 +221,7 @@ def merge_pools(source_pool: model.Pool, target_pool: model.Pool) -> None:
|
|||
if source_pool.pool_id == target_pool.pool_id:
|
||||
raise InvalidPoolRelationError('Cannot merge pool with itself.')
|
||||
|
||||
def merge_posts(source_pool_id: int, target_pool_id: int) -> None:
|
||||
def merge_pool_posts(source_pool_id: int, target_pool_id: int) -> None:
|
||||
alias1 = model.PoolPost
|
||||
alias2 = sa.orm.util.aliased(model.PoolPost)
|
||||
update_stmt = (
|
||||
|
@ -236,7 +236,7 @@ def merge_pools(source_pool: model.Pool, target_pool: model.Pool) -> None:
|
|||
update_stmt = update_stmt.values(pool_id=target_pool_id)
|
||||
db.session.execute(update_stmt)
|
||||
|
||||
merge_posts(source_pool.pool_id, target_pool.pool_id)
|
||||
merge_pool_posts(source_pool.pool_id, target_pool.pool_id)
|
||||
delete(source_pool)
|
||||
|
||||
|
||||
|
@ -304,8 +304,6 @@ def update_pool_posts(pool: model.Pool, post_ids: List[int]) -> None:
|
|||
assert pool
|
||||
dupes = _duplicates(post_ids)
|
||||
if len(dupes) > 0:
|
||||
print(str(dupes))
|
||||
print(str(post_ids))
|
||||
dupes = ', '.join(list(str(x) for x in dupes))
|
||||
raise InvalidPoolDuplicateError('Duplicate post(s) in pool: ' + dupes)
|
||||
ret = posts.get_posts_by_ids(post_ids)
|
||||
|
|
|
@ -300,7 +300,7 @@ class PostSerializer(serialization.BaseSerializer):
|
|||
self.post.comments,
|
||||
key=lambda comment: comment.creation_time)]
|
||||
|
||||
def serialize_pools(self) -> Any:
|
||||
def serialize_pools(self) -> List[Any]:
|
||||
return [
|
||||
pools.serialize_pool(pool)
|
||||
for pool in sorted(
|
||||
|
@ -343,7 +343,7 @@ def get_post_by_id(post_id: int) -> model.Post:
|
|||
return post
|
||||
|
||||
|
||||
def get_posts_by_ids(ids: List[int]) -> List[model.Pool]:
|
||||
def get_posts_by_ids(ids: List[int]) -> List[model.Post]:
|
||||
if len(ids) == 0:
|
||||
return []
|
||||
posts = (
|
||||
|
|
Loading…
Reference in a new issue