f3-data-models 0.1.10__py3-none-any.whl → 0.1.12__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,13 @@ 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
+ locations (Optional[List[Location]]): The locations associated with the organization. Probably only relevant for regions.
284
+ 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.
285
+ 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.
286
+ achievements (Optional[List[Achievement]]): The achievements available within the organization.
287
+ parent_org (Optional[Org]): The parent organization.
288
+ event_tags_x_org (Optional[List[EventTag_x_Org]]): The association between event tags and organizations.
282
289
  """
283
290
 
284
291
  __tablename__ = "orgs"
@@ -301,6 +308,9 @@ class Org(Base):
301
308
  created: Mapped[dt_create]
302
309
  updated: Mapped[dt_update]
303
310
 
311
+ locations: Mapped[Optional[List["Location"]]] = relationship(
312
+ "Location", cascade="expunge"
313
+ )
304
314
  event_types: Mapped[Optional[List["EventType"]]] = relationship(
305
315
  "EventType", secondary="event_types_x_org", cascade="expunge"
306
316
  )
@@ -313,6 +323,9 @@ class Org(Base):
313
323
  parent_org: Mapped[Optional["Org"]] = relationship(
314
324
  "Org", remote_side=[id], cascade="expunge"
315
325
  )
326
+ event_tags_x_org: Mapped[Optional[List["EventTag_x_Org"]]] = relationship(
327
+ "EventTag_x_Org", cascade="expunge"
328
+ )
316
329
 
317
330
 
318
331
  class EventType(Base):
@@ -347,6 +360,8 @@ class EventType_x_Event(Base):
347
360
  Attributes:
348
361
  event_id (int): The ID of the associated event.
349
362
  event_type_id (int): The ID of the associated event type.
363
+
364
+ event (Event): The associated event.
350
365
  """
351
366
 
352
367
  __tablename__ = "events_x_event_types"
@@ -356,6 +371,8 @@ class EventType_x_Event(Base):
356
371
  ForeignKey("event_types.id"), primary_key=True
357
372
  )
358
373
 
374
+ event: Mapped["Event"] = relationship(back_populates="event_x_event_types")
375
+
359
376
 
360
377
  class EventType_x_Org(Base):
361
378
  """
@@ -406,6 +423,8 @@ class EventTag_x_Event(Base):
406
423
  Attributes:
407
424
  event_id (int): The ID of the associated event.
408
425
  event_tag_id (int): The ID of the associated event tag.
426
+
427
+ event (Event): The associated event.
409
428
  """
410
429
 
411
430
  __tablename__ = "event_tags_x_events"
@@ -415,6 +434,8 @@ class EventTag_x_Event(Base):
415
434
  ForeignKey("event_tags.id"), primary_key=True
416
435
  )
417
436
 
437
+ event: Mapped["Event"] = relationship(back_populates="event_x_event_tags")
438
+
418
439
 
419
440
  class EventTag_x_Org(Base):
420
441
  """
@@ -526,6 +547,13 @@ class Event(Base):
526
547
  meta (Optional[Dict[str, Any]]): Additional metadata for the event.
527
548
  created (datetime): The timestamp when the record was created.
528
549
  updated (datetime): The timestamp when the record was last updated.
550
+
551
+ org (Org): The associated organization.
552
+ location (Location): The associated location.
553
+ event_types (List[EventType]): The associated event types.
554
+ event_tags (Optional[List[EventTag]]): The associated event tags.
555
+ event_x_event_types (List[EventType_x_Event]): The association between the event and event types.
556
+ event_x_event_tags (Optional[List[EventTag_x_Event]]): The association between the event and event tags.
529
557
  """
530
558
 
531
559
  __tablename__ = "events"
@@ -559,13 +587,24 @@ class Event(Base):
559
587
  created: Mapped[dt_create]
560
588
  updated: Mapped[dt_update]
561
589
 
562
- org: Mapped[Org] = relationship(innerjoin=True, cascade="expunge")
563
- location: Mapped[Location] = relationship(innerjoin=True, cascade="expunge")
590
+ org: Mapped[Org] = relationship(innerjoin=True, cascade="expunge", viewonly=True)
591
+ location: Mapped[Location] = relationship(
592
+ innerjoin=True, cascade="expunge", viewonly=True
593
+ )
564
594
  event_types: Mapped[List[EventType]] = relationship(
565
- secondary="events_x_event_types", innerjoin=True, cascade="expunge"
595
+ secondary="events_x_event_types",
596
+ innerjoin=True,
597
+ cascade="expunge",
598
+ viewonly=True,
566
599
  )
567
600
  event_tags: Mapped[Optional[List[EventTag]]] = relationship(
568
- secondary="event_tags_x_events", cascade="expunge"
601
+ secondary="event_tags_x_events", cascade="expunge", viewonly=True
602
+ )
603
+ event_x_event_types: Mapped[List[EventType_x_Event]] = relationship(
604
+ back_populates="event"
605
+ )
606
+ event_x_event_tags: Mapped[Optional[List[EventTag_x_Event]]] = relationship(
607
+ back_populates="event"
569
608
  )
570
609
 
571
610
 
@@ -587,13 +626,15 @@ class AttendanceType(Base):
587
626
  updated: Mapped[dt_update]
588
627
 
589
628
 
590
- class Attendance_x_AttenanceType(Base):
629
+ class Attendance_x_AttendanceType(Base):
591
630
  """
592
631
  Model representing the association between attendance and attendance types.
593
632
 
594
633
  Attributes:
595
634
  attendance_id (int): The ID of the associated attendance.
596
635
  attendance_type_id (int): The ID of the associated attendance type.
636
+
637
+ attendance (Attendance): The associated attendance.
597
638
  """
598
639
 
599
640
  __tablename__ = "attendance_x_attendance_types"
@@ -605,6 +646,10 @@ class Attendance_x_AttenanceType(Base):
605
646
  ForeignKey("attendance_types.id"), primary_key=True
606
647
  )
607
648
 
649
+ attendance: Mapped["Attendance"] = relationship(
650
+ back_populates="attendance_x_attendance_types"
651
+ )
652
+
608
653
 
609
654
  class User(Base):
610
655
  """
@@ -701,6 +746,12 @@ class Attendance(Base):
701
746
  meta (Optional[Dict[str, Any]]): Additional metadata for the attendance.
702
747
  created (datetime): The timestamp when the record was created.
703
748
  updated (datetime): The timestamp when the record was last updated.
749
+
750
+ event (Event): The associated event.
751
+ user (User): The associated user.
752
+ slack_user (Optional[SlackUser]): The associated Slack user.
753
+ attendance_x_attendance_types (List[Attendance_x_AttendanceType]): The association between the attendance and attendance types.
754
+ attendance_types (List[AttendanceType]): The associated attendance types.
704
755
  """
705
756
 
706
757
  __tablename__ = "attendance"
@@ -714,10 +765,21 @@ class Attendance(Base):
714
765
  created: Mapped[dt_create]
715
766
  updated: Mapped[dt_update]
716
767
 
717
- event: Mapped[Event] = relationship(innerjoin=True, cascade="expunge")
768
+ event: Mapped[Event] = relationship(
769
+ innerjoin=True, cascade="expunge", viewonly=True
770
+ )
718
771
  user: Mapped[User] = relationship(innerjoin=True, cascade="expunge", viewonly=True)
719
772
  slack_user: Mapped[Optional[SlackUser]] = relationship(
720
- innerjoin=False, cascade="expunge", secondary="users"
773
+ innerjoin=False, cascade="expunge", secondary="users", viewonly=True
774
+ )
775
+ attendance_x_attendance_types: Mapped[List[Attendance_x_AttendanceType]] = (
776
+ relationship(back_populates="attendance")
777
+ )
778
+ attendance_types: Mapped[List[AttendanceType]] = relationship(
779
+ secondary="attendance_x_attendance_types",
780
+ innerjoin=True,
781
+ cascade="expunge",
782
+ viewonly=True,
721
783
  )
722
784
 
723
785
 
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.12
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=UjkF7RnOsAnIPPIY8YCzOHWMRrq5ixL0_Tzee3LZ_0Y,36999
3
+ f3_data_models/utils.py,sha256=Ytyjn6DScRw0bxkEea_RfAgeUV3Q5I22FuT0O7aizCs,8764
4
+ f3_data_models-0.1.12.dist-info/METADATA,sha256=ARvUizpQnSJI_NH__DvWcgUhhrLJjCf7RMzZdZwwH_4,2714
5
+ f3_data_models-0.1.12.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
6
+ f3_data_models-0.1.12.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,,