Add ignore_subscription functionality for events
This commit is contained in:
@@ -22,7 +22,19 @@ def upgrade() -> None:
|
|||||||
"""Upgrade schema."""
|
"""Upgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.add_column(
|
op.add_column(
|
||||||
"event", sa.Column("subscriptions_applied", sa.Boolean(), nullable=False)
|
"event",
|
||||||
|
sa.Column(
|
||||||
|
"subscriptions_applied",
|
||||||
|
sa.Boolean(),
|
||||||
|
nullable=False,
|
||||||
|
server_default="false",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
op.add_column(
|
||||||
|
"event",
|
||||||
|
sa.Column(
|
||||||
|
"ignore_subscriptions", sa.Boolean(), nullable=False, server_default="true"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
@@ -31,4 +43,5 @@ def downgrade() -> None:
|
|||||||
"""Downgrade schema."""
|
"""Downgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_column("event", "subscriptions_applied")
|
op.drop_column("event", "subscriptions_applied")
|
||||||
|
op.drop_column("event", "ignore_subscriptions")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ async def edit_event(
|
|||||||
event.registration_deadline = registration_deadline
|
event.registration_deadline = registration_deadline
|
||||||
event.description = form_data.get("eventDescription")
|
event.description = form_data.get("eventDescription")
|
||||||
event.recipe_link = form_data.get("recipeLink")
|
event.recipe_link = form_data.get("recipeLink")
|
||||||
|
event.ignore_subscriptions = form_data.get("ignoreSubscriptions") == "on"
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@@ -257,6 +258,7 @@ async def add_event(request: Request, session: SessionDep, user: StrictUserDep):
|
|||||||
registration_deadline=registration_deadline,
|
registration_deadline=registration_deadline,
|
||||||
description=form_data.get("eventDescription"),
|
description=form_data.get("eventDescription"),
|
||||||
recipe_link=form_data.get("recipeLink"),
|
recipe_link=form_data.get("recipeLink"),
|
||||||
|
ignore_subscriptions=form_data.get("ignoreSubscriptions") == "on",
|
||||||
)
|
)
|
||||||
session.add(event)
|
session.add(event)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class Event(Base):
|
|||||||
team_prep_max: Mapped[int] = mapped_column(default=1, nullable=False)
|
team_prep_max: Mapped[int] = mapped_column(default=1, nullable=False)
|
||||||
|
|
||||||
subscriptions_applied: Mapped[bool] = mapped_column(default=False, nullable=False)
|
subscriptions_applied: Mapped[bool] = mapped_column(default=False, nullable=False)
|
||||||
|
ignore_subscriptions: Mapped[bool] = mapped_column(default=False, nullable=False)
|
||||||
|
|
||||||
registrations: Mapped[list["Registration"]] = relationship(
|
registrations: Mapped[list["Registration"]] = relationship(
|
||||||
"Registration", cascade="all, delete"
|
"Registration", cascade="all, delete"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ def apply_subscriptions(session: Session, event: Event = None, dry_run: bool = F
|
|||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
query = select(Event).where(
|
query = select(Event).where(
|
||||||
~Event.subscriptions_applied,
|
~Event.subscriptions_applied,
|
||||||
|
~Event.ignore_subscriptions,
|
||||||
func.strftime("%Y-%m-%d %H:%M:%S", Event.event_time) >= today.isoformat(),
|
func.strftime("%Y-%m-%d %H:%M:%S", Event.event_time) >= today.isoformat(),
|
||||||
func.strftime("%Y-%m-%d %H:%M:%S", Event.event_time)
|
func.strftime("%Y-%m-%d %H:%M:%S", Event.event_time)
|
||||||
<= (today + datetime.timedelta(days=7)).isoformat(),
|
<= (today + datetime.timedelta(days=7)).isoformat(),
|
||||||
|
|||||||
@@ -30,6 +30,15 @@
|
|||||||
<label for="eventDescription" class="form-label">Beschreibung</label>
|
<label for="eventDescription" class="form-label">Beschreibung</label>
|
||||||
<textarea class="form-control" id="eventDescription" name="eventDescription" rows="3" {% if edit_mode %}value="{{ event.description }}"{% endif %}></textarea>
|
<textarea class="form-control" id="eventDescription" name="eventDescription" rows="3" {% if edit_mode %}value="{{ event.description }}"{% endif %}></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" id="ignoreSubscriptions" name="ignoreSubscriptions" {% if (edit_mode and event.ignore_subscriptions) or not edit_mode %}checked{% endif %}>
|
||||||
|
<label class="form-check-label" for="ignoreSubscriptions">Dauerhafte Anmeldung ignorieren</label>
|
||||||
|
<small class="form-text text-muted">
|
||||||
|
Aktivieren, um dauerhafte Anmeldungen für dieses Event zu ignorieren. Das sollte für alle Events getan werden, die keine offiziellen AG Kochen Kochabende sind.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Event {% if edit_mode %}bearbeiten{% else %}erstellen{% endif %}</button>
|
<button type="submit" class="btn btn-primary">Event {% if edit_mode %}bearbeiten{% else %}erstellen{% endif %}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user