f3-data-models 0.1.10__py3-none-any.whl → 0.1.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
f3_data_models/models.py CHANGED
@@ -279,6 +279,11 @@ class Org(Base):
279
279
  meta (Optional[Dict[str, Any]]): Additional metadata for the organization.
280
280
  created (datetime): The timestamp when the record was created.
281
281
  updated (datetime): The timestamp when the record was last updated.
282
+
283
+ event_types (Optional[List[EventType]]): The event types associated with the organization. Used to control which event types are available for selection at the region level.
284
+ event_tags (Optional[List[EventTag]]): The event tags associated with the organization. Used to control which event tags are available for selection at the region level.
285
+ achievements (Optional[List[Achievement]]): The achievements available within the organization.
286
+ parent_org (Optional[Org]): The parent organization.
282
287
  """
283
288
 
284
289
  __tablename__ = "orgs"
@@ -347,6 +352,8 @@ class EventType_x_Event(Base):
347
352
  Attributes:
348
353
  event_id (int): The ID of the associated event.
349
354
  event_type_id (int): The ID of the associated event type.
355
+
356
+ event (Event): The associated event.
350
357
  """
351
358
 
352
359
  __tablename__ = "events_x_event_types"
@@ -356,6 +363,8 @@ class EventType_x_Event(Base):
356
363
  ForeignKey("event_types.id"), primary_key=True
357
364
  )
358
365
 
366
+ event: Mapped["Event"] = relationship(back_populates="event_x_event_types")
367
+
359
368
 
360
369
  class EventType_x_Org(Base):
361
370
  """
@@ -406,6 +415,8 @@ class EventTag_x_Event(Base):
406
415
  Attributes:
407
416
  event_id (int): The ID of the associated event.
408
417
  event_tag_id (int): The ID of the associated event tag.
418
+
419
+ event (Event): The associated event.
409
420
  """
410
421
 
411
422
  __tablename__ = "event_tags_x_events"
@@ -415,6 +426,8 @@ class EventTag_x_Event(Base):
415
426
  ForeignKey("event_tags.id"), primary_key=True
416
427
  )
417
428
 
429
+ event: Mapped["Event"] = relationship(back_populates="event_x_event_tags")
430
+
418
431
 
419
432
  class EventTag_x_Org(Base):
420
433
  """
@@ -526,6 +539,13 @@ class Event(Base):
526
539
  meta (Optional[Dict[str, Any]]): Additional metadata for the event.
527
540
  created (datetime): The timestamp when the record was created.
528
541
  updated (datetime): The timestamp when the record was last updated.
542
+
543
+ org (Org): The associated organization.
544
+ location (Location): The associated location.
545
+ event_types (List[EventType]): The associated event types.
546
+ event_tags (Optional[List[EventTag]]): The associated event tags.
547
+ event_x_event_types (List[EventType_x_Event]): The association between the event and event types.
548
+ event_x_event_tags (Optional[List[EventTag_x_Event]]): The association between the event and event tags.
529
549
  """
530
550
 
531
551
  __tablename__ = "events"
@@ -559,13 +579,24 @@ class Event(Base):
559
579
  created: Mapped[dt_create]
560
580
  updated: Mapped[dt_update]
561
581
 
562
- org: Mapped[Org] = relationship(innerjoin=True, cascade="expunge")
563
- location: Mapped[Location] = relationship(innerjoin=True, cascade="expunge")
582
+ org: Mapped[Org] = relationship(innerjoin=True, cascade="expunge", viewonly=True)
583
+ location: Mapped[Location] = relationship(
584
+ innerjoin=True, cascade="expunge", viewonly=True
585
+ )
564
586
  event_types: Mapped[List[EventType]] = relationship(
565
- secondary="events_x_event_types", innerjoin=True, cascade="expunge"
587
+ secondary="events_x_event_types",
588
+ innerjoin=True,
589
+ cascade="expunge",
590
+ viewonly=True,
566
591
  )
567
592
  event_tags: Mapped[Optional[List[EventTag]]] = relationship(
568
- secondary="event_tags_x_events", cascade="expunge"
593
+ secondary="event_tags_x_events", cascade="expunge", viewonly=True
594
+ )
595
+ event_x_event_types: Mapped[List[EventType_x_Event]] = relationship(
596
+ back_populates="event"
597
+ )
598
+ event_x_event_tags: Mapped[Optional[List[EventTag_x_Event]]] = relationship(
599
+ back_populates="event"
569
600
  )
570
601
 
571
602
 
@@ -587,13 +618,15 @@ class AttendanceType(Base):
587
618
  updated: Mapped[dt_update]
588
619
 
589
620
 
590
- class Attendance_x_AttenanceType(Base):
621
+ class Attendance_x_AttendanceType(Base):
591
622
  """
592
623
  Model representing the association between attendance and attendance types.
593
624
 
594
625
  Attributes:
595
626
  attendance_id (int): The ID of the associated attendance.
596
627
  attendance_type_id (int): The ID of the associated attendance type.
628
+
629
+ attendance (Attendance): The associated attendance.
597
630
  """
598
631
 
599
632
  __tablename__ = "attendance_x_attendance_types"
@@ -605,6 +638,10 @@ class Attendance_x_AttenanceType(Base):
605
638
  ForeignKey("attendance_types.id"), primary_key=True
606
639
  )
607
640
 
641
+ attendance: Mapped["Attendance"] = relationship(
642
+ back_populates="attendance_x_attendance_types"
643
+ )
644
+
608
645
 
609
646
  class User(Base):
610
647
  """
@@ -701,6 +738,12 @@ class Attendance(Base):
701
738
  meta (Optional[Dict[str, Any]]): Additional metadata for the attendance.
702
739
  created (datetime): The timestamp when the record was created.
703
740
  updated (datetime): The timestamp when the record was last updated.
741
+
742
+ event (Event): The associated event.
743
+ user (User): The associated user.
744
+ slack_user (Optional[SlackUser]): The associated Slack user.
745
+ attendance_x_attendance_types (List[Attendance_x_AttendanceType]): The association between the attendance and attendance types.
746
+ attendance_types (List[AttendanceType]): The associated attendance types.
704
747
  """
705
748
 
706
749
  __tablename__ = "attendance"
@@ -714,10 +757,21 @@ class Attendance(Base):
714
757
  created: Mapped[dt_create]
715
758
  updated: Mapped[dt_update]
716
759
 
717
- event: Mapped[Event] = relationship(innerjoin=True, cascade="expunge")
760
+ event: Mapped[Event] = relationship(
761
+ innerjoin=True, cascade="expunge", viewonly=True
762
+ )
718
763
  user: Mapped[User] = relationship(innerjoin=True, cascade="expunge", viewonly=True)
719
764
  slack_user: Mapped[Optional[SlackUser]] = relationship(
720
- innerjoin=False, cascade="expunge", secondary="users"
765
+ innerjoin=False, cascade="expunge", secondary="users", viewonly=True
766
+ )
767
+ attendance_x_attendance_types: Mapped[List[Attendance_x_AttendanceType]] = (
768
+ relationship(back_populates="attendance")
769
+ )
770
+ attendance_types: Mapped[List[AttendanceType]] = relationship(
771
+ secondary="attendance_x_attendance_types",
772
+ innerjoin=True,
773
+ cascade="expunge",
774
+ viewonly=True,
721
775
  )
722
776
 
723
777
 
f3_data_models/utils.py CHANGED
@@ -56,7 +56,7 @@ def get_engine(echo=False) -> Engine:
56
56
  return engine
57
57
 
58
58
 
59
- def get_session(echo=False):
59
+ def get_session(echo=True):
60
60
  if GLOBAL_SESSION:
61
61
  return GLOBAL_SESSION
62
62
 
@@ -254,10 +254,16 @@ class DbManager:
254
254
  session.commit()
255
255
  close_session(session)
256
256
 
257
- def delete_records(cls: T, filters):
257
+ def delete_records(cls: T, filters, joinedloads: List | str = []):
258
258
  session = get_session()
259
259
  try:
260
- session.query(cls).filter(and_(*filters)).delete()
260
+ query = select(cls)
261
+ query = _joinedloads(cls, query, joinedloads)
262
+ query = query.filter(*filters)
263
+ records = session.scalars(query).unique().all()
264
+ for r in records:
265
+ session.delete(r)
266
+ # session.query(cls).filter(and_(*filters)).delete()
261
267
  session.flush()
262
268
  finally:
263
269
  session.commit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: f3-data-models
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: The data schema and models for F3 Nation applications.
5
5
  Home-page: https://github.com/F3-Nation/f3-data-models
6
6
  License: MIT
@@ -0,0 +1,6 @@
1
+ f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ f3_data_models/models.py,sha256=UV-O8z6pciSD9ZmBv-X95p4We1RX0elRFlW2aenTt2s,36517
3
+ f3_data_models/utils.py,sha256=Ytyjn6DScRw0bxkEea_RfAgeUV3Q5I22FuT0O7aizCs,8764
4
+ f3_data_models-0.1.11.dist-info/METADATA,sha256=Zs1LWDl6jEuVFQt8a2IvzBsl0CVMKMMtkQ9vMzPqDc4,2714
5
+ f3_data_models-0.1.11.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
6
+ f3_data_models-0.1.11.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- f3_data_models/models.py,sha256=hE9vj_orXwtJn0y7tatQ61aK0Dnppyuw-8Xxi6jC53M,34017
3
- f3_data_models/utils.py,sha256=Jw9YPAfKhsBYZWYilPO87mzrkuZbzDK-NNRBe9ojOsQ,8476
4
- f3_data_models-0.1.10.dist-info/METADATA,sha256=4gp_tNF0q5lyEpegprWa-tq2AbIoBaCUUpEzI4pRbqc,2714
5
- f3_data_models-0.1.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
6
- f3_data_models-0.1.10.dist-info/RECORD,,