mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Properly load schemas specified as strings (#943)
* Properly load schemas specified by their key string * Add test for UserSchema * Prevent users without teams from interacting with challenges if the CTF is in Team Mode
This commit is contained in:
@@ -3,6 +3,7 @@ from marshmallow import fields, post_load
|
||||
from marshmallow import validate, ValidationError
|
||||
from marshmallow_sqlalchemy import field_for
|
||||
from CTFd.models import ma, Notifications
|
||||
from CTFd.utils import string_types
|
||||
|
||||
|
||||
class NotificationSchema(ma.ModelSchema):
|
||||
@@ -13,9 +14,9 @@ class NotificationSchema(ma.ModelSchema):
|
||||
|
||||
def __init__(self, view=None, *args, **kwargs):
|
||||
if view:
|
||||
if type(view) == str:
|
||||
if isinstance(view, string_types):
|
||||
kwargs['only'] = self.views[view]
|
||||
elif type(view) == list:
|
||||
elif isinstance(view, list):
|
||||
kwargs['only'] = view
|
||||
|
||||
super(NotificationSchema, self).__init__(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user