678 lines
No EOL
30 KiB
Diff
678 lines
No EOL
30 KiB
Diff
diff --git a/indico/core/marshmallow.py b/indico/core/marshmallow.py
|
|
index d3718a5..e51ba0a 100644
|
|
--- a/indico/core/marshmallow.py
|
|
+++ b/indico/core/marshmallow.py
|
|
@@ -10,7 +10,6 @@ from inspect import getmro
|
|
from flask_marshmallow import Marshmallow
|
|
from flask_marshmallow.sqla import SQLAlchemyAutoSchemaOpts
|
|
from marshmallow import fields, post_dump, post_load, pre_load
|
|
-from marshmallow_enum import EnumField
|
|
from marshmallow_sqlalchemy import ModelConverter
|
|
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema as MSQLASQLAlchemyAutoSchema
|
|
from sqlalchemy.orm import ColumnProperty
|
|
@@ -33,7 +32,7 @@ class IndicoModelConverter(ModelConverter):
|
|
SQLA_TYPE_MAPPING = ModelConverter.SQLA_TYPE_MAPPING.copy()
|
|
SQLA_TYPE_MAPPING.update({
|
|
UTCDateTime: fields.DateTime,
|
|
- PyIntEnum: EnumField
|
|
+ PyIntEnum: fields.Enum
|
|
})
|
|
|
|
def _get_field_kwargs_for_property(self, prop):
|
|
diff --git a/indico/modules/categories/controllers/display.py b/indico/modules/categories/controllers/display.py
|
|
index 00d229c..b2e0707 100644
|
|
--- a/indico/modules/categories/controllers/display.py
|
|
+++ b/indico/modules/categories/controllers/display.py
|
|
@@ -17,7 +17,6 @@ import dateutil
|
|
from dateutil.parser import ParserError
|
|
from dateutil.relativedelta import relativedelta
|
|
from flask import flash, jsonify, redirect, request, session
|
|
-from marshmallow_enum import EnumField
|
|
from pytz import utc
|
|
from sqlalchemy.orm import joinedload, load_only, selectinload, subqueryload, undefer, undefer_group
|
|
from webargs import fields, validate
|
|
@@ -575,7 +574,7 @@ class RHCategoryCalendarViewEvents(RHDisplayCategoryBase):
|
|
room = auto()
|
|
keywords = auto()
|
|
|
|
- @use_kwargs({'group_by': EnumField(GroupBy, load_default=GroupBy.category)}, location='query')
|
|
+ @use_kwargs({'group_by': fields.Enum(GroupBy, load_default=GroupBy.category)}, location='query')
|
|
def _process_args(self, group_by):
|
|
RHDisplayCategoryBase._process_args(self)
|
|
tz = self.category.display_tzinfo
|
|
diff --git a/indico/modules/events/contributions/schemas.py b/indico/modules/events/contributions/schemas.py
|
|
index 3ea9d17..0f1df57 100644
|
|
--- a/indico/modules/events/contributions/schemas.py
|
|
+++ b/indico/modules/events/contributions/schemas.py
|
|
@@ -9,7 +9,6 @@ import hashlib
|
|
from operator import attrgetter
|
|
|
|
from marshmallow import fields, post_dump
|
|
-from marshmallow_enum import EnumField
|
|
from marshmallow_sqlalchemy import column2field
|
|
|
|
from indico.core.marshmallow import mm
|
|
@@ -38,7 +37,7 @@ class ContributionTypeSchema(mm.SQLAlchemyAutoSchema):
|
|
|
|
|
|
class ContributionFieldSchema(mm.Schema):
|
|
- visibility = EnumField(ContributionFieldVisibility)
|
|
+ visibility = fields.Enum(ContributionFieldVisibility)
|
|
|
|
class Meta:
|
|
model = ContributionField
|
|
diff --git a/indico/modules/events/controllers/display.py b/indico/modules/events/controllers/display.py
|
|
index e7d4830..eb4aa57 100644
|
|
--- a/indico/modules/events/controllers/display.py
|
|
+++ b/indico/modules/events/controllers/display.py
|
|
@@ -8,7 +8,6 @@
|
|
from io import BytesIO
|
|
|
|
from flask import jsonify, redirect, request, session
|
|
-from marshmallow_enum import EnumField
|
|
from webargs import fields
|
|
|
|
from indico.modules.events.controllers.base import RHDisplayEventBase, RHEventBase
|
|
@@ -27,7 +26,7 @@ from indico.web.rh import RHProtected, allow_signed_url
|
|
@allow_signed_url
|
|
class RHExportEventICAL(RHDisplayEventBase):
|
|
@use_kwargs({
|
|
- 'scope': EnumField(CalendarScope, load_default=None),
|
|
+ 'scope': fields.Enum(CalendarScope, load_default=None),
|
|
'detail': fields.String(load_default=None),
|
|
'series': fields.Boolean(load_default=False) # Export the full event series
|
|
}, location='query')
|
|
diff --git a/indico/modules/events/editing/controllers/backend/timeline.py b/indico/modules/events/editing/controllers/backend/timeline.py
|
|
index 1088178..4c9a807 100644
|
|
--- a/indico/modules/events/editing/controllers/backend/timeline.py
|
|
+++ b/indico/modules/events/editing/controllers/backend/timeline.py
|
|
@@ -13,7 +13,6 @@ from zipfile import ZipFile, ZipInfo
|
|
|
|
from flask import jsonify, request, session
|
|
from marshmallow import EXCLUDE, fields
|
|
-from marshmallow_enum import EnumField
|
|
from sqlalchemy.orm import joinedload
|
|
from werkzeug.exceptions import BadRequest, Conflict, Forbidden, NotFound, ServiceUnavailable
|
|
|
|
@@ -248,7 +247,7 @@ class RHConfirmEditableChanges(RHContributionEditableRevisionBase):
|
|
return self.editable.can_perform_submitter_actions(session.user)
|
|
|
|
@use_kwargs({
|
|
- 'action': EnumField(EditingConfirmationAction, required=True),
|
|
+ 'action': fields.Enum(EditingConfirmationAction, required=True),
|
|
'comment': fields.String(load_default='')
|
|
})
|
|
def _process(self, action, comment):
|
|
@@ -267,7 +266,7 @@ class RHReplaceRevision(RHContributionEditableRevisionBase):
|
|
|
|
@use_kwargs({
|
|
'comment': fields.String(load_default=''),
|
|
- 'revision_type': EnumField(RevisionType)
|
|
+ 'revision_type': fields.Enum(RevisionType)
|
|
})
|
|
def _process(self, comment, revision_type):
|
|
args = parser.parse({
|
|
diff --git a/indico/modules/events/editing/schemas.py b/indico/modules/events/editing/schemas.py
|
|
index f3c022e..b5da577 100644
|
|
--- a/indico/modules/events/editing/schemas.py
|
|
+++ b/indico/modules/events/editing/schemas.py
|
|
@@ -10,7 +10,6 @@ from operator import itemgetter
|
|
|
|
from markupsafe import escape
|
|
from marshmallow import ValidationError, fields, post_dump, validate, validates, validates_schema
|
|
-from marshmallow_enum import EnumField
|
|
from sqlalchemy import func
|
|
|
|
from indico.core.marshmallow import mm
|
|
@@ -251,7 +250,7 @@ class EditableBasicSchema(mm.SQLAlchemyAutoSchema):
|
|
model = Editable
|
|
fields = ('id', 'type', 'state', 'editor', 'timeline_url', 'revision_count', 'tags', 'last_update_dt')
|
|
|
|
- state = EnumField(EditableState)
|
|
+ state = fields.Enum(EditableState)
|
|
editor = fields.Nested(EditingUserSchema)
|
|
timeline_url = fields.String()
|
|
tags = fields.List(fields.Nested(EditingTagSchema, only=('id', 'code', 'title', 'color')),
|
|
@@ -295,7 +294,7 @@ class FilteredEditableSchema(mm.SQLAlchemyAutoSchema):
|
|
attribute='contribution.person_links')
|
|
contribution_keywords = fields.List(fields.String(), attribute='contribution.keywords')
|
|
contribution_session = fields.Nested(SessionBasicSchema, attribute='contribution.session')
|
|
- state = EnumField(EditableState)
|
|
+ state = fields.Enum(EditableState)
|
|
timeline_url = fields.String()
|
|
editor = fields.Nested(EditingUserSchema)
|
|
can_assign_self = fields.Function(lambda editable, ctx: editable.can_assign_self(ctx.get('user')))
|
|
@@ -318,7 +317,7 @@ class EditingReviewAction(IndicoEnum):
|
|
|
|
|
|
class ReviewEditableArgs(mm.Schema):
|
|
- action = EnumField(EditingReviewAction, required=True)
|
|
+ action = fields.Enum(EditingReviewAction, required=True)
|
|
comment = fields.String(load_default='')
|
|
|
|
@validates_schema(skip_on_field_errors=True)
|
|
@@ -437,7 +436,7 @@ class EditingMenuItemSchema(mm.Schema):
|
|
|
|
|
|
class EditableTypeArgs(mm.Schema):
|
|
- editable_types = fields.List(EnumField(EditableType), required=True)
|
|
+ editable_types = fields.List(fields.Enum(EditableType), required=True)
|
|
|
|
|
|
class EditableTypePrincipalsSchema(mm.Schema):
|
|
diff --git a/indico/modules/events/notes/controllers.py b/indico/modules/events/notes/controllers.py
|
|
index 4e8a17e..c5b3191 100644
|
|
--- a/indico/modules/events/notes/controllers.py
|
|
+++ b/indico/modules/events/notes/controllers.py
|
|
@@ -6,7 +6,6 @@
|
|
# LICENSE file for more details.
|
|
|
|
from flask import jsonify, redirect, request, session
|
|
-from marshmallow_enum import EnumField
|
|
from webargs import fields
|
|
from werkzeug.exceptions import Forbidden, NotFound
|
|
|
|
@@ -70,7 +69,7 @@ class RHApiNote(RHManageNoteBase):
|
|
return EventNoteSchema().dump(note.current_revision)
|
|
|
|
@use_kwargs({
|
|
- 'render_mode': EnumField(RenderMode, load_default=RenderMode.html),
|
|
+ 'render_mode': fields.Enum(RenderMode, load_default=RenderMode.html),
|
|
'source': fields.String(required=True),
|
|
'revision_id': fields.Integer(),
|
|
})
|
|
diff --git a/indico/modules/events/papers/controllers/api.py b/indico/modules/events/papers/controllers/api.py
|
|
index c06042c..183bc7f 100644
|
|
--- a/indico/modules/events/papers/controllers/api.py
|
|
+++ b/indico/modules/events/papers/controllers/api.py
|
|
@@ -6,7 +6,6 @@
|
|
# LICENSE file for more details.
|
|
|
|
from flask import request, session
|
|
-from marshmallow_enum import EnumField
|
|
from webargs import fields, validate
|
|
from werkzeug.exceptions import Forbidden, UnprocessableEntity
|
|
|
|
@@ -50,7 +49,7 @@ class RHCreatePaperComment(RHPaperBase):
|
|
|
|
@use_kwargs({
|
|
'comment': fields.String(validate=not_empty),
|
|
- 'visibility': EnumField(PaperCommentVisibility, load_default=None)
|
|
+ 'visibility': fields.Enum(PaperCommentVisibility, load_default=None)
|
|
})
|
|
def _process(self, comment, visibility):
|
|
create_comment(self.paper, comment, visibility, session.user)
|
|
@@ -82,7 +81,7 @@ class RHCommentActions(RHPaperBase):
|
|
|
|
@use_kwargs({
|
|
'comment': fields.String(validate=not_empty),
|
|
- 'visibility': EnumField(PaperCommentVisibility)
|
|
+ 'visibility': fields.Enum(PaperCommentVisibility)
|
|
}, partial=True)
|
|
def _process_PATCH(self, comment=None, visibility=None):
|
|
update_comment(self.comment, comment, visibility)
|
|
@@ -94,7 +93,7 @@ class RHJudgePaper(RHPaperBase):
|
|
return self.paper.can_judge(session.user, check_state=True)
|
|
|
|
@use_kwargs({
|
|
- 'action': EnumField(PaperAction, required=True),
|
|
+ 'action': fields.Enum(PaperAction, required=True),
|
|
'comment': fields.String()
|
|
})
|
|
def _process(self, action, comment):
|
|
@@ -122,7 +121,7 @@ class RHSubmitNewRevision(RHPaperBase):
|
|
|
|
def _parse_review_args(event, review_type):
|
|
args_schema = {
|
|
- 'proposed_action': EnumField(PaperAction, required=True),
|
|
+ 'proposed_action': fields.Enum(PaperAction, required=True),
|
|
'comment': fields.String(load_default='')
|
|
}
|
|
|
|
diff --git a/indico/modules/events/papers/schemas.py b/indico/modules/events/papers/schemas.py
|
|
index 4b228ab..fd47bcf 100644
|
|
--- a/indico/modules/events/papers/schemas.py
|
|
+++ b/indico/modules/events/papers/schemas.py
|
|
@@ -7,8 +7,7 @@
|
|
|
|
from markupsafe import escape
|
|
from marshmallow import post_dump
|
|
-from marshmallow.fields import Boolean, Decimal, Field, Function, Integer, List, Method, Nested, String
|
|
-from marshmallow_enum import EnumField
|
|
+from marshmallow.fields import Boolean, Decimal, Enum, Field, Function, Integer, List, Method, Nested, String
|
|
|
|
from indico.core.marshmallow import mm
|
|
from indico.modules.events.contributions.schemas import BasicContributionSchema
|
|
@@ -100,7 +99,7 @@ class PaperRevisionSchema(mm.SQLAlchemyAutoSchema):
|
|
judge = Nested(BasicUserSchema)
|
|
spotlight_file = Nested(PaperFileSchema)
|
|
files = List(Nested(PaperFileSchema))
|
|
- state = EnumField(PaperRevisionState)
|
|
+ state = Enum(PaperRevisionState)
|
|
timeline = PaperRevisionTimelineField()
|
|
judgment_comment_html = Function(lambda revision: escape(revision.judgment_comment))
|
|
reviewer_data = Method('_get_reviewer_data')
|
|
diff --git a/indico/modules/events/persons/schemas.py b/indico/modules/events/persons/schemas.py
|
|
index 9de1947..f122ae1 100644
|
|
--- a/indico/modules/events/persons/schemas.py
|
|
+++ b/indico/modules/events/persons/schemas.py
|
|
@@ -6,7 +6,6 @@
|
|
# LICENSE file for more details.
|
|
|
|
from marshmallow import fields, post_dump, post_load, pre_load
|
|
-from marshmallow_enum import EnumField
|
|
|
|
from indico.core.marshmallow import mm
|
|
from indico.modules.events.models.persons import EventPerson
|
|
@@ -24,7 +23,7 @@ class PersonLinkSchema(mm.Schema):
|
|
name = fields.String(attribute='display_full_name', dump_only=True)
|
|
first_name = fields.String(load_default='')
|
|
last_name = fields.String(required=True)
|
|
- _title = EnumField(UserTitle, data_key='title')
|
|
+ _title = fields.Enum(UserTitle, data_key='title')
|
|
affiliation = fields.String(load_default='')
|
|
affiliation_link = ModelField(Affiliation, data_key='affiliation_id', load_default=None, load_only=True)
|
|
affiliation_id = fields.Integer(load_default=None, dump_only=True)
|
|
@@ -100,4 +99,4 @@ class EventPersonUpdateSchema(EventPersonSchema):
|
|
class Meta(EventPersonSchema.Meta):
|
|
fields = ('title', 'first_name', 'last_name', 'address', 'phone', 'affiliation', 'affiliation_link')
|
|
|
|
- title = EnumField(UserTitle)
|
|
+ title = fields.Enum(UserTitle)
|
|
diff --git a/indico/modules/events/registration/controllers/management/privacy.py b/indico/modules/events/registration/controllers/management/privacy.py
|
|
index eabbe3b..4bbd6f0 100644
|
|
--- a/indico/modules/events/registration/controllers/management/privacy.py
|
|
+++ b/indico/modules/events/registration/controllers/management/privacy.py
|
|
@@ -7,7 +7,7 @@
|
|
|
|
from flask import redirect, session
|
|
from flask.helpers import flash
|
|
-from marshmallow_enum import EnumField
|
|
+from marshmallow import fields
|
|
|
|
from indico.core.db import db
|
|
from indico.modules.events import EventLogRealm
|
|
@@ -64,7 +64,7 @@ class RHRegistrationPrivacy(RHManageRegFormBase):
|
|
class RHAPIRegistrationChangeConsent(RHRegistrationFormRegistrationBase):
|
|
"""Internal API to change registration consent to publish."""
|
|
|
|
- @use_kwargs({'consent_to_publish': EnumField(RegistrationVisibility)})
|
|
+ @use_kwargs({'consent_to_publish': fields.Enum(RegistrationVisibility)})
|
|
def _process_POST(self, consent_to_publish):
|
|
update_registration_consent_to_publish(self.registration, consent_to_publish)
|
|
return '', 204
|
|
diff --git a/indico/modules/events/registration/util.py b/indico/modules/events/registration/util.py
|
|
index c370676..ea03684 100644
|
|
--- a/indico/modules/events/registration/util.py
|
|
+++ b/indico/modules/events/registration/util.py
|
|
@@ -15,7 +15,6 @@ from operator import attrgetter
|
|
|
|
from flask import json, session
|
|
from marshmallow import RAISE, ValidationError, fields, validates
|
|
-from marshmallow_enum import EnumField
|
|
from PIL import Image, ImageOps
|
|
from qrcode import QRCode, constants
|
|
from sqlalchemy import and_, or_
|
|
@@ -349,7 +348,7 @@ def make_registration_schema(
|
|
schema['notify_user'] = fields.Boolean()
|
|
schema['override_required'] = fields.Boolean()
|
|
elif regform.needs_publish_consent:
|
|
- schema['consent_to_publish'] = EnumField(RegistrationVisibility)
|
|
+ schema['consent_to_publish'] = fields.Enum(RegistrationVisibility)
|
|
|
|
if captcha_required:
|
|
schema['captcha'] = CaptchaField()
|
|
diff --git a/indico/modules/rb/controllers/backend/bookings.py b/indico/modules/rb/controllers/backend/bookings.py
|
|
index 30f95dd..c361b68 100644
|
|
--- a/indico/modules/rb/controllers/backend/bookings.py
|
|
+++ b/indico/modules/rb/controllers/backend/bookings.py
|
|
@@ -11,7 +11,6 @@ from datetime import date, datetime, time
|
|
import dateutil
|
|
from flask import jsonify, request, session
|
|
from marshmallow import fields, validate
|
|
-from marshmallow_enum import EnumField
|
|
from sqlalchemy.orm import joinedload
|
|
from werkzeug.exceptions import BadRequest, Forbidden, NotFound
|
|
|
|
@@ -65,7 +64,7 @@ class RHTimeline(RHRoomBookingBase):
|
|
@use_kwargs({
|
|
'start_dt': fields.DateTime(required=True),
|
|
'end_dt': fields.DateTime(required=True),
|
|
- 'repeat_frequency': EnumField(RepeatFrequency, load_default='NEVER'),
|
|
+ 'repeat_frequency': fields.Enum(RepeatFrequency, load_default='NEVER'),
|
|
'repeat_interval': fields.Int(load_default=1),
|
|
'recurrence_weekdays': fields.List(fields.Str(validate=validate.OneOf(WEEKDAYS)), load_default=None),
|
|
'skip_conflicts_with': fields.List(fields.Int(), load_default=None),
|
|
@@ -311,7 +310,7 @@ class RHBookingEditCalendars(RHBookingBase):
|
|
@use_kwargs({
|
|
'start_dt': fields.DateTime(required=True),
|
|
'end_dt': fields.DateTime(required=True),
|
|
- 'repeat_frequency': EnumField(RepeatFrequency, load_default='NEVER'),
|
|
+ 'repeat_frequency': fields.Enum(RepeatFrequency, load_default='NEVER'),
|
|
'repeat_interval': fields.Int(load_default=1),
|
|
'recurrence_weekdays': fields.List(fields.Str(validate=validate.OneOf(WEEKDAYS)), load_default=None)
|
|
}, location='query')
|
|
@@ -395,7 +394,7 @@ class RHMatchingEvents(RHRoomBookingBase):
|
|
@use_kwargs({
|
|
'start_dt': fields.DateTime(),
|
|
'end_dt': fields.DateTime(),
|
|
- 'repeat_frequency': EnumField(RepeatFrequency, load_default='NEVER'),
|
|
+ 'repeat_frequency': fields.Enum(RepeatFrequency, load_default='NEVER'),
|
|
'repeat_interval': fields.Int(load_default=1),
|
|
'recurrence_weekdays': fields.List(fields.Str(validate=validate.OneOf(WEEKDAYS)), load_default=None)
|
|
}, location='query')
|
|
diff --git a/indico/modules/rb/controllers/backend/common.py b/indico/modules/rb/controllers/backend/common.py
|
|
index 5387c4f..38ecc9e 100644
|
|
--- a/indico/modules/rb/controllers/backend/common.py
|
|
+++ b/indico/modules/rb/controllers/backend/common.py
|
|
@@ -6,7 +6,6 @@
|
|
# LICENSE file for more details.
|
|
|
|
from marshmallow import validate
|
|
-from marshmallow_enum import EnumField
|
|
from webargs import fields
|
|
|
|
from indico.modules.rb.models.reservations import RepeatFrequency
|
|
@@ -23,7 +22,7 @@ search_room_args = {
|
|
'division': fields.Str(),
|
|
'start_dt': fields.DateTime(),
|
|
'end_dt': fields.DateTime(),
|
|
- 'repeat_frequency': EnumField(RepeatFrequency),
|
|
+ 'repeat_frequency': fields.Enum(RepeatFrequency),
|
|
'repeat_interval': fields.Int(load_default=0),
|
|
'recurrence_weekdays': fields.List(fields.Str(validate=validate.OneOf(WEEKDAYS))),
|
|
'building': fields.Str(),
|
|
diff --git a/indico/modules/rb/schemas.py b/indico/modules/rb/schemas.py
|
|
index d9cafb8..1bc9854 100644
|
|
--- a/indico/modules/rb/schemas.py
|
|
+++ b/indico/modules/rb/schemas.py
|
|
@@ -11,7 +11,6 @@ from babel.dates import get_timezone
|
|
from flask import session
|
|
from marshmallow import ValidationError, fields, post_dump, post_load, validate, validates, validates_schema
|
|
from marshmallow.fields import Boolean, Date, DateTime, Function, Method, Nested, Number, Pluck, String
|
|
-from marshmallow_enum import EnumField
|
|
from sqlalchemy import func
|
|
|
|
from indico.core.config import config
|
|
@@ -79,7 +78,7 @@ class AdminRoomSchema(mm.SQLAlchemyAutoSchema):
|
|
class RoomUpdateSchema(RoomSchema):
|
|
owner = Principal()
|
|
acl_entries = PrincipalPermissionList(RoomPrincipal)
|
|
- protection_mode = EnumField(ProtectionMode)
|
|
+ protection_mode = fields.Enum(ProtectionMode)
|
|
|
|
class Meta(RoomSchema.Meta):
|
|
fields = (*RoomSchema.Meta.fields, 'notification_before_days', 'notification_before_days_weekly', 'owner',
|
|
@@ -117,7 +116,7 @@ class RoomUpdateArgsSchema(mm.Schema):
|
|
max_advance_days = fields.Int(validate=lambda x: x >= 1, allow_none=True)
|
|
comments = fields.String()
|
|
acl_entries = PrincipalPermissionList(RoomPrincipal)
|
|
- protection_mode = EnumField(ProtectionMode)
|
|
+ protection_mode = fields.Enum(ProtectionMode)
|
|
|
|
|
|
class RoomEquipmentSchema(mm.SQLAlchemyAutoSchema):
|
|
@@ -185,11 +184,11 @@ class ReservationUserEventSchema(mm.Schema):
|
|
|
|
class ReservationOccurrenceLinkSchema(mm.SQLAlchemyAutoSchema):
|
|
id = Number()
|
|
- type = EnumField(LinkType, attribute='link_type')
|
|
+ type = fields.Enum(LinkType, attribute='link_type')
|
|
object = Nested(ReservationLinkedObjectDataSchema,
|
|
only=('url', 'title', 'event_title', 'event_url', 'start_dt', 'end_dt'))
|
|
start_dt = NaiveDateTime(attribute='reservation_occurrence.start_dt')
|
|
- state = EnumField(ReservationOccurrenceState, attribute='reservation_occurrence.state')
|
|
+ state = fields.Enum(ReservationOccurrenceState, attribute='reservation_occurrence.state')
|
|
|
|
@post_dump(pass_original=True)
|
|
def _hide_restricted_object(self, data, link, **kwargs):
|
|
@@ -204,7 +203,7 @@ class ReservationOccurrenceLinkSchema(mm.SQLAlchemyAutoSchema):
|
|
|
|
class ReservationOccurrenceSchema(mm.SQLAlchemyAutoSchema):
|
|
reservation = Nested(ReservationSchema)
|
|
- state = EnumField(ReservationOccurrenceState)
|
|
+ state = fields.Enum(ReservationOccurrenceState)
|
|
start_dt = NaiveDateTime()
|
|
end_dt = NaiveDateTime()
|
|
|
|
@@ -262,7 +261,7 @@ class ReservationDetailsSchema(mm.SQLAlchemyAutoSchema):
|
|
can_edit = Function(lambda booking: booking.can_edit(session.user))
|
|
can_reject = Function(lambda booking: booking.can_reject(session.user))
|
|
permissions = Method('_get_permissions')
|
|
- state = EnumField(ReservationState)
|
|
+ state = fields.Enum(ReservationState)
|
|
is_linked_to_objects = Function(lambda booking: bool(booking.links))
|
|
start_dt = NaiveDateTime()
|
|
end_dt = NaiveDateTime()
|
|
@@ -302,7 +301,7 @@ class ReservationDetailsSchema(mm.SQLAlchemyAutoSchema):
|
|
|
|
class BlockedRoomSchema(mm.SQLAlchemyAutoSchema):
|
|
room = Nested(RoomSchema, only=('id', 'name', 'sprite_position', 'full_name'))
|
|
- state = EnumField(BlockedRoomState)
|
|
+ state = fields.Enum(BlockedRoomState)
|
|
|
|
class Meta:
|
|
model = BlockedRoom
|
|
@@ -398,7 +397,7 @@ class CreateBookingSchema(mm.Schema):
|
|
|
|
start_dt = fields.DateTime(required=True)
|
|
end_dt = fields.DateTime(required=True)
|
|
- repeat_frequency = EnumField(RepeatFrequency, required=True)
|
|
+ repeat_frequency = fields.Enum(RepeatFrequency, required=True)
|
|
repeat_interval = fields.Int(load_default=0, validate=lambda x: x >= 0)
|
|
recurrence_weekdays = fields.List(fields.Str(validate=validate.OneOf(WEEKDAYS)))
|
|
room_id = fields.Int(required=True)
|
|
@@ -406,7 +405,7 @@ class CreateBookingSchema(mm.Schema):
|
|
booking_reason = fields.String(data_key='reason', load_default='')
|
|
internal_note = fields.String()
|
|
is_prebooking = fields.Bool(load_default=False)
|
|
- link_type = EnumField(LinkType)
|
|
+ link_type = fields.Enum(LinkType)
|
|
link_id = fields.Int()
|
|
link_back = fields.Bool(load_default=False)
|
|
admin_override_enabled = fields.Bool(load_default=False)
|
|
@@ -561,7 +560,7 @@ class SettingsSchema(mm.Schema):
|
|
hide_module_if_unauthorized = fields.Bool()
|
|
tileserver_url = fields.String(validate=validate.URL(schemes={'http', 'https'}), allow_none=True)
|
|
booking_limit = fields.Int(validate=not_empty)
|
|
- booking_reason_required = EnumField(BookingReasonRequiredOptions, required=True)
|
|
+ booking_reason_required = fields.Enum(BookingReasonRequiredOptions, required=True)
|
|
notifications_enabled = fields.Bool()
|
|
notification_before_days = fields.Int(validate=validate.Range(min=1, max=30))
|
|
notification_before_days_weekly = fields.Int(validate=validate.Range(min=1, max=30))
|
|
diff --git a/indico/modules/search/controllers.py b/indico/modules/search/controllers.py
|
|
index a115a81..7f818d9 100644
|
|
--- a/indico/modules/search/controllers.py
|
|
+++ b/indico/modules/search/controllers.py
|
|
@@ -7,7 +7,6 @@
|
|
|
|
from flask import jsonify, session
|
|
from marshmallow import INCLUDE, fields
|
|
-from marshmallow_enum import EnumField
|
|
|
|
from indico.modules.categories.controllers.base import RHDisplayCategoryBase
|
|
from indico.modules.events.controllers.base import RHDisplayEventBase
|
|
@@ -46,7 +45,7 @@ class RHAPISearch(RH):
|
|
@use_kwargs({
|
|
'page': fields.Int(load_default=None),
|
|
'q': fields.String(required=True),
|
|
- 'type': fields.List(EnumField(SearchTarget), required=True),
|
|
+ 'type': fields.List(fields.Enum(SearchTarget), required=True),
|
|
'admin_override_enabled': fields.Bool(
|
|
load_default=False,
|
|
validate=validate_with_message(lambda value: session.user and session.user.is_admin,
|
|
diff --git a/indico/modules/search/result_schemas.py b/indico/modules/search/result_schemas.py
|
|
index 88c274e..96efa43 100644
|
|
--- a/indico/modules/search/result_schemas.py
|
|
+++ b/indico/modules/search/result_schemas.py
|
|
@@ -6,7 +6,6 @@
|
|
# LICENSE file for more details.
|
|
|
|
from marshmallow import EXCLUDE, ValidationError, fields
|
|
-from marshmallow_enum import EnumField
|
|
from marshmallow_oneofschema import OneOfSchema
|
|
|
|
from indico.core.db.sqlalchemy.links import LinkType
|
|
@@ -63,7 +62,7 @@ def require_search_target(target):
|
|
|
|
|
|
class CategoryResultSchema(ResultSchemaBase):
|
|
- type = EnumField(SearchTarget, validate=require_search_target(SearchTarget.category))
|
|
+ type = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.category))
|
|
category_id = fields.Int(required=True)
|
|
title = fields.String(required=True)
|
|
url = fields.Method('_get_url')
|
|
@@ -83,7 +82,7 @@ class LocationResultSchema(mm.Schema):
|
|
|
|
class EventResultSchema(ResultSchemaBase):
|
|
#: The record type
|
|
- type: SearchTarget = EnumField(SearchTarget, validate=require_search_target(SearchTarget.event))
|
|
+ type: SearchTarget = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.event))
|
|
#: The event id
|
|
event_id = fields.Int(required=True)
|
|
#: The event title
|
|
@@ -91,7 +90,7 @@ class EventResultSchema(ResultSchemaBase):
|
|
#: The event description
|
|
description = fields.String(required=True)
|
|
#: The event type
|
|
- event_type = EnumField(EventType, required=True)
|
|
+ event_type = fields.Enum(EventType, required=True)
|
|
#: The event start date time
|
|
start_dt = fields.DateTime(required=True)
|
|
#: The event end date time
|
|
@@ -111,7 +110,7 @@ class EventResultSchema(ResultSchemaBase):
|
|
|
|
class ContributionResultSchema(ResultSchemaBase):
|
|
#: The record type
|
|
- type: SearchTarget = EnumField(SearchTarget, validate=require_search_target(SearchTarget.contribution))
|
|
+ type: SearchTarget = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.contribution))
|
|
#: The contribution id
|
|
contribution_id = fields.Int(required=True)
|
|
#: The contribution event id
|
|
@@ -150,7 +149,7 @@ class ContributionResultSchema(ResultSchemaBase):
|
|
|
|
class SubContributionResultSchema(ContributionResultSchema):
|
|
#: The record type
|
|
- type: SearchTarget = EnumField(SearchTarget, validate=require_search_target(SearchTarget.subcontribution))
|
|
+ type: SearchTarget = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.subcontribution))
|
|
#: The sub-contribution id
|
|
subcontribution_id = fields.Int(required=True)
|
|
|
|
@@ -188,7 +187,7 @@ def _get_event_path(obj):
|
|
|
|
class AttachmentResultSchema(ResultSchemaBase):
|
|
#: The record type
|
|
- type: SearchTarget = EnumField(SearchTarget, validate=require_search_target(SearchTarget.attachment))
|
|
+ type: SearchTarget = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.attachment))
|
|
#: The attachment id
|
|
attachment_id = fields.Int(required=True)
|
|
#: The attachment folder id
|
|
@@ -206,7 +205,7 @@ class AttachmentResultSchema(ResultSchemaBase):
|
|
#: The attachment author
|
|
user: PersonSchema = fields.Nested(PersonSchema, load_default=None)
|
|
#: The attachment type
|
|
- attachment_type: AttachmentType = EnumField(AttachmentType, required=True)
|
|
+ attachment_type: AttachmentType = fields.Enum(AttachmentType, required=True)
|
|
#: The attachment last modified date time
|
|
modified_dt = fields.DateTime(required=True)
|
|
# extra fields that are not taken from the data returned by the search engine
|
|
@@ -227,7 +226,7 @@ class AttachmentResultSchema(ResultSchemaBase):
|
|
|
|
class EventNoteResultSchema(ResultSchemaBase):
|
|
#: The record type
|
|
- type: SearchTarget = EnumField(SearchTarget, validate=require_search_target(SearchTarget.event_note))
|
|
+ type: SearchTarget = fields.Enum(SearchTarget, validate=require_search_target(SearchTarget.event_note))
|
|
#: The note id
|
|
note_id = fields.Int(required=True)
|
|
#: The note event id
|
|
diff --git a/indico/modules/users/controllers.py b/indico/modules/users/controllers.py
|
|
index 5cb5047..52c7a51 100644
|
|
--- a/indico/modules/users/controllers.py
|
|
+++ b/indico/modules/users/controllers.py
|
|
@@ -15,7 +15,6 @@ from flask import flash, jsonify, redirect, render_template, request, session
|
|
from itsdangerous import BadSignature
|
|
from markupsafe import Markup, escape
|
|
from marshmallow import fields
|
|
-from marshmallow_enum import EnumField
|
|
from PIL import Image
|
|
from sqlalchemy.orm import joinedload, load_only, subqueryload
|
|
from sqlalchemy.orm.exc import StaleDataError
|
|
@@ -337,7 +336,7 @@ class RHProfilePicturePreview(RHUserBase):
|
|
|
|
flash_user_status = False
|
|
|
|
- @use_kwargs({'source': EnumField(ProfilePictureSource)}, location='view_args')
|
|
+ @use_kwargs({'source': fields.Enum(ProfilePictureSource)}, location='view_args')
|
|
def _process(self, source):
|
|
if source == ProfilePictureSource.standard:
|
|
first_name = self.user.first_name[0].upper() if self.user.first_name else ''
|
|
@@ -374,7 +373,7 @@ class RHSaveProfilePicture(RHUserBase):
|
|
"""Update the user's profile picture."""
|
|
|
|
@use_kwargs({
|
|
- 'source': EnumField(ProfilePictureSource, required=True)
|
|
+ 'source': fields.Enum(ProfilePictureSource, required=True)
|
|
})
|
|
def _process(self, source):
|
|
self.user.picture_source = source
|
|
@@ -885,7 +884,7 @@ class RHRejectRegistrationRequest(RHRegistrationRequestBase):
|
|
class UserSearchResultSchema(mm.SQLAlchemyAutoSchema):
|
|
affiliation_id = fields.Integer(attribute='_affiliation.affiliation_id')
|
|
affiliation_meta = fields.Nested(AffiliationSchema, attribute='_affiliation.affiliation_link')
|
|
- title = EnumField(UserTitle, attribute='_title')
|
|
+ title = fields.Enum(UserTitle, attribute='_title')
|
|
|
|
class Meta:
|
|
model = User
|
|
diff --git a/indico/util/marshmallow.py b/indico/util/marshmallow.py
|
|
index fed7293..b331b4a 100644
|
|
--- a/indico/util/marshmallow.py
|
|
+++ b/indico/util/marshmallow.py
|
|
@@ -14,7 +14,6 @@ import yaml
|
|
from dateutil import parser, relativedelta
|
|
from marshmallow import Schema, ValidationError, fields
|
|
from marshmallow.utils import from_iso_datetime
|
|
-from marshmallow_enum import EnumField
|
|
from pytz import timezone
|
|
from speaklater import _LazyString
|
|
from sqlalchemy import inspect
|
|
@@ -500,7 +499,7 @@ class LowercaseString(fields.String):
|
|
return super()._deserialize(value, attr, data, **kwargs).lower()
|
|
|
|
|
|
-class NoneValueEnumField(EnumField):
|
|
+class NoneValueEnumField(fields.Enum):
|
|
"""
|
|
Like the normal EnumField, but when receiving a None value,
|
|
this is mapped to a specific enum member.
|
|
diff --git a/requirements.in b/requirements.in
|
|
index 54be3ee..fd12cfa 100644
|
|
--- a/requirements.in
|
|
+++ b/requirements.in
|
|
@@ -36,7 +36,6 @@ lxml[html5]
|
|
markdown
|
|
markupsafe
|
|
marshmallow-dataclass
|
|
-marshmallow-enum
|
|
marshmallow-oneofschema
|
|
marshmallow-sqlalchemy
|
|
marshmallow
|
|
diff --git a/requirements.txt b/requirements.txt
|
|
index e1112a7814..53c2d521de 100644
|
|
--- a/requirements.txt
|
|
+++ b/requirements.txt
|
|
@@ -211,14 +211,11 @@ marshmallow==3.22.0
|
|
# -r requirements.in
|
|
# flask-marshmallow
|
|
# marshmallow-dataclass
|
|
- # marshmallow-enum
|
|
# marshmallow-oneofschema
|
|
# marshmallow-sqlalchemy
|
|
# webargs
|
|
marshmallow-dataclass==8.7.0
|
|
# via -r requirements.in
|
|
-marshmallow-enum==1.5.1
|
|
- # via -r requirements.in
|
|
marshmallow-oneofschema==3.1.1
|
|
# via -r requirements.in
|
|
marshmallow-sqlalchemy==1.1.0
|