Skip to content

Commit

Permalink
[PORT] Port event_rest_api from OCA to mozaik
Browse files Browse the repository at this point in the history
  • Loading branch information
qgroulard authored and marielejeune committed Sep 19, 2023
1 parent 9e92cff commit 511301e
Show file tree
Hide file tree
Showing 18 changed files with 407 additions and 50 deletions.
4 changes: 3 additions & 1 deletion mozaik_event_rest/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"author": "ACSONE SA/NV",
"website": "https://github.com/OCA/mozaik",
"depends": [
"event_rest_api",
"base_rest",
"base_rest_pydantic",
"event_sale",
"extendable",
"mozaik_address",
"mozaik_ama_indexed_on_website",
"mozaik_event_image",
Expand Down
3 changes: 3 additions & 0 deletions mozaik_event_rest/pydantic_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from . import event_info
from . import event_question_answer
from . import event_question_info
from . import event_registration_info
from . import event_registration_request
from . import event_search_filter
from . import event_stage_info
from . import event_stage_search_filter
from . import event_ticket_info
from . import event_type_info
from . import event_type_search_filter
from . import event_website_domain_info
from . import event_website_domain_search_filter
from . import partner_address_info
Expand Down
34 changes: 27 additions & 7 deletions mozaik_event_rest/pydantic_models/event_info.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from datetime import date
from datetime import date, datetime
from typing import List

import pydantic
from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

from odoo.addons.event_rest_api.pydantic_models.event_info import (
EventInfo as BaseEventInfo,
EventShortInfo as BaseEventShortInfo,
)
from odoo.addons.mozaik_thesaurus_api.pydantic_models.thesaurus_term_info import (
ThesaurusTermInfo,
)
from odoo.addons.pydantic import utils

from .event_question_info import EventQuestionInfo
from .event_stage_info import EventStageInfo
from .event_ticket_info import EventTicketInfo
from .event_type_info import EventTypeInfo
from .event_website_domain_info import EventWebsiteDomainInfo
from .partner_address_info import PartnerAddressInfo
from .partner_minimum_info import PartnerMinimumInfo


class EventShortInfo(BaseEventShortInfo, extends=BaseEventShortInfo):
class EventShortInfo(BaseModel, metaclass=ExtendableModelMeta):

id: int
name: str
date_begin: datetime
date_end: datetime
event_type: EventTypeInfo = pydantic.Field(None, alias="event_type_id")
stage: EventStageInfo = pydantic.Field(None, alias="stage_id")
note: str = None
write_date: datetime
image_url: str
interests: List[ThesaurusTermInfo] = pydantic.Field([], alias="interest_ids")
address: PartnerAddressInfo = pydantic.Field(None, alias="address_id")
Expand All @@ -35,8 +46,17 @@ class EventShortInfo(BaseEventShortInfo, extends=BaseEventShortInfo):
is_published: bool = None
is_headline: bool = None

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter


class EventInfo(EventShortInfo):

class EventInfo(BaseEventInfo, extends=BaseEventInfo):
event_tickets: List[EventTicketInfo] = pydantic.Field([], alias="event_ticket_ids")
seats_limited: bool
seats_max: int = None
seats_expected: int = None
publish_date: date = None
questions: List[EventQuestionInfo] = pydantic.Field([], alias="question_ids")
menu_register_cta: bool = None
Expand Down
29 changes: 29 additions & 0 deletions mozaik_event_rest/pydantic_models/event_registration_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from datetime import datetime

import pydantic
from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

from odoo.addons.pydantic import utils

from .event_info import EventInfo
from .event_ticket_info import EventTicketInfo


class EventRegistrationInfo(BaseModel, metaclass=ExtendableModelMeta):

id: int
partner_id: int = None
firstname: str = None
lastname: str = None
email: str = None
event: EventInfo = pydantic.Field(..., alias="event_id")
event_ticket: EventTicketInfo = pydantic.Field(None, alias="event_ticket_id")
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
22 changes: 12 additions & 10 deletions mozaik_event_rest/pydantic_models/event_registration_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@
from typing import List

import pydantic

from odoo.addons.event_rest_api.pydantic_models.event_registration_request import (
EventRegistrationRequest as BaseEventRegistrationRequest,
)
from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

from .event_question_answer import EventQuestionAnswer


class EventRegistrationRequest(
BaseEventRegistrationRequest, extends=BaseEventRegistrationRequest
):
# firstname, lastname and email are not mandatory anymore since we
# can give registered_partner_id
class EventRegistrationRequest(BaseModel, metaclass=ExtendableModelMeta):

firstname: str = None
lastname: str = None
email: str = None

phone: str = None
mobile: str = None
event_ticket_id: int = None
registered_partner_id: int = None
zip: str = None
answers: List[EventQuestionAnswer] = pydantic.Field([])
force_autoval: bool = False


class EventRegistrationRequestList(BaseModel, metaclass=ExtendableModelMeta):

event_registration_requests: List[EventRegistrationRequest] = []
14 changes: 10 additions & 4 deletions mozaik_event_rest/pydantic_models/event_search_filter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from datetime import datetime
from typing import List

from odoo.addons.event_rest_api.pydantic_models.event_search_filter import (
EventSearchFilter as BaseEventSearchFilter,
)
from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel


class EventSearchFilter(BaseEventSearchFilter, extends=BaseEventSearchFilter):
class EventSearchFilter(BaseModel, metaclass=ExtendableModelMeta):

id: int = None
name: str = None
start_after: datetime = None
end_before: datetime = None
event_type_ids: List[int] = None
stage_ids: List[int] = None
website_domain_ids: List[int] = None
interest_ids: List[int] = None
is_headline: bool = None
20 changes: 16 additions & 4 deletions mozaik_event_rest/pydantic_models/event_stage_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo.addons.event_rest_api.pydantic_models.event_stage_info import (
EventStageInfo as BaseEventStageInfo,
)
from datetime import datetime

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

class EventStageInfo(BaseEventStageInfo, extends=BaseEventStageInfo):
from odoo.addons.pydantic import utils


class EventStageInfo(BaseModel, metaclass=ExtendableModelMeta):
id: int
name: str
sequence: int = None
pipe_end: bool = None
write_date: datetime
draft_stage: bool

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
12 changes: 6 additions & 6 deletions mozaik_event_rest/pydantic_models/event_stage_search_filter.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.addons.event_rest_api.pydantic_models.event_stage_search_filter import (
EventStageSearchFilter as BaseEventStageSearchFilter,
)
from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel


class EventStageSearchFilter(
BaseEventStageSearchFilter, extends=BaseEventStageSearchFilter
):
class EventStageSearchFilter(BaseModel, metaclass=ExtendableModelMeta):

id: int = None
name: str = None
pipe_end: bool = None
draft_stage: bool = None
23 changes: 19 additions & 4 deletions mozaik_event_rest/pydantic_models/event_ticket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo.addons.event_rest_api.pydantic_models.event_ticket_info import (
EventTicketInfo as BaseEventTicketInfo,
)
from datetime import date, datetime

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

class EventTicketInfo(BaseEventTicketInfo, extends=BaseEventTicketInfo):
from odoo.addons.pydantic import utils


class EventTicketInfo(BaseModel, metaclass=ExtendableModelMeta):
id: int
event_id: int
name: str
description: str = None
start_sale_date: date = None
end_sale_date: date = None
seats_available: int = None
write_date: datetime
price: float = None

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
19 changes: 19 additions & 0 deletions mozaik_event_rest/pydantic_models/event_type_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from datetime import datetime

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

from odoo.addons.pydantic import utils


class EventTypeInfo(BaseModel, metaclass=ExtendableModelMeta):
id: int
name: str
write_date: datetime

class Config:
orm_mode = True
getter_dict = utils.GenericOdooGetter
11 changes: 11 additions & 0 deletions mozaik_event_rest/pydantic_models/event_type_search_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel


class EventTypeSearchFilter(BaseModel, metaclass=ExtendableModelMeta):

id: int = None
name: str = None
2 changes: 2 additions & 0 deletions mozaik_event_rest/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from . import service
from . import event_stage
from . import event_type
from . import event_website_domain
from . import event
Loading

0 comments on commit 511301e

Please sign in to comment.