wbcrm 1.49.3__py2.py3-none-any.whl → 1.49.4__py2.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.

Potentially problematic release.


This version of wbcrm might be problematic. Click here for more details.

@@ -9,7 +9,7 @@ from celery import shared_task
9
9
  from dateutil.rrule import rrulestr
10
10
  from django.conf import settings
11
11
  from django.db import models, transaction
12
- from django.db.models import Q
12
+ from django.db.models import Exists, OuterRef, Q
13
13
  from django.db.models.query import QuerySet
14
14
  from django.db.models.signals import m2m_changed, post_delete, post_save
15
15
  from django.dispatch import receiver
@@ -687,6 +687,20 @@ class Activity(Recurrence):
687
687
  self.last_event_id = last_event.id
688
688
  self.save()
689
689
 
690
+ def get_participants_for_employer(self, employer: Entry) -> QuerySet[Person]:
691
+ rels = (
692
+ ActivityParticipant.objects.filter(activity=self)
693
+ .annotate(
694
+ is_employee=Exists(
695
+ EmployerEmployeeRelationship.objects.filter(
696
+ employee=OuterRef("participant"), employer=employer, primary=True
697
+ )
698
+ )
699
+ )
700
+ .filter(is_employee=True)
701
+ )
702
+ return Person.objects.filter(id__in=rels.values("participant"))
703
+
690
704
  @staticmethod
691
705
  def get_inrange_activities(
692
706
  queryset: QuerySet["Activity"], start_date: date, end_date: date
@@ -857,7 +871,7 @@ def m2m_changed_companies(sender, instance: Activity, action: str, pk_set: set[i
857
871
  entry = Entry.objects.get(id=company_id)
858
872
  if action == "post_add":
859
873
  instance.entities.add(entry)
860
- elif not instance.participants.annotate_all().filter(primary_employer=company_id).exists():
874
+ elif not instance.get_participants_for_employer(entry).exists():
861
875
  instance.entities.remove(entry)
862
876
  if action == "post_add":
863
877
  for company_id in pk_set:
@@ -1099,12 +1113,7 @@ class ActivityParticipant(models.Model):
1099
1113
  with suppress(EmployerEmployeeRelationship.DoesNotExist):
1100
1114
  rel = EmployerEmployeeRelationship.objects.get(employee=self.participant, primary=True)
1101
1115
  # delete only if no other participants are of the same company
1102
- if (
1103
- not self.activity.participants.annotate_all()
1104
- .exclude(id=rel.employee.id)
1105
- .filter(primary_employer=rel.employer)
1106
- .exists()
1107
- ):
1116
+ if not self.activity.get_participants_for_employer(rel.employer).exclude(id=rel.employee.id).exists():
1108
1117
  self.activity.companies.remove(rel.employer)
1109
1118
  self.activity.entities.remove(rel.employer.entry_ptr)
1110
1119
  if self.activity.is_active:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbcrm
3
- Version: 1.49.3
3
+ Version: 1.49.4
4
4
  Summary: A workbench module that contains all the functionality related to a customer relationship management.
5
5
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
6
6
  Requires-Dist: django-eventtools==1.*
@@ -47,7 +47,7 @@ wbcrm/migrations/0017_event.py,sha256=PzhAVAa2z4itzctQBz-6i__aRDh3TDe029F8leE34W
47
47
  wbcrm/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  wbcrm/models/__init__.py,sha256=23U2eBeZStYgUKSGfi3q88JtfqfbNTk7MbnLEAGw1gk,287
49
49
  wbcrm/models/accounts.py,sha256=Wtr8QtHWSnkVmbdZqY64kQJaZ5UDqSfkIKSUaqxBirI,25435
50
- wbcrm/models/activities.py,sha256=ouCAB_X-ZYRaSHLbstl4YGsPFWOUOLxE1K0Y18skgnk,53844
50
+ wbcrm/models/activities.py,sha256=8d7cVN2lrfJI5XFarfSTnqazTXjHKuh_XZ-PJZKX-q4,54280
51
51
  wbcrm/models/events.py,sha256=jUHArKuZlPzMXpzwrtxM0fI6POF2-ETybtphjPQxqqA,393
52
52
  wbcrm/models/groups.py,sha256=UFGQ1JXvVq_IMZ5nmEBha01wozilRTbPpjaqfjHvEw8,4301
53
53
  wbcrm/models/products.py,sha256=q7BOU3hPGZwolVfOPkkAFhGYYBRDGHU8ldKui9FAMPQ,2472
@@ -170,6 +170,6 @@ wbcrm/viewsets/titles/products.py,sha256=cFAK5zljjybabk2U0KzPT2PVfV5vmO_UlJd6QlI
170
170
  wbcrm/viewsets/titles/utils.py,sha256=IaHQTmEG2OwIHS1bRv7sjuT950wefUJNi3yvPdrpNEs,1144
171
171
  wbcrm/workflows/__init__.py,sha256=biwXXPkVJugT9Vc1cwbInAUY8EnVmOauxdPz7e_2w_A,32
172
172
  wbcrm/workflows/assignee_methods.py,sha256=L7ymErtcpFgXdTMTj_lDOVJqsLAGLNT6qMlrkHGuXWM,999
173
- wbcrm-1.49.3.dist-info/METADATA,sha256=76pjfFrsbYMtTHnD_VTRlM4lEP-Iz-zGtRA7cwXs1bU,450
174
- wbcrm-1.49.3.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
175
- wbcrm-1.49.3.dist-info/RECORD,,
173
+ wbcrm-1.49.4.dist-info/METADATA,sha256=4LJQhv-6oeKQe5-F_VYOesmKRJN2HZ5EhltptWJTM9M,450
174
+ wbcrm-1.49.4.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
175
+ wbcrm-1.49.4.dist-info/RECORD,,
File without changes