mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Compare commits
4 Commits
master
...
086dfb6dd6
Author | SHA1 | Date | |
---|---|---|---|
086dfb6dd6 | |||
bfba05cfae | |||
3c51d1d694 | |||
0b99b98f9e |
@ -26,7 +26,7 @@
|
||||
%><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) { %><%
|
||||
%></a><%
|
||||
|
@ -48,7 +48,7 @@ def create_comment(
|
||||
text = ctx.get_param_as_string("text")
|
||||
post_id = ctx.get_param_as_int("postId")
|
||||
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.commit()
|
||||
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:
|
||||
assert post
|
||||
if user and not user.name:
|
||||
user = None
|
||||
post_feature = model.PostFeature()
|
||||
post_feature.time = datetime.utcnow()
|
||||
post_feature.post = post
|
||||
|
@ -107,6 +107,9 @@ def _create(
|
||||
entity
|
||||
)
|
||||
|
||||
if auth_user and not auth_user.name:
|
||||
auth_user = None
|
||||
|
||||
snapshot = model.Snapshot()
|
||||
snapshot.creation_time = datetime.utcnow()
|
||||
snapshot.operation = operation
|
||||
|
@ -43,12 +43,14 @@ def get_avatar_path(user_name: str) -> str:
|
||||
def get_avatar_url(user: model.User) -> str:
|
||||
assert user
|
||||
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" % (
|
||||
util.get_md5((user.email or user.name).lower()),
|
||||
config.config["thumbnails"]["avatar_width"],
|
||||
)
|
||||
assert user.name
|
||||
if not user.name:
|
||||
return ""
|
||||
return "%s/avatars/%s.png" % (
|
||||
config.config["data_url"].rstrip("/"),
|
||||
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.Integer,
|
||||
sa.ForeignKey("user.id"),
|
||||
sa.ForeignKey("user.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
|
@ -24,8 +24,8 @@ class PostFeature(Base):
|
||||
user_id = sa.Column(
|
||||
"user_id",
|
||||
sa.Integer,
|
||||
sa.ForeignKey("user.id"),
|
||||
nullable=False,
|
||||
sa.ForeignKey("user.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
time = sa.Column("time", sa.DateTime, nullable=False)
|
||||
|
Reference in New Issue
Block a user