Commit b630fcd
committed
refactor(business): Streamline promo views and data handling
This commit refactors the `business` app's views and serializers to improve efficiency and clarify the logic for handling promo data.
Key changes:
- **Simplified Query Validation:** The `CompanyPromoListCreateView` now validates query parameters directly within the `get_queryset` method, removing the need for an intermediate `list` method override and instance variables.
- **Optimized Target Updates:** The `PromoDetailSerializer` now correctly handles updates to the `target` field by calling the parent `update` method first and then saving the `target` field specifically. This ensures atomicity and prevents unnecessary model saves.
- **Improved QuerySet Definition:** The `PromoManager` now defines `with_related_fields` as a tuple to clearly specify the fields for `only()`, making the query more readable and maintainable.1 parent 9a70256 commit b630fcd
3 files changed
+25
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
25 | 40 | | |
26 | 41 | | |
27 | 42 | | |
28 | 43 | | |
29 | 44 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
| 274 | + | |
276 | 275 | | |
277 | 276 | | |
278 | 277 | | |
| 278 | + | |
279 | 279 | | |
280 | | - | |
281 | 280 | | |
282 | 281 | | |
283 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | 77 | | |
79 | 78 | | |
80 | | - | |
81 | | - | |
82 | 79 | | |
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
87 | 84 | | |
88 | | - | |
| 85 | + | |
89 | 86 | | |
90 | | - | |
| 87 | + | |
91 | 88 | | |
92 | 89 | | |
93 | | - | |
| 90 | + | |
94 | 91 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | 92 | | |
100 | 93 | | |
101 | 94 | | |
| |||
0 commit comments