mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
321 comments functionality (#1596)
* Add a comments functionality for admins to discuss challenges, users, teams, pages * Adds `/api/v1/comments` * Adds a `CommentBox.vue` component for the Admin Panel * Closes #321
This commit is contained in:
@@ -17,21 +17,26 @@ from CTFd.cache import cache, clear_standings
|
||||
from CTFd.config import TestingConfig
|
||||
from CTFd.models import (
|
||||
Awards,
|
||||
ChallengeComments,
|
||||
ChallengeFiles,
|
||||
Challenges,
|
||||
Comments,
|
||||
Fails,
|
||||
Files,
|
||||
Flags,
|
||||
Hints,
|
||||
Notifications,
|
||||
PageComments,
|
||||
PageFiles,
|
||||
Pages,
|
||||
Solves,
|
||||
Tags,
|
||||
TeamComments,
|
||||
Teams,
|
||||
Tokens,
|
||||
Tracking,
|
||||
Unlocks,
|
||||
UserComments,
|
||||
Users,
|
||||
)
|
||||
|
||||
@@ -435,6 +440,24 @@ def gen_token(db, type="user", user_id=None, expiration=None):
|
||||
return token
|
||||
|
||||
|
||||
def gen_comment(db, content="comment", author_id=None, type="challenge", **kwargs):
|
||||
if type == "challenge":
|
||||
model = ChallengeComments
|
||||
elif type == "user":
|
||||
model = UserComments
|
||||
elif type == "team":
|
||||
model = TeamComments
|
||||
elif type == "page":
|
||||
model = PageComments
|
||||
else:
|
||||
model = Comments
|
||||
|
||||
comment = model(content=content, author_id=author_id, type=type, **kwargs)
|
||||
db.session.add(comment)
|
||||
db.session.commit()
|
||||
return comment
|
||||
|
||||
|
||||
def simulate_user_activity(db, user):
|
||||
gen_tracking(db, user_id=user.id)
|
||||
gen_award(db, user_id=user.id)
|
||||
|
||||
Reference in New Issue
Block a user