mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
756 generic data fields (#1608)
* Adds the ability to add custom user fields for registration/profile settings * Admins can create fields that users can optionally edit * Works on #756
This commit is contained in:
@@ -22,6 +22,7 @@ from CTFd.models import (
|
||||
Challenges,
|
||||
Comments,
|
||||
Fails,
|
||||
Fields,
|
||||
Files,
|
||||
Flags,
|
||||
Hints,
|
||||
@@ -458,6 +459,30 @@ def gen_comment(db, content="comment", author_id=None, type="challenge", **kwarg
|
||||
return comment
|
||||
|
||||
|
||||
def gen_field(
|
||||
db,
|
||||
name="CustomField",
|
||||
type="user",
|
||||
field_type="text",
|
||||
description="CustomFieldDescription",
|
||||
required=True,
|
||||
public=True,
|
||||
editable=True,
|
||||
):
|
||||
field = Fields(
|
||||
name=name,
|
||||
type=type,
|
||||
field_type=field_type,
|
||||
description=description,
|
||||
required=required,
|
||||
public=public,
|
||||
editable=editable,
|
||||
)
|
||||
db.session.add(field)
|
||||
db.session.commit()
|
||||
return field
|
||||
|
||||
|
||||
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