Files
CTFd/CTFd/schemas/notifications.py
Kevin Chung c0a32a836b 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
2019-04-08 01:47:26 -04:00

23 lines
727 B
Python

from sqlalchemy.sql.expression import union_all
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):
class Meta:
model = Notifications
include_fk = True
dump_only = ('id', 'date')
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(NotificationSchema, self).__init__(*args, **kwargs)