mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Merge bfba05cfae
into ee7e9ef2a3
This commit is contained in:
@ -26,7 +26,7 @@
|
|||||||
%><a href='<%- ctx.formatClientLink('user', ctx.user.name) %>'><%
|
%><a href='<%- ctx.formatClientLink('user', ctx.user.name) %>'><%
|
||||||
%><% } %><%
|
%><% } %><%
|
||||||
|
|
||||||
%><%- ctx.user ? ctx.user.name : 'Deleted user' %><%
|
%><%- ctx.user ? ctx.user.name : 'Anonymous' %><%
|
||||||
|
|
||||||
%><% if (ctx.user && ctx.user.name && ctx.canViewUsers) { %><%
|
%><% if (ctx.user && ctx.user.name && ctx.canViewUsers) { %><%
|
||||||
%></a><%
|
%></a><%
|
||||||
|
@ -48,7 +48,7 @@ def create_comment(
|
|||||||
text = ctx.get_param_as_string("text")
|
text = ctx.get_param_as_string("text")
|
||||||
post_id = ctx.get_param_as_int("postId")
|
post_id = ctx.get_param_as_int("postId")
|
||||||
post = posts.get_post_by_id(post_id)
|
post = posts.get_post_by_id(post_id)
|
||||||
comment = comments.create_comment(ctx.user, post, text)
|
comment = comments.create_comment(ctx.user if ctx.user.name else None, post, text)
|
||||||
ctx.session.add(comment)
|
ctx.session.add(comment)
|
||||||
ctx.session.commit()
|
ctx.session.commit()
|
||||||
return _serialize(ctx, comment)
|
return _serialize(ctx, comment)
|
||||||
|
@ -794,6 +794,8 @@ def update_post_flags(post: model.Post, flags: List[str]) -> None:
|
|||||||
|
|
||||||
def feature_post(post: model.Post, user: Optional[model.User]) -> None:
|
def feature_post(post: model.Post, user: Optional[model.User]) -> None:
|
||||||
assert post
|
assert post
|
||||||
|
if user and not user.name:
|
||||||
|
user = None
|
||||||
post_feature = model.PostFeature()
|
post_feature = model.PostFeature()
|
||||||
post_feature.time = datetime.utcnow()
|
post_feature.time = datetime.utcnow()
|
||||||
post_feature.post = post
|
post_feature.post = post
|
||||||
|
@ -107,6 +107,9 @@ def _create(
|
|||||||
entity
|
entity
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if auth_user and not auth_user.name:
|
||||||
|
auth_user = None
|
||||||
|
|
||||||
snapshot = model.Snapshot()
|
snapshot = model.Snapshot()
|
||||||
snapshot.creation_time = datetime.utcnow()
|
snapshot.creation_time = datetime.utcnow()
|
||||||
snapshot.operation = operation
|
snapshot.operation = operation
|
||||||
|
@ -43,12 +43,14 @@ def get_avatar_path(user_name: str) -> str:
|
|||||||
def get_avatar_url(user: model.User) -> str:
|
def get_avatar_url(user: model.User) -> str:
|
||||||
assert user
|
assert user
|
||||||
if user.avatar_style == user.AVATAR_GRAVATAR:
|
if user.avatar_style == user.AVATAR_GRAVATAR:
|
||||||
assert user.email or user.name
|
if not user.email and not user.name:
|
||||||
|
return ""
|
||||||
return "https://gravatar.com/avatar/%s?d=retro&s=%d" % (
|
return "https://gravatar.com/avatar/%s?d=retro&s=%d" % (
|
||||||
util.get_md5((user.email or user.name).lower()),
|
util.get_md5((user.email or user.name).lower()),
|
||||||
config.config["thumbnails"]["avatar_width"],
|
config.config["thumbnails"]["avatar_width"],
|
||||||
)
|
)
|
||||||
assert user.name
|
if not user.name:
|
||||||
|
return ""
|
||||||
return "%s/avatars/%s.png" % (
|
return "%s/avatars/%s.png" % (
|
||||||
config.config["data_url"].rstrip("/"),
|
config.config["data_url"].rstrip("/"),
|
||||||
user.name.lower(),
|
user.name.lower(),
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
'''
|
||||||
|
make featuring users nullable
|
||||||
|
|
||||||
|
Revision ID: 5b5c940b4e78
|
||||||
|
Created at: 2025-04-04 08:24:39.000603
|
||||||
|
'''
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision = '5b5c940b4e78'
|
||||||
|
down_revision = 'adcd63ff76a2'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.alter_column(
|
||||||
|
"post_feature", "user_id", nullable=True, existing_nullable=False
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.alter_column(
|
||||||
|
"post_feature", "user_id", nullable=False, existing_nullable=True
|
||||||
|
)
|
||||||
|
pass
|
@ -46,7 +46,7 @@ class Comment(Base):
|
|||||||
user_id = sa.Column(
|
user_id = sa.Column(
|
||||||
"user_id",
|
"user_id",
|
||||||
sa.Integer,
|
sa.Integer,
|
||||||
sa.ForeignKey("user.id"),
|
sa.ForeignKey("user.id", ondelete="SET NULL"),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
|
@ -24,8 +24,8 @@ class PostFeature(Base):
|
|||||||
user_id = sa.Column(
|
user_id = sa.Column(
|
||||||
"user_id",
|
"user_id",
|
||||||
sa.Integer,
|
sa.Integer,
|
||||||
sa.ForeignKey("user.id"),
|
sa.ForeignKey("user.id", ondelete="SET NULL"),
|
||||||
nullable=False,
|
nullable=True,
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
time = sa.Column("time", sa.DateTime, nullable=False)
|
time = sa.Column("time", sa.DateTime, nullable=False)
|
||||||
|
Reference in New Issue
Block a user