Commit 801fe45
authored
Merge pull request #62 from RandomProgramm3r/develop
refactor(user, validators): extract PromoActivationService & simplify password validators
This commit consolidates and improves core user-related logic by:
- Extracting promo code activation functionality from `PromoActivateView` into a new `PromoActivationService` in `user/services.py`, which now handles:
- User targeting (age, country) checks
- Promo active status verification
- Anti‑fraud validation
- Atomic issuance for common and unique promo codes
- Granular exceptions (`PromoActivationError`, `TargetingError`, etc.) for clearer API error responses
- Simplifying password validation by:
- Removing the `BaseCountPasswordValidator` abstract class in favor of standalone validators
- Renaming classes for brevity (e.g. `AsciiValidator`, `UppercaseValidator`)
- Leveraging built‑in methods like `isascii()` and `isupper()` for clarity and performance
- Using `ngettext` to enhance internationalized, pluralized error messages
- Updating `settings.py` to reference new validator names and options
Both the view and validator integrations have been streamlined for maintainability and adherence to Django conventions.File tree
4 files changed
+315
-311
lines changed- promo_code
- promo_code
- user
4 files changed
+315
-311
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | | - | |
| 184 | + | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
| 188 | + | |
190 | 189 | | |
191 | 190 | | |
192 | | - | |
193 | | - | |
| 191 | + | |
194 | 192 | | |
195 | 193 | | |
196 | | - | |
197 | | - | |
| 194 | + | |
198 | 195 | | |
199 | 196 | | |
200 | 197 | | |
201 | | - | |
202 | 198 | | |
203 | 199 | | |
204 | 200 | | |
| |||
0 commit comments