Commit graph

81 commits

Author SHA1 Message Date
c359105019 FIX(promotions): include filters.py/docs/urls.py in admin panel restructure
These were dropped from the prior restructuring commit by a failed
multi-pathspec git add (one invalid path aborted the whole call).
Wires up filters.py's Admin*Filter classes, mounts apps.promotions.urls
(the new router package) instead of the deleted urls_admin module, and
brings docs/adminpanel_technical.md in sync with the new layout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 17:28:33 +03:30
1d77303f00 REFACTOR(promotions): split admin panel into views/serializers/urls subpackages
Restructures the admin promotions/referrals endpoints to match the
admin/users folder split used by the sibling advertising service
(apps/crm, apps/escrow, apps/stores there): views/admin/, serializers/admin/,
and a shared urls/router.py with the two resources as GenericViewSets
registered on one DefaultRouter, instead of flat _admin-suffixed modules
with separate ListAPIView/RetrieveAPIView classes.

Scoped to the admin slice only -- the pre-existing user-token/
application-token views, urls, and serializers keep their original
_user/_application file layout and URL namespaces, since converting
those too would rename routes tests.py and external callers depend on.
filters.py stays a single flat file, matching how advertising's own
filters.py is not split into subfolders either.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 17:27:15 +03:30
d27ae32e27 FEATURE(promotions): add read-only admin endpoints for promotions and referrals
Adds GET /api/v2/promotions/admin/promotions/ and .../referrals/, listing
every Promotion (type derived from Plan.processor) and referral activity
(invited_by = resolved payee, invited_user = raw event.data['user'] --
there's no dedicated referral model or referral_code field in this
codebase). Follows the existing _user/_application file-suffix convention
with a new _admin suffix, backed by real django-filter FilterSets.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 17:10:49 +03:30
079c795065 Merge pull request 'FIX(promotions): resolve user UUID before saving application events' (#3) from feature/debug-v2 into master
Reviewed-on: #3
2026-08-18 07:05:14 -04:00
1536016f14 FIX(promotions): resolve user UUID before saving application events
ApplicationEventViewSet.perform_create() was passing the full request.user
model instance into Event.user (a plain UUIDField), which raises on every
real call. Use the same _resolve_user() -> user.uuid pattern already used by
status(), and raise UnprocessableEntity on save_event failure to match the
v1 endpoint's error-handling convention.
2026-08-18 14:26:14 +03:30
1a63acee32 Merge pull request 'FIX(promotions): default event status promotion_amount to 0' (#2) from feature/allow-users into master
Reviewed-on: #2
2026-08-03 11:04:17 -04:00
54de7fdb48 PERF(promotions): collapse allowed-user check into a single query
Fold the restricted-recipient access check into the recipients
queryset itself via Q(public OR restricted-and-allowed), joining
against AllowedUser instead of running a separate lookup query.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 18:21:23 +03:30
33aa0ed1b4 PERF(promotions): batch allowed-user lookup in get_configured_promotion_amount
Checking each recipient via Recipient.is_user_allowed() inside the
loop issued one AllowedUser query per restricted recipient (N+1).
Fetch all matching AllowedUser rows for the plan's recipients in a
single query up front instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 17:55:42 +03:30
ac37f15bea FIX(promotions): default event status promotion_amount to 0
get_event_status_for_user returned None whenever the event was
already processed, no plan matched, or the user lacked access to the
recipient. Callers now always get a concrete amount: the real payout
if accessible, 0 otherwise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 17:33:59 +03:30
c2a0c2f1d8 Merge pull request 'feature/allow-users' (#1) from feature/allow-users into master
Reviewed-on: #1
2026-08-03 09:24:13 -04:00
0e95fab85f DOCS: add service brief for promotions
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 16:18:32 +03:30
c4ff4cf4cb FEATURE(promotions): restrict recipients to allowed users
Add Recipient.access_type (restricted/public) and an AllowedUser
table linking users to the recipients they may be paid through.
Restricted recipients are now checked against AllowedUser both when
computing a promotion payout and in the event-status endpoints that
report eligibility before submission.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 16:11:33 +03:30
3cef84a346 FEATURE(promotions): adding promotion is used status for user
adding promotion is used status for user
2026-07-26 15:25:49 +03:30
ab348d5134 Merge pull request 'from FEATURE/refactore-application-views into master' (#2) from FEATURE/refactore-application-views into master
Reviewed-on: https://git.mindplus-dev.ir/gooyal/promotions/pulls/2
2026-07-11 06:58:18 -04:00
Sayyid Hamid Mahdavi
a8b10b79a5 user availability test 2026-07-08 12:05:42 +03:30
Sayyid Hamid Mahdavi
1eca11e4a4 better exceptions 2026-07-07 17:24:32 +03:30
Sayyid Hamid Mahdavi
e7db91d1da get user from accounts 2026-07-07 16:42:34 +03:30
Sayyid Hamid Mahdavi
3320ff93e3 temp 2026-07-07 12:10:19 +03:30
Sayyid Hamid Mahdavi
a7964ce0ab application views 2026-06-26 14:58:36 +03:30
Sayyid Hamid Mahdavi
83582f25aa application views 2026-06-26 13:56:22 +03:30
Sayyid Hamid Mahdavi
30ccca8efc get promotion amount from another promotion 2026-06-25 11:52:04 +03:30
Sayyid Hamid Mahdavi
7038ada31e additional data in event 2026-02-24 16:19:08 +03:30
Sayyid Hamid Mahdavi
8cdcd7b1c2 basic serial promotion 2026-02-24 13:27:33 +03:30
Sayyid Hamid Mahdavi
2de2f5adc3 access without scope 2026-02-22 16:24:49 +03:30
Sayyid Hamid Mahdavi
4830602d50 get plan details 2026-02-22 14:03:52 +03:30
Sayyid Hamid Mahdavi
61f3c8a920 get plan details 2026-02-22 13:59:48 +03:30
Sayyid Hamid Mahdavi
81e3e7776d update libs 2026-02-22 12:08:32 +03:30
Sayyid Hamid Mahdavi
7a55488a17 csrf 2026-02-21 17:10:59 +03:30
Sayyid Hamid Mahdavi
d4e77dbdf8 csrf 2026-02-15 12:24:21 +03:30
Sayyid Hamid Mahdavi
87fdae51c5 better query 2025-12-13 13:19:53 +03:30
Sayyid Hamid Mahdavi
74bd3e4ed9 percentage promotion 2025-12-06 12:29:49 +03:30
Sayyid Hamid Mahdavi
3443cba7bd logger 2025-12-03 18:32:23 +03:30
Sayyid Hamid Mahdavi
d67f4f6069 get notification base url from env 2025-12-03 18:14:15 +03:30
Sayyid Hamid Mahdavi
1ccc31ad23 get notification base url from env 2025-12-03 13:57:16 +03:30
Sayyid Hamid Mahdavi
be838d1d19 push 2025-12-03 13:49:39 +03:30
Sayyid Hamid Mahdavi
308faff858 some bugfix 2025-12-03 12:08:16 +03:30
Sayyid Hamid Mahdavi
7eff9739fd some cleanup 2025-12-03 10:52:57 +03:30
Sayyid Hamid Mahdavi
89768fa02e index for jsonfield 2025-11-15 14:50:18 +03:30
Sayyid Hamid Mahdavi
1c42e3784a correct scops 2025-11-13 10:45:50 +03:30
Sayyid Hamid Mahdavi
adf8913707 correct scops 2025-11-13 10:39:15 +03:30
Sayyid Hamid Mahdavi
faab09595c create promotion outside of atomic 2025-11-13 10:23:15 +03:30
Sayyid Hamid Mahdavi
2a428fbb5d bugfix 2025-11-12 20:04:27 +03:30
Sayyid Hamid Mahdavi
6570be7b20 bugfix 2025-11-12 16:01:28 +03:30
Sayyid Hamid Mahdavi
7982878a1d bugfix 2025-11-12 15:34:38 +03:30
Sayyid Hamid Mahdavi
419fe24c57 new wallet system 2025-11-11 18:57:22 +03:30
Sayyid Hamid Mahdavi
68cea34add promotion get promoted 2025-11-08 20:16:33 +03:30
Sayyid Hamid Mahdavi
2c7d7808b3 promotion get promoted 2025-11-08 20:16:26 +03:30
Sayyid Hamid Mahdavi
ee1d1e6e66 promotion get promoted 2025-11-08 19:57:43 +03:30
Sayyid Hamid Mahdavi
2a6971f106 3 type of promotion test pass 2025-11-08 15:34:22 +03:30
Sayyid Hamid Mahdavi
aa0011d615 3 type of promotion test pass 2025-11-08 13:49:56 +03:30