This commit is contained in:
Ruin0x11 2020-06-02 17:43:18 -07:00
parent 7bcefeb347
commit 1be947e946
13 changed files with 175 additions and 206 deletions

View file

@ -1,7 +1,6 @@
<div class='pool-input'> <div class='pool-input'>
<div class='main-control'> <div class='main-control'>
<input type='text' placeholder='type to add…'/> <input type='text' placeholder='type to add…'/>
<!-- <button>Add</button> -->
</div> </div>
<ul class='compact-pools'></ul> <ul class='compact-pools'></ul>

View file

@ -7,11 +7,11 @@
<section> <section>
Aliases:<br/> Aliases:<br/>
<ul><!-- <ul>
--><% for (let name of ctx.pool.names.slice(1)) { %><!-- <% for (let name of ctx.pool.names.slice(1)) { %>
--><li><%= ctx.makePoolLink(ctx.pool.id, false, false, ctx.pool, name) %></li><!-- <li><%= ctx.makePoolLink(ctx.pool.id, false, false, ctx.pool, name) %></li>
--><% } %><!-- <% } %>
--></ul> </ul>
</section> </section>
</section> </section>

View file

@ -54,8 +54,7 @@ class PoolController {
this._view.addEventListener('submit', e => this._evtUpdate(e)); this._view.addEventListener('submit', e => this._evtUpdate(e));
this._view.addEventListener('merge', e => this._evtMerge(e)); this._view.addEventListener('merge', e => this._evtMerge(e));
this._view.addEventListener('delete', e => this._evtDelete(e)); this._view.addEventListener('delete', e => this._evtDelete(e));
}, }, error => {
error => {
this._view = new EmptyView(); this._view = new EmptyView();
this._view.showError(error.message); this._view.showError(error.message);
}); });
@ -68,9 +67,7 @@ class PoolController {
_evtSaved(e, section) { _evtSaved(e, section) {
misc.disableExitConfirmation(); misc.disableExitConfirmation();
if (this._name !== e.detail.pool.names[0]) { if (this._name !== e.detail.pool.names[0]) {
router.replace( router.replace(uri.formatClientLink('pool', e.detail.pool.id, section), null, false);
uri.formatClientLink('pool', e.detail.pool.id, section),
null, false);
} }
} }
@ -87,9 +84,9 @@ class PoolController {
e.detail.pool.description = e.detail.description; e.detail.pool.description = e.detail.description;
} }
if (e.detail.posts !== undefined) { if (e.detail.posts !== undefined) {
e.detail.pool.posts.clear() e.detail.pool.posts.clear();
for (let post_id of e.detail.posts) { 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(() => { e.detail.pool.save().then(() => {

View file

@ -16,8 +16,7 @@ class PoolCreateController {
return; return;
} }
PoolCategoryList.get() PoolCategoryList.get().then(poolCategoriesResponse => {
.then(poolCategoriesResponse => {
const categories = {}; const categories = {};
for (let category of poolCategoriesResponse.results) { for (let category of poolCategoriesResponse.results) {
categories[category.name] = category.name; categories[category.name] = category.name;

View file

@ -3,7 +3,6 @@ script_location = szurubooru/migrations
# overriden by szurubooru's config # overriden by szurubooru's config
sqlalchemy.url = sqlalchemy.url =
revision_environment = true
[loggers] [loggers]
keys = root,sqlalchemy,alembic keys = root,sqlalchemy,alembic

View file

@ -4,7 +4,7 @@
# shown in the website title and on the front page # shown in the website title and on the front page
name: szurubooru name: szurubooru
# full url to the homepage of this szurubooru site, with no trailing slash # 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 # used to salt the users' password hashes and generate filenames for static content
secret: change secret: change
@ -49,9 +49,6 @@ enable_safety: yes
tag_name_regex: ^\S+$ tag_name_regex: ^\S+$
tag_category_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 # 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 # customize them, make sure to update the instructions in the registration form
# template as well. # template as well.

View file

@ -9,4 +9,3 @@ pillow>=4.3.0
pynacl>=1.2.1 pynacl>=1.2.1
pytz>=2018.3 pytz>=2018.3
pyRFC3339>=1.0 pyRFC3339>=1.0
youtube_dl>=2020.5.3

View file

@ -34,22 +34,3 @@ def _bump_query_count() -> None:
sa.event.listen(_engine, 'after_execute', lambda *args: _bump_query_count()) 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)

View file

@ -195,5 +195,5 @@ def delete_category(category: model.PoolCategory) -> None:
if (category.pool_count or 0) > 0: if (category.pool_count or 0) > 0:
raise PoolCategoryIsInUseError( raise PoolCategoryIsInUseError(
'Pool category has some usages and cannot be deleted. ' + '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) db.session.delete(category)

View file

@ -77,6 +77,7 @@ def _duplicates(a: List[int]) -> List[int]:
dupes.append(x) dupes.append(x)
return dupes return dupes
def sort_pools(pools: List[model.Pool]) -> List[model.Pool]: def sort_pools(pools: List[model.Pool]) -> List[model.Pool]:
default_category_name = pool_categories.get_default_category_name() default_category_name = pool_categories.get_default_category_name()
return sorted( return sorted(
@ -131,8 +132,7 @@ class PoolSerializer(serialization.BaseSerializer):
def serialize_posts(self) -> Any: def serialize_posts(self) -> Any:
return [post for post in return [post for post in
[posts.serialize_micro_post(rel, None) [posts.serialize_micro_post(rel, None) for rel in self.pool.posts]]
for rel in self.pool.posts]]
def serialize_pool( 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: if source_pool.pool_id == target_pool.pool_id:
raise InvalidPoolRelationError('Cannot merge pool with itself.') 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 alias1 = model.PoolPost
alias2 = sa.orm.util.aliased(model.PoolPost) alias2 = sa.orm.util.aliased(model.PoolPost)
update_stmt = ( 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) update_stmt = update_stmt.values(pool_id=target_pool_id)
db.session.execute(update_stmt) 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) delete(source_pool)
@ -304,8 +304,6 @@ def update_pool_posts(pool: model.Pool, post_ids: List[int]) -> None:
assert pool assert pool
dupes = _duplicates(post_ids) dupes = _duplicates(post_ids)
if len(dupes) > 0: if len(dupes) > 0:
print(str(dupes))
print(str(post_ids))
dupes = ', '.join(list(str(x) for x in dupes)) dupes = ', '.join(list(str(x) for x in dupes))
raise InvalidPoolDuplicateError('Duplicate post(s) in pool: ' + dupes) raise InvalidPoolDuplicateError('Duplicate post(s) in pool: ' + dupes)
ret = posts.get_posts_by_ids(post_ids) ret = posts.get_posts_by_ids(post_ids)

View file

@ -300,7 +300,7 @@ class PostSerializer(serialization.BaseSerializer):
self.post.comments, self.post.comments,
key=lambda comment: comment.creation_time)] key=lambda comment: comment.creation_time)]
def serialize_pools(self) -> Any: def serialize_pools(self) -> List[Any]:
return [ return [
pools.serialize_pool(pool) pools.serialize_pool(pool)
for pool in sorted( for pool in sorted(
@ -343,7 +343,7 @@ def get_post_by_id(post_id: int) -> model.Post:
return 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: if len(ids) == 0:
return [] return []
posts = ( posts = (