mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-08 19:35:14 -05:00
feat: additional events dispatch (#1999)
* formatting * add new user type * add registration event * publish events on new mealplan * update UI for supported types + type updates
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from datetime import date, datetime
|
||||
from enum import Enum, auto
|
||||
from typing import Any
|
||||
|
||||
@@ -57,6 +57,8 @@ class EventTypes(Enum):
|
||||
class EventDocumentType(Enum):
|
||||
generic = "generic"
|
||||
|
||||
user = "user"
|
||||
|
||||
category = "category"
|
||||
cookbook = "cookbook"
|
||||
mealplan = "mealplan"
|
||||
@@ -82,6 +84,23 @@ class EventDocumentDataBase(MealieModel):
|
||||
...
|
||||
|
||||
|
||||
class EventMealplanCreatedData(EventDocumentDataBase):
|
||||
document_type = EventDocumentType.mealplan
|
||||
operation = EventOperation.create
|
||||
mealplan_id: int
|
||||
date: date
|
||||
recipe_id: UUID4 | None
|
||||
recipe_name: str | None
|
||||
recipe_slug: str | None
|
||||
|
||||
|
||||
class EventUserSignupData(EventDocumentDataBase):
|
||||
document_type = EventDocumentType.user
|
||||
operation = EventOperation.create
|
||||
username: str
|
||||
email: str
|
||||
|
||||
|
||||
class EventCategoryData(EventDocumentDataBase):
|
||||
document_type = EventDocumentType.category
|
||||
category_id: UUID4
|
||||
|
||||
@@ -70,7 +70,6 @@ class RegistrationService:
|
||||
if registration.group:
|
||||
new_group = True
|
||||
group = self._register_new_group()
|
||||
|
||||
elif registration.group_token and registration.group_token != "":
|
||||
token_entry = self.repos.group_invite_tokens.get_one(registration.group_token)
|
||||
if not token_entry:
|
||||
@@ -88,9 +87,7 @@ class RegistrationService:
|
||||
user = self._create_new_user(group, new_group)
|
||||
|
||||
if new_group and registration.seed_data:
|
||||
|
||||
seeder_service = SeederService(self.repos, user, group)
|
||||
|
||||
seeder_service.seed_foods(registration.locale)
|
||||
seeder_service.seed_labels(registration.locale)
|
||||
seeder_service.seed_units(registration.locale)
|
||||
|
||||
Reference in New Issue
Block a user