mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-19 06:54:20 +01:00
* Fix regression for creating hints via ctfcli See #1582 for details. Closes https://github.com/CTFd/ctfcli/pull/20.
42 lines
1009 B
Python
42 lines
1009 B
Python
from CTFd.models import Hints, ma
|
|
from CTFd.utils import string_types
|
|
|
|
|
|
class HintSchema(ma.ModelSchema):
|
|
class Meta:
|
|
model = Hints
|
|
include_fk = True
|
|
dump_only = ("id", "type", "html")
|
|
|
|
views = {
|
|
"locked": ["id", "type", "challenge", "challenge_id", "cost"],
|
|
"unlocked": [
|
|
"id",
|
|
"type",
|
|
"challenge",
|
|
"challenge_id",
|
|
"content",
|
|
"html",
|
|
"cost",
|
|
],
|
|
"admin": [
|
|
"id",
|
|
"type",
|
|
"challenge",
|
|
"challenge_id",
|
|
"content",
|
|
"html",
|
|
"cost",
|
|
"requirements",
|
|
],
|
|
}
|
|
|
|
def __init__(self, view=None, *args, **kwargs):
|
|
if view:
|
|
if isinstance(view, string_types):
|
|
kwargs["only"] = self.views[view]
|
|
elif isinstance(view, list):
|
|
kwargs["only"] = view
|
|
|
|
super(HintSchema, self).__init__(*args, **kwargs)
|