mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 14:04:20 +01:00
* 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
23 lines
727 B
Python
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)
|