4 | | Jobs.objects.annotate( |
5 | | worker_preference=FilteredRelation( |
6 | | relation_name="company__workerpreference", |
7 | | condition=Q( |
8 | | company__workerpreference__worker=Coalesce(F("worker"), F("substitute__worker")), |
9 | | company__workerpreference__company=F("company"), |
10 | | ) |
11 | | ) |
| 4 | job_worker_preference=FilteredRelation( |
| 5 | relation_name="company__worker_preferences", |
| 6 | condition=Q( |
| 7 | company__worker_preferences__worker=Coalesce(F("worker"), F("worker_substitutions__worker")), |
| 8 | company__worker_preferences__company=F("company"), |
| 9 | ) |
| 10 | ), |
| 11 | is_allowed=Case(When(job_worker_preference__allow_assignments=True, then=1), default=0, output_field=BooleanField()) |
17 | | Jobs.objects.annotate( |
18 | | actual_worker=Coalesce(F("worker"), F("substitute__worker")), |
19 | | worker_preference=FilteredRelation( |
20 | | relation_name="company__workerpreference", |
21 | | condition=Q( |
22 | | company__workerpreference__worker=F("actual_worker"), |
23 | | company__workerpreference__company=F("company"), |
24 | | ) |
25 | | ) |
| 17 | actual_worker=Coalesce(F("worker"), F("worker_substitutions__worker")), |
| 18 | job_worker_preference=FilteredRelation( |
| 19 | relation_name="company__worker_preferences", |
| 20 | condition=Q( |
| 21 | company__worker_preferences__worker=F("actual_worker"), |
| 22 | company__worker_preferences__company=F("company"), |
| 23 | ) |
| 24 | ), |
| 25 | is_allowed=Case(When(job_worker_preference__allow_assignments=True, then=1), default=0, output_field=BooleanField()) |