mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/comments: allow anonymous users to leave comments
This commit is contained in:
@ -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)
|
||||
|
@ -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,
|
||||
)
|
||||
|
Reference in New Issue
Block a user