Commit d33d22e
authored
Merge pull request #58 from RandomProgramm3r/develop
refactor(core, business): unify pagination and promo serializers with enhanced validation
Introduces a shared pagination serializer and consolidates promo-related serializers,
validation logic, and country-code handling to improve structure, DRY-ness, and maintainability.
Key changes:
- **Core pagination**
- Add `BaseLimitOffsetPaginationSerializer` to centralize `limit`/`offset` validation for all endpoints.
- **Promo serializers overhaul**
- Collapse `PromoValidator` into serializers to co‑locate validation and data representation.
- Create `BasePromoSerializer` to extract common fields and methods, reducing duplication across create, detail, and read-only serializers.
- Implement `CountryField` and `MultiCountryField` for reusable ISO 3166‑1 α‑2 code validation.
- Simplify `PromoListQuerySerializer` by inheriting from the base pagination serializer and using `MultiCountryField`.
- **Enhanced promo validation**
- Support partial updates (`PATCH`), inferring `mode` from instance when absent in request data.
- Prevent lowering `max_count` below the current `used_count`.
- Ensure `get_used_codes_count` returns accurate counts for `COMMON`‑mode promotions.File tree
5 files changed
+284
-354
lines changed- promo_code
- business
- core
5 files changed
+284
-354
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
| 122 | + | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
| |||
0 commit comments