mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-28 05:05:12 -05:00
Feature/event notifications (#399)
* additional server events * sort 'recent recipes' by updated * remove duplicate code * fixes #396 * set color * consolidate tag/category pages * set colors * list unorganized recipes * cleanup old code * remove flash message, switch to global snackbar * cancel to close * cleanup * notifications first pass * test notification * complete notification feature * use background tasks * add url param * update documentation Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from logging import getLogger
|
||||
|
||||
from mealie.db.db_base import BaseDocument
|
||||
from mealie.db.models.event import Event
|
||||
from mealie.db.models.event import Event, EventNotification
|
||||
from mealie.db.models.group import Group
|
||||
from mealie.db.models.mealplan import MealPlanModel
|
||||
from mealie.db.models.recipe.recipe import Category, RecipeModel, Tag
|
||||
@@ -10,6 +10,7 @@ from mealie.db.models.sign_up import SignUp
|
||||
from mealie.db.models.theme import SiteThemeModel
|
||||
from mealie.db.models.users import LongLiveToken, User
|
||||
from mealie.schema.category import RecipeCategoryResponse, RecipeTagResponse
|
||||
from mealie.schema.event_notifications import EventNotificationIn
|
||||
from mealie.schema.events import Event as EventSchema
|
||||
from mealie.schema.meal import MealPlanInDB
|
||||
from mealie.schema.recipe import Recipe
|
||||
@@ -156,6 +157,13 @@ class _Events(BaseDocument):
|
||||
self.schema = EventSchema
|
||||
|
||||
|
||||
class _EventNotification(BaseDocument):
|
||||
def __init__(self) -> None:
|
||||
self.primary_key = "id"
|
||||
self.sql_model = EventNotification
|
||||
self.schema = EventNotificationIn
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self) -> None:
|
||||
self.recipes = _Recipes()
|
||||
@@ -170,6 +178,7 @@ class Database:
|
||||
self.groups = _Groups()
|
||||
self.custom_pages = _CustomPages()
|
||||
self.events = _Events()
|
||||
self.event_notifications = _EventNotification()
|
||||
|
||||
|
||||
db = Database()
|
||||
|
||||
@@ -1,14 +1,45 @@
|
||||
import sqlalchemy as sa
|
||||
from mealie.db.models.model_base import BaseMixins, SqlAlchemyBase
|
||||
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
||||
|
||||
|
||||
class EventNotification(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "event_notifications"
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String)
|
||||
type = Column(String)
|
||||
notification_url = Column(String)
|
||||
|
||||
# Event Types
|
||||
general = Column(Boolean, default=False)
|
||||
recipe = Column(Boolean, default=False)
|
||||
backup = Column(Boolean, default=False)
|
||||
scheduled = Column(Boolean, default=False)
|
||||
migration = Column(Boolean, default=False)
|
||||
group = Column(Boolean, default=False)
|
||||
user = Column(Boolean, default=False)
|
||||
|
||||
def __init__(
|
||||
self, name, notification_url, type, general, recipe, backup, scheduled, migration, group, user, *args, **kwargs
|
||||
) -> None:
|
||||
self.name = name
|
||||
self.notification_url = notification_url
|
||||
self.type = type
|
||||
self.general = general
|
||||
self.recipe = recipe
|
||||
self.backup = backup
|
||||
self.scheduled = scheduled
|
||||
self.migration = migration
|
||||
self.group = group
|
||||
self.user = user
|
||||
|
||||
|
||||
class Event(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "events"
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
title = sa.Column(sa.String)
|
||||
text = sa.Column(sa.String)
|
||||
time_stamp = sa.Column(sa.DateTime)
|
||||
category = sa.Column(sa.String)
|
||||
id = Column(Integer, primary_key=True)
|
||||
title = Column(String)
|
||||
text = Column(String)
|
||||
time_stamp = Column(DateTime)
|
||||
category = Column(String)
|
||||
|
||||
def __init__(self, title, text, time_stamp, category, *args, **kwargs) -> None:
|
||||
self.title = title
|
||||
|
||||
Reference in New Issue
Block a user