mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-28 13:05:26 -05:00
Feature/group based notifications (#918)
* fix group page * setup group notification for backend * update type generators * script to auto-generate schema exports * setup frontend CRUD interface * remove old notifications UI * drop old events api * add test functionality * update naming for fields * add event dispatcher functionality * bump to python 3.10 * bump python version * purge old event code * use-async apprise * set mealie logo as image * unify styles for buttons rows * add links to banners
This commit is contained in:
@@ -1,31 +1,10 @@
|
||||
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
||||
from sqlalchemy import Column, DateTime, Integer, String
|
||||
|
||||
from mealie.db.models._model_base import BaseMixins, SqlAlchemyBase
|
||||
|
||||
from ._model_utils import auto_init
|
||||
|
||||
|
||||
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)
|
||||
|
||||
@auto_init()
|
||||
def __init__(self, **_) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class Event(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "events"
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from .cookbook import *
|
||||
from .events import *
|
||||
from .exports import *
|
||||
from .group import *
|
||||
from .invite_tokens import *
|
||||
|
||||
61
mealie/db/models/group/events.py
Normal file
61
mealie/db/models/group/events.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from sqlalchemy import Boolean, Column, ForeignKey, String, orm
|
||||
|
||||
from .._model_base import BaseMixins, SqlAlchemyBase
|
||||
from .._model_utils import GUID, auto_init
|
||||
|
||||
|
||||
class GroupEventNotifierOptionsModel(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "group_events_notifier_options"
|
||||
|
||||
id = Column(GUID, primary_key=True, default=GUID.generate)
|
||||
event_notifier_id = Column(GUID, ForeignKey("group_events_notifiers.id"), nullable=False)
|
||||
|
||||
recipe_created = Column(Boolean, default=False, nullable=False)
|
||||
recipe_updated = Column(Boolean, default=False, nullable=False)
|
||||
recipe_deleted = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
user_signup = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
data_migrations = Column(Boolean, default=False, nullable=False)
|
||||
data_export = Column(Boolean, default=False, nullable=False)
|
||||
data_import = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
mealplan_entry_created = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
shopping_list_created = Column(Boolean, default=False, nullable=False)
|
||||
shopping_list_updated = Column(Boolean, default=False, nullable=False)
|
||||
shopping_list_deleted = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
cookbook_created = Column(Boolean, default=False, nullable=False)
|
||||
cookbook_updated = Column(Boolean, default=False, nullable=False)
|
||||
cookbook_deleted = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
tag_created = Column(Boolean, default=False, nullable=False)
|
||||
tag_updated = Column(Boolean, default=False, nullable=False)
|
||||
tag_deleted = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
category_created = Column(Boolean, default=False, nullable=False)
|
||||
category_updated = Column(Boolean, default=False, nullable=False)
|
||||
category_deleted = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
@auto_init()
|
||||
def __init__(self, **_) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class GroupEventNotifierModel(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "group_events_notifiers"
|
||||
|
||||
id = Column(GUID, primary_key=True, default=GUID.generate)
|
||||
name = Column(String, nullable=False)
|
||||
enabled = Column(String, default=True, nullable=False)
|
||||
apprise_url = Column(String, nullable=False)
|
||||
|
||||
group = orm.relationship("Group", back_populates="group_event_notifiers", single_parent=True)
|
||||
group_id = Column(GUID, ForeignKey("groups.id"), index=True)
|
||||
|
||||
options = orm.relationship(GroupEventNotifierOptionsModel, uselist=False, cascade="all, delete-orphan")
|
||||
|
||||
@auto_init()
|
||||
def __init__(self, **_) -> None:
|
||||
pass
|
||||
@@ -1,5 +1,3 @@
|
||||
import uuid
|
||||
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.orm as orm
|
||||
from sqlalchemy.orm.session import Session
|
||||
@@ -22,7 +20,7 @@ settings = get_app_settings()
|
||||
|
||||
class Group(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "groups"
|
||||
id = sa.Column(GUID, primary_key=True, default=uuid.uuid4)
|
||||
id = sa.Column(GUID, primary_key=True, default=GUID.generate)
|
||||
name = sa.Column(sa.String, index=True, nullable=False, unique=True)
|
||||
users = orm.relationship("User", back_populates="group")
|
||||
categories = orm.relationship(Category, secondary=group2categories, single_parent=True, uselist=True)
|
||||
@@ -57,6 +55,7 @@ class Group(SqlAlchemyBase, BaseMixins):
|
||||
data_exports = orm.relationship("GroupDataExportsModel", **common_args)
|
||||
shopping_lists = orm.relationship("ShoppingList", **common_args)
|
||||
group_reports = orm.relationship("ReportModel", **common_args)
|
||||
group_event_notifiers = orm.relationship("GroupEventNotifierModel", **common_args)
|
||||
|
||||
class Config:
|
||||
exclude = {
|
||||
|
||||
Reference in New Issue
Block a user