mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Challenge Topics (#1966)
* Closes #1897 * Adds Topics to Challenges where Topics are admin-only visible tags about challenges * Adds `/api/v1/topics` and `/api/v1/challenges/[challenge_id]/topics` to API * Challenge comments have been moved into a modal
This commit is contained in:
@@ -22,6 +22,7 @@ from CTFd.models import (
|
||||
ChallengeComments,
|
||||
ChallengeFiles,
|
||||
Challenges,
|
||||
ChallengeTopics,
|
||||
Comments,
|
||||
Fails,
|
||||
Fields,
|
||||
@@ -37,6 +38,7 @@ from CTFd.models import (
|
||||
TeamComments,
|
||||
Teams,
|
||||
Tokens,
|
||||
Topics,
|
||||
Tracking,
|
||||
Unlocks,
|
||||
UserComments,
|
||||
@@ -353,6 +355,17 @@ def gen_tag(db, challenge_id, value="tag_tag", **kwargs):
|
||||
return tag
|
||||
|
||||
|
||||
def gen_topic(db, challenge_id, value="topic", **kwargs):
|
||||
topic = Topics(value=value, **kwargs)
|
||||
db.session.add(topic)
|
||||
db.session.commit()
|
||||
|
||||
challenge_topic = ChallengeTopics(challenge_id=challenge_id, topic_id=topic.id)
|
||||
db.session.add(challenge_topic)
|
||||
db.session.commit()
|
||||
return challenge_topic
|
||||
|
||||
|
||||
def gen_file(db, location, challenge_id=None, page_id=None):
|
||||
if challenge_id:
|
||||
f = ChallengeFiles(challenge_id=challenge_id, location=location)
|
||||
|
||||
Reference in New Issue
Block a user