django-cfg 1.2.27__py3-none-any.whl → 1.2.31__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/payments/admin/__init__.py +3 -2
- django_cfg/apps/payments/admin/balance_admin.py +18 -18
- django_cfg/apps/payments/admin/currencies_admin.py +319 -131
- django_cfg/apps/payments/admin/payments_admin.py +15 -4
- django_cfg/apps/payments/config/module.py +2 -2
- django_cfg/apps/payments/config/utils.py +2 -2
- django_cfg/apps/payments/decorators.py +2 -2
- django_cfg/apps/payments/management/commands/README.md +95 -127
- django_cfg/apps/payments/management/commands/currency_stats.py +5 -24
- django_cfg/apps/payments/management/commands/manage_currencies.py +229 -0
- django_cfg/apps/payments/management/commands/manage_providers.py +235 -0
- django_cfg/apps/payments/managers/__init__.py +3 -2
- django_cfg/apps/payments/managers/balance_manager.py +2 -2
- django_cfg/apps/payments/managers/currency_manager.py +272 -49
- django_cfg/apps/payments/managers/payment_manager.py +161 -13
- django_cfg/apps/payments/middleware/api_access.py +2 -2
- django_cfg/apps/payments/middleware/rate_limiting.py +8 -18
- django_cfg/apps/payments/middleware/usage_tracking.py +20 -17
- django_cfg/apps/payments/migrations/0002_network_providercurrency_and_more.py +241 -0
- django_cfg/apps/payments/migrations/0003_add_usd_rate_cache.py +30 -0
- django_cfg/apps/payments/models/__init__.py +3 -2
- django_cfg/apps/payments/models/currencies.py +187 -71
- django_cfg/apps/payments/models/payments.py +3 -2
- django_cfg/apps/payments/serializers/__init__.py +3 -2
- django_cfg/apps/payments/serializers/currencies.py +20 -12
- django_cfg/apps/payments/services/cache/simple_cache.py +2 -2
- django_cfg/apps/payments/services/core/balance_service.py +2 -2
- django_cfg/apps/payments/services/core/fallback_service.py +2 -2
- django_cfg/apps/payments/services/core/payment_service.py +3 -6
- django_cfg/apps/payments/services/core/subscription_service.py +4 -7
- django_cfg/apps/payments/services/internal_types.py +171 -7
- django_cfg/apps/payments/services/monitoring/api_schemas.py +58 -204
- django_cfg/apps/payments/services/monitoring/provider_health.py +2 -2
- django_cfg/apps/payments/services/providers/base.py +144 -43
- django_cfg/apps/payments/services/providers/cryptapi/__init__.py +4 -0
- django_cfg/apps/payments/services/providers/cryptapi/config.py +8 -0
- django_cfg/apps/payments/services/providers/cryptapi/models.py +192 -0
- django_cfg/apps/payments/services/providers/cryptapi/provider.py +439 -0
- django_cfg/apps/payments/services/providers/cryptomus/__init__.py +4 -0
- django_cfg/apps/payments/services/providers/cryptomus/models.py +176 -0
- django_cfg/apps/payments/services/providers/cryptomus/provider.py +429 -0
- django_cfg/apps/payments/services/providers/cryptomus/provider_v2.py +564 -0
- django_cfg/apps/payments/services/providers/models/__init__.py +34 -0
- django_cfg/apps/payments/services/providers/models/currencies.py +190 -0
- django_cfg/apps/payments/services/providers/nowpayments/__init__.py +4 -0
- django_cfg/apps/payments/services/providers/nowpayments/models.py +196 -0
- django_cfg/apps/payments/services/providers/nowpayments/provider.py +380 -0
- django_cfg/apps/payments/services/providers/registry.py +294 -11
- django_cfg/apps/payments/services/providers/stripe/__init__.py +4 -0
- django_cfg/apps/payments/services/providers/stripe/models.py +184 -0
- django_cfg/apps/payments/services/providers/stripe/provider.py +109 -0
- django_cfg/apps/payments/services/security/error_handler.py +6 -8
- django_cfg/apps/payments/services/security/payment_notifications.py +2 -2
- django_cfg/apps/payments/services/security/webhook_validator.py +3 -4
- django_cfg/apps/payments/signals/api_key_signals.py +2 -2
- django_cfg/apps/payments/signals/payment_signals.py +11 -5
- django_cfg/apps/payments/signals/subscription_signals.py +2 -2
- django_cfg/apps/payments/static/payments/css/payments.css +340 -0
- django_cfg/apps/payments/static/payments/js/notifications.js +202 -0
- django_cfg/apps/payments/static/payments/js/payment-utils.js +318 -0
- django_cfg/apps/payments/static/payments/js/theme.js +86 -0
- django_cfg/apps/payments/tasks/webhook_processing.py +2 -2
- django_cfg/apps/payments/templates/admin/payments/currency/change_list.html +50 -0
- django_cfg/apps/payments/templates/payments/base.html +182 -0
- django_cfg/apps/payments/templates/payments/components/payment_card.html +201 -0
- django_cfg/apps/payments/templates/payments/components/payment_qr_code.html +109 -0
- django_cfg/apps/payments/templates/payments/components/progress_bar.html +43 -0
- django_cfg/apps/payments/templates/payments/components/provider_stats.html +40 -0
- django_cfg/apps/payments/templates/payments/components/status_badge.html +34 -0
- django_cfg/apps/payments/templates/payments/components/status_overview.html +148 -0
- django_cfg/apps/payments/templates/payments/dashboard.html +258 -0
- django_cfg/apps/payments/templates/payments/dashboard_simple_test.html +35 -0
- django_cfg/apps/payments/templates/payments/payment_create.html +579 -0
- django_cfg/apps/payments/templates/payments/payment_detail.html +373 -0
- django_cfg/apps/payments/templates/payments/payment_list.html +354 -0
- django_cfg/apps/payments/templates/payments/stats.html +261 -0
- django_cfg/apps/payments/templates/payments/test.html +213 -0
- django_cfg/apps/payments/templatetags/__init__.py +1 -0
- django_cfg/apps/payments/templatetags/payments_tags.py +315 -0
- django_cfg/apps/payments/urls.py +3 -1
- django_cfg/apps/payments/urls_admin.py +58 -0
- django_cfg/apps/payments/utils/__init__.py +1 -3
- django_cfg/apps/payments/utils/billing_utils.py +2 -2
- django_cfg/apps/payments/utils/config_utils.py +2 -8
- django_cfg/apps/payments/utils/validation_utils.py +2 -2
- django_cfg/apps/payments/views/__init__.py +3 -2
- django_cfg/apps/payments/views/currency_views.py +31 -20
- django_cfg/apps/payments/views/payment_views.py +2 -2
- django_cfg/apps/payments/views/templates/__init__.py +25 -0
- django_cfg/apps/payments/views/templates/ajax.py +451 -0
- django_cfg/apps/payments/views/templates/base.py +212 -0
- django_cfg/apps/payments/views/templates/dashboard.py +60 -0
- django_cfg/apps/payments/views/templates/payment_detail.py +102 -0
- django_cfg/apps/payments/views/templates/payment_management.py +158 -0
- django_cfg/apps/payments/views/templates/qr_code.py +174 -0
- django_cfg/apps/payments/views/templates/stats.py +244 -0
- django_cfg/apps/payments/views/templates/utils.py +181 -0
- django_cfg/apps/payments/views/webhook_views.py +2 -2
- django_cfg/apps/payments/viewsets.py +3 -2
- django_cfg/apps/tasks/urls.py +0 -2
- django_cfg/apps/tasks/urls_admin.py +14 -0
- django_cfg/apps/urls.py +6 -3
- django_cfg/core/config.py +35 -0
- django_cfg/models/payments.py +2 -8
- django_cfg/modules/django_currency/__init__.py +16 -11
- django_cfg/modules/django_currency/clients/__init__.py +4 -4
- django_cfg/modules/django_currency/clients/coinpaprika_client.py +289 -0
- django_cfg/modules/django_currency/clients/yahoo_client.py +157 -0
- django_cfg/modules/django_currency/core/__init__.py +1 -7
- django_cfg/modules/django_currency/core/converter.py +18 -23
- django_cfg/modules/django_currency/core/models.py +122 -11
- django_cfg/modules/django_currency/database/__init__.py +4 -4
- django_cfg/modules/django_currency/database/database_loader.py +190 -309
- django_cfg/modules/django_unfold/dashboard.py +7 -2
- django_cfg/registry/core.py +1 -0
- django_cfg/template_archive/.gitignore +1 -0
- django_cfg/template_archive/django_sample.zip +0 -0
- django_cfg/templates/admin/components/action_grid.html +9 -9
- django_cfg/templates/admin/components/metric_card.html +5 -5
- django_cfg/templates/admin/components/status_badge.html +2 -2
- django_cfg/templates/admin/layouts/dashboard_with_tabs.html +152 -24
- django_cfg/templates/admin/snippets/components/quick_actions.html +3 -3
- django_cfg/templates/admin/snippets/components/system_health.html +1 -1
- django_cfg/templates/admin/snippets/tabs/overview_tab.html +49 -52
- {django_cfg-1.2.27.dist-info → django_cfg-1.2.31.dist-info}/METADATA +13 -18
- {django_cfg-1.2.27.dist-info → django_cfg-1.2.31.dist-info}/RECORD +130 -83
- django_cfg/apps/payments/management/commands/populate_currencies.py +0 -246
- django_cfg/apps/payments/management/commands/update_currencies.py +0 -336
- django_cfg/apps/payments/services/providers/cryptapi.py +0 -273
- django_cfg/apps/payments/services/providers/cryptomus.py +0 -310
- django_cfg/apps/payments/services/providers/nowpayments.py +0 -293
- django_cfg/apps/payments/services/validators/__init__.py +0 -8
- django_cfg/modules/django_currency/clients/coingecko_client.py +0 -257
- django_cfg/modules/django_currency/clients/yfinance_client.py +0 -246
- {django_cfg-1.2.27.dist-info → django_cfg-1.2.31.dist-info}/WHEEL +0 -0
- {django_cfg-1.2.27.dist-info → django_cfg-1.2.31.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.2.27.dist-info → django_cfg-1.2.31.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,318 @@
|
|
1
|
+
/**
|
2
|
+
* Payment Utility Functions
|
3
|
+
* Common utilities for payment dashboard functionality
|
4
|
+
*/
|
5
|
+
|
6
|
+
class PaymentUtils {
|
7
|
+
constructor() {
|
8
|
+
this.formatters = {
|
9
|
+
currency: new Intl.NumberFormat('en-US', {
|
10
|
+
style: 'currency',
|
11
|
+
currency: 'USD',
|
12
|
+
minimumFractionDigits: 2,
|
13
|
+
maximumFractionDigits: 8
|
14
|
+
}),
|
15
|
+
number: new Intl.NumberFormat('en-US'),
|
16
|
+
date: new Intl.DateTimeFormat('en-US', {
|
17
|
+
year: 'numeric',
|
18
|
+
month: 'short',
|
19
|
+
day: 'numeric',
|
20
|
+
hour: '2-digit',
|
21
|
+
minute: '2-digit'
|
22
|
+
})
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
// Format currency with proper decimals based on currency type
|
27
|
+
formatCurrency(amount, currencyCode = 'USD') {
|
28
|
+
const numAmount = parseFloat(amount) || 0;
|
29
|
+
|
30
|
+
// Crypto currencies need more decimal places
|
31
|
+
const cryptoDecimals = {
|
32
|
+
'BTC': 8,
|
33
|
+
'ETH': 6,
|
34
|
+
'LTC': 8,
|
35
|
+
'USDT': 6,
|
36
|
+
'USDC': 6
|
37
|
+
};
|
38
|
+
|
39
|
+
if (cryptoDecimals[currencyCode]) {
|
40
|
+
return `${numAmount.toFixed(cryptoDecimals[currencyCode])} ${currencyCode}`;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Fiat currencies
|
44
|
+
if (currencyCode === 'USD') {
|
45
|
+
return this.formatters.currency.format(numAmount);
|
46
|
+
}
|
47
|
+
|
48
|
+
return `${numAmount.toFixed(2)} ${currencyCode}`;
|
49
|
+
}
|
50
|
+
|
51
|
+
// Format payment status with proper display text
|
52
|
+
formatStatus(status) {
|
53
|
+
const statusMap = {
|
54
|
+
'pending': 'Pending',
|
55
|
+
'confirming': 'Confirming',
|
56
|
+
'confirmed': 'Confirmed',
|
57
|
+
'completed': 'Completed',
|
58
|
+
'failed': 'Failed',
|
59
|
+
'expired': 'Expired',
|
60
|
+
'cancelled': 'Cancelled',
|
61
|
+
'refunded': 'Refunded'
|
62
|
+
};
|
63
|
+
return statusMap[status] || status;
|
64
|
+
}
|
65
|
+
|
66
|
+
// Get status color class
|
67
|
+
getStatusColor(status) {
|
68
|
+
const colorMap = {
|
69
|
+
'pending': 'yellow',
|
70
|
+
'confirming': 'blue',
|
71
|
+
'confirmed': 'green',
|
72
|
+
'completed': 'green',
|
73
|
+
'failed': 'red',
|
74
|
+
'expired': 'gray',
|
75
|
+
'cancelled': 'gray',
|
76
|
+
'refunded': 'purple'
|
77
|
+
};
|
78
|
+
return colorMap[status] || 'gray';
|
79
|
+
}
|
80
|
+
|
81
|
+
// Get provider display name
|
82
|
+
getProviderName(provider) {
|
83
|
+
const providerMap = {
|
84
|
+
'nowpayments': 'NowPayments',
|
85
|
+
'cryptapi': 'CryptAPI',
|
86
|
+
'cryptomus': 'Cryptomus',
|
87
|
+
'stripe': 'Stripe',
|
88
|
+
'internal': 'Internal'
|
89
|
+
};
|
90
|
+
return providerMap[provider] || provider;
|
91
|
+
}
|
92
|
+
|
93
|
+
// Get provider icon
|
94
|
+
getProviderIcon(provider) {
|
95
|
+
const iconMap = {
|
96
|
+
'nowpayments': 'currency_bitcoin',
|
97
|
+
'cryptapi': 'currency_bitcoin',
|
98
|
+
'cryptomus': 'currency_bitcoin',
|
99
|
+
'stripe': 'credit_card',
|
100
|
+
'internal': 'account_balance'
|
101
|
+
};
|
102
|
+
return iconMap[provider] || 'payment';
|
103
|
+
}
|
104
|
+
|
105
|
+
// Calculate time ago
|
106
|
+
timeAgo(dateString) {
|
107
|
+
const date = new Date(dateString);
|
108
|
+
const now = new Date();
|
109
|
+
const diffMs = now - date;
|
110
|
+
const diffSecs = Math.floor(diffMs / 1000);
|
111
|
+
const diffMins = Math.floor(diffSecs / 60);
|
112
|
+
const diffHours = Math.floor(diffMins / 60);
|
113
|
+
const diffDays = Math.floor(diffHours / 24);
|
114
|
+
|
115
|
+
if (diffSecs < 60) {
|
116
|
+
return 'Just now';
|
117
|
+
} else if (diffMins < 60) {
|
118
|
+
return `${diffMins}m ago`;
|
119
|
+
} else if (diffHours < 24) {
|
120
|
+
return `${diffHours}h ago`;
|
121
|
+
} else if (diffDays < 7) {
|
122
|
+
return `${diffDays}d ago`;
|
123
|
+
} else {
|
124
|
+
return this.formatters.date.format(date);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
// Validate payment ID format
|
129
|
+
isValidPaymentId(id) {
|
130
|
+
// UUID v4 format
|
131
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
132
|
+
return uuidRegex.test(id);
|
133
|
+
}
|
134
|
+
|
135
|
+
// Copy text to clipboard
|
136
|
+
async copyToClipboard(text) {
|
137
|
+
try {
|
138
|
+
await navigator.clipboard.writeText(text);
|
139
|
+
if (window.notificationManager) {
|
140
|
+
window.notificationManager.success('Copied to clipboard');
|
141
|
+
}
|
142
|
+
return true;
|
143
|
+
} catch (err) {
|
144
|
+
console.error('Failed to copy to clipboard:', err);
|
145
|
+
if (window.notificationManager) {
|
146
|
+
window.notificationManager.error('Failed to copy to clipboard');
|
147
|
+
}
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
// Generate QR code data URL (placeholder - requires QR library)
|
153
|
+
generateQRCodeDataUrl(data, size = 128) {
|
154
|
+
// This would integrate with a QR code library like qrcode.js
|
155
|
+
// For now, return a placeholder
|
156
|
+
return `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><rect width="100%" height="100%" fill="%23f3f4f6"/><text x="50%" y="50%" text-anchor="middle" dy="0.3em" font-family="sans-serif" font-size="12" fill="%236b7280">QR Code</text></svg>`;
|
157
|
+
}
|
158
|
+
|
159
|
+
// Debounce function for search/filter inputs
|
160
|
+
debounce(func, wait) {
|
161
|
+
let timeout;
|
162
|
+
return function executedFunction(...args) {
|
163
|
+
const later = () => {
|
164
|
+
clearTimeout(timeout);
|
165
|
+
func(...args);
|
166
|
+
};
|
167
|
+
clearTimeout(timeout);
|
168
|
+
timeout = setTimeout(later, wait);
|
169
|
+
};
|
170
|
+
}
|
171
|
+
|
172
|
+
// Throttle function for scroll events
|
173
|
+
throttle(func, limit) {
|
174
|
+
let inThrottle;
|
175
|
+
return function() {
|
176
|
+
const args = arguments;
|
177
|
+
const context = this;
|
178
|
+
if (!inThrottle) {
|
179
|
+
func.apply(context, args);
|
180
|
+
inThrottle = true;
|
181
|
+
setTimeout(() => inThrottle = false, limit);
|
182
|
+
}
|
183
|
+
};
|
184
|
+
}
|
185
|
+
|
186
|
+
// Update URL parameters without page reload
|
187
|
+
updateUrlParams(params) {
|
188
|
+
const url = new URL(window.location);
|
189
|
+
Object.keys(params).forEach(key => {
|
190
|
+
if (params[key] !== null && params[key] !== '') {
|
191
|
+
url.searchParams.set(key, params[key]);
|
192
|
+
} else {
|
193
|
+
url.searchParams.delete(key);
|
194
|
+
}
|
195
|
+
});
|
196
|
+
window.history.replaceState({}, '', url);
|
197
|
+
}
|
198
|
+
|
199
|
+
// Get URL parameter value
|
200
|
+
getUrlParam(param) {
|
201
|
+
const urlParams = new URLSearchParams(window.location.search);
|
202
|
+
return urlParams.get(param);
|
203
|
+
}
|
204
|
+
|
205
|
+
// Format large numbers (e.g., 1000000 -> 1M)
|
206
|
+
formatLargeNumber(num) {
|
207
|
+
const numValue = parseFloat(num) || 0;
|
208
|
+
if (numValue >= 1000000000) {
|
209
|
+
return (numValue / 1000000000).toFixed(1) + 'B';
|
210
|
+
} else if (numValue >= 1000000) {
|
211
|
+
return (numValue / 1000000).toFixed(1) + 'M';
|
212
|
+
} else if (numValue >= 1000) {
|
213
|
+
return (numValue / 1000).toFixed(1) + 'K';
|
214
|
+
}
|
215
|
+
return this.formatters.number.format(numValue);
|
216
|
+
}
|
217
|
+
|
218
|
+
// Show confirmation dialog
|
219
|
+
showConfirmDialog(message, onConfirm, onCancel = null) {
|
220
|
+
const modal = document.createElement('div');
|
221
|
+
modal.className = 'modal-overlay';
|
222
|
+
modal.innerHTML = `
|
223
|
+
<div class="modal-content">
|
224
|
+
<div class="modal-header">
|
225
|
+
<h3 class="text-lg font-medium text-gray-900 dark:text-white">Confirm Action</h3>
|
226
|
+
</div>
|
227
|
+
<div class="modal-body">
|
228
|
+
<p class="text-sm text-gray-500 dark:text-gray-400">${this.escapeHtml(message)}</p>
|
229
|
+
</div>
|
230
|
+
<div class="modal-footer">
|
231
|
+
<button class="btn btn-outline" id="cancel-btn">Cancel</button>
|
232
|
+
<button class="btn btn-danger" id="confirm-btn">Confirm</button>
|
233
|
+
</div>
|
234
|
+
</div>
|
235
|
+
`;
|
236
|
+
|
237
|
+
document.body.appendChild(modal);
|
238
|
+
|
239
|
+
const confirmBtn = modal.querySelector('#confirm-btn');
|
240
|
+
const cancelBtn = modal.querySelector('#cancel-btn');
|
241
|
+
|
242
|
+
const cleanup = () => {
|
243
|
+
if (modal.parentNode) {
|
244
|
+
modal.parentNode.removeChild(modal);
|
245
|
+
}
|
246
|
+
};
|
247
|
+
|
248
|
+
confirmBtn.addEventListener('click', () => {
|
249
|
+
cleanup();
|
250
|
+
if (onConfirm) onConfirm();
|
251
|
+
});
|
252
|
+
|
253
|
+
cancelBtn.addEventListener('click', () => {
|
254
|
+
cleanup();
|
255
|
+
if (onCancel) onCancel();
|
256
|
+
});
|
257
|
+
|
258
|
+
modal.addEventListener('click', (e) => {
|
259
|
+
if (e.target === modal) {
|
260
|
+
cleanup();
|
261
|
+
if (onCancel) onCancel();
|
262
|
+
}
|
263
|
+
});
|
264
|
+
}
|
265
|
+
|
266
|
+
// Escape HTML to prevent XSS
|
267
|
+
escapeHtml(text) {
|
268
|
+
const map = {
|
269
|
+
'&': '&',
|
270
|
+
'<': '<',
|
271
|
+
'>': '>',
|
272
|
+
'"': '"',
|
273
|
+
"'": '''
|
274
|
+
};
|
275
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
276
|
+
}
|
277
|
+
|
278
|
+
// Local storage helpers with error handling
|
279
|
+
setStorage(key, value) {
|
280
|
+
try {
|
281
|
+
localStorage.setItem(key, JSON.stringify(value));
|
282
|
+
return true;
|
283
|
+
} catch (e) {
|
284
|
+
console.error('Failed to save to localStorage:', e);
|
285
|
+
return false;
|
286
|
+
}
|
287
|
+
}
|
288
|
+
|
289
|
+
getStorage(key, defaultValue = null) {
|
290
|
+
try {
|
291
|
+
const item = localStorage.getItem(key);
|
292
|
+
return item ? JSON.parse(item) : defaultValue;
|
293
|
+
} catch (e) {
|
294
|
+
console.error('Failed to read from localStorage:', e);
|
295
|
+
return defaultValue;
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
removeStorage(key) {
|
300
|
+
try {
|
301
|
+
localStorage.removeItem(key);
|
302
|
+
return true;
|
303
|
+
} catch (e) {
|
304
|
+
console.error('Failed to remove from localStorage:', e);
|
305
|
+
return false;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
// Initialize utils when DOM is loaded
|
311
|
+
document.addEventListener('DOMContentLoaded', () => {
|
312
|
+
window.paymentUtils = new PaymentUtils();
|
313
|
+
});
|
314
|
+
|
315
|
+
// Export for use in other modules
|
316
|
+
if (typeof module !== 'undefined' && module.exports) {
|
317
|
+
module.exports = PaymentUtils;
|
318
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/**
|
2
|
+
* Theme Management for Payment Dashboard
|
3
|
+
* Handles light/dark mode switching with persistence
|
4
|
+
*/
|
5
|
+
|
6
|
+
class ThemeManager {
|
7
|
+
constructor() {
|
8
|
+
this.initTheme();
|
9
|
+
this.bindEvents();
|
10
|
+
}
|
11
|
+
|
12
|
+
initTheme() {
|
13
|
+
// Check for saved theme preference or default to system preference
|
14
|
+
const savedTheme = localStorage.getItem('theme');
|
15
|
+
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
16
|
+
|
17
|
+
if (savedTheme) {
|
18
|
+
this.setTheme(savedTheme);
|
19
|
+
} else if (systemPrefersDark) {
|
20
|
+
this.setTheme('dark');
|
21
|
+
} else {
|
22
|
+
this.setTheme('light');
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
setTheme(theme) {
|
27
|
+
const html = document.documentElement;
|
28
|
+
const toggleBtn = document.getElementById('theme-toggle');
|
29
|
+
const icon = toggleBtn?.querySelector('.material-icons');
|
30
|
+
|
31
|
+
if (theme === 'dark') {
|
32
|
+
html.classList.add('dark');
|
33
|
+
localStorage.setItem('theme', 'dark');
|
34
|
+
if (icon) {
|
35
|
+
icon.textContent = 'dark_mode';
|
36
|
+
icon.classList.add('text-yellow-400');
|
37
|
+
icon.classList.remove('text-gray-600');
|
38
|
+
}
|
39
|
+
} else {
|
40
|
+
html.classList.remove('dark');
|
41
|
+
localStorage.setItem('theme', 'light');
|
42
|
+
if (icon) {
|
43
|
+
icon.textContent = 'light_mode';
|
44
|
+
icon.classList.add('text-gray-600');
|
45
|
+
icon.classList.remove('text-yellow-400');
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
// Dispatch theme change event
|
50
|
+
window.dispatchEvent(new CustomEvent('themeChanged', { detail: { theme } }));
|
51
|
+
}
|
52
|
+
|
53
|
+
toggle() {
|
54
|
+
const currentTheme = localStorage.getItem('theme') || 'light';
|
55
|
+
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
56
|
+
this.setTheme(newTheme);
|
57
|
+
}
|
58
|
+
|
59
|
+
bindEvents() {
|
60
|
+
const toggleBtn = document.getElementById('theme-toggle');
|
61
|
+
if (toggleBtn) {
|
62
|
+
toggleBtn.addEventListener('click', () => this.toggle());
|
63
|
+
}
|
64
|
+
|
65
|
+
// Listen for system theme changes
|
66
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
67
|
+
if (!localStorage.getItem('theme')) {
|
68
|
+
this.setTheme(e.matches ? 'dark' : 'light');
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
getCurrentTheme() {
|
74
|
+
return localStorage.getItem('theme') || 'light';
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
// Initialize theme manager when DOM is loaded
|
79
|
+
document.addEventListener('DOMContentLoaded', () => {
|
80
|
+
window.themeManager = new ThemeManager();
|
81
|
+
});
|
82
|
+
|
83
|
+
// Export for use in other modules
|
84
|
+
if (typeof module !== 'undefined' && module.exports) {
|
85
|
+
module.exports = ThemeManager;
|
86
|
+
}
|
@@ -5,7 +5,7 @@ Simple webhook processing with fallback to sync processing.
|
|
5
5
|
Uses existing Dramatiq configuration and graceful degradation.
|
6
6
|
"""
|
7
7
|
|
8
|
-
import
|
8
|
+
from django_cfg.modules.django_logger import get_logger
|
9
9
|
from typing import Dict, Any, Optional
|
10
10
|
from django.db import transaction
|
11
11
|
from django.utils import timezone
|
@@ -16,7 +16,7 @@ import dramatiq
|
|
16
16
|
from ..services.core.payment_service import PaymentService
|
17
17
|
from ..models.events import PaymentEvent
|
18
18
|
|
19
|
-
logger =
|
19
|
+
logger = get_logger("webhook_processing")
|
20
20
|
|
21
21
|
|
22
22
|
@dramatiq.actor(
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{% extends "admin/change_list.html" %}
|
2
|
+
{% load static %}
|
3
|
+
|
4
|
+
{% block result_list %}
|
5
|
+
<!-- Currency Statistics Dashboard - Unfold Semantic Colors -->
|
6
|
+
<div class="bg-white border border-base-200 dark:bg-base-900 dark:border-base-700 p-4 rounded-default mb-4">
|
7
|
+
<h3 class="text-lg font-semibold text-font-important-light dark:text-font-important-dark mb-3">📊 Currency Overview</h3>
|
8
|
+
|
9
|
+
<div class="grid grid-cols-4 gap-4 mb-4">
|
10
|
+
<div class="text-center bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
11
|
+
<p class="text-2xl font-bold text-primary-600 dark:text-primary-400">{{ total_currencies }}</p>
|
12
|
+
<p class="text-sm text-font-subtle-light dark:text-font-subtle-dark">Total Currencies</p>
|
13
|
+
</div>
|
14
|
+
<div class="text-center bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
15
|
+
<p class="text-2xl font-bold text-success-600 dark:text-success-400">{{ enabled_provider_currencies }}</p>
|
16
|
+
<p class="text-sm text-font-subtle-light dark:text-font-subtle-dark">Provider Mappings</p>
|
17
|
+
</div>
|
18
|
+
<div class="text-center bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
19
|
+
<p class="text-2xl font-bold text-warning-600 dark:text-warning-400">{{ currencies_with_rates }}</p>
|
20
|
+
<p class="text-sm text-font-subtle-light dark:text-font-subtle-dark">With USD Rates</p>
|
21
|
+
</div>
|
22
|
+
<div class="text-center bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
23
|
+
<p class="text-2xl font-bold text-info-600 dark:text-info-400">{{ rate_coverage|floatformat:1 }}%</p>
|
24
|
+
<p class="text-sm text-font-subtle-light dark:text-font-subtle-dark">Rate Coverage</p>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="grid grid-cols-2 gap-4">
|
29
|
+
<div class="bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
30
|
+
<h4 class="font-semibold text-font-important-light dark:text-font-important-dark mb-2">Currency Types</h4>
|
31
|
+
<ul class="text-sm space-y-1 text-font-default-light dark:text-font-default-dark">
|
32
|
+
<li>💵 Fiat: <span class="font-medium text-primary-600 dark:text-primary-400">{{ fiat_count }}</span></li>
|
33
|
+
<li>₿ Crypto: <span class="font-medium text-warning-600 dark:text-warning-400">{{ crypto_count }}</span></li>
|
34
|
+
</ul>
|
35
|
+
</div>
|
36
|
+
<div class="bg-base-50 dark:bg-base-800 p-3 rounded-default">
|
37
|
+
<h4 class="font-semibold text-font-important-light dark:text-font-important-dark mb-2">🚀 Top Supported</h4>
|
38
|
+
<ul class="text-sm space-y-1 text-font-default-light dark:text-font-default-dark">
|
39
|
+
{% for currency in top_currencies %}
|
40
|
+
<li><span class="font-semibold text-primary-600 dark:text-primary-400">{{ currency.code }}:</span> {{ currency.provider_count }} providers</li>
|
41
|
+
{% empty %}
|
42
|
+
<li class="text-font-subtle-light dark:text-font-subtle-dark">No provider data available</li>
|
43
|
+
{% endfor %}
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
{{ block.super }}
|
50
|
+
{% endblock %}
|
@@ -0,0 +1,182 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en" class="h-full">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>{% block title %}Payment Dashboard{% endblock %}</title>
|
7
|
+
|
8
|
+
<!-- Tailwind CSS -->
|
9
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
10
|
+
<script>
|
11
|
+
tailwind.config = {
|
12
|
+
darkMode: 'class',
|
13
|
+
theme: {
|
14
|
+
extend: {
|
15
|
+
colors: {
|
16
|
+
primary: {
|
17
|
+
50: '#eff6ff',
|
18
|
+
100: '#dbeafe',
|
19
|
+
200: '#bfdbfe',
|
20
|
+
300: '#93c5fd',
|
21
|
+
400: '#60a5fa',
|
22
|
+
500: '#3b82f6',
|
23
|
+
600: '#2563eb',
|
24
|
+
700: '#1d4ed8',
|
25
|
+
800: '#1e40af',
|
26
|
+
900: '#1e3a8a',
|
27
|
+
},
|
28
|
+
success: {
|
29
|
+
50: '#f0fdf4',
|
30
|
+
100: '#dcfce7',
|
31
|
+
500: '#22c55e',
|
32
|
+
600: '#16a34a',
|
33
|
+
},
|
34
|
+
warning: {
|
35
|
+
50: '#fffbeb',
|
36
|
+
100: '#fef3c7',
|
37
|
+
500: '#f59e0b',
|
38
|
+
600: '#d97706',
|
39
|
+
},
|
40
|
+
danger: {
|
41
|
+
50: '#fef2f2',
|
42
|
+
100: '#fee2e2',
|
43
|
+
500: '#ef4444',
|
44
|
+
600: '#dc2626',
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<!-- Material Icons -->
|
53
|
+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
54
|
+
|
55
|
+
<!-- Custom CSS -->
|
56
|
+
{% load static %}
|
57
|
+
<link rel="stylesheet" href="{% static 'payments/css/payments.css' %}">
|
58
|
+
|
59
|
+
{% block extra_head %}{% endblock %}
|
60
|
+
</head>
|
61
|
+
<body class="h-full bg-gray-50 dark:bg-gray-900">
|
62
|
+
<div class="min-h-full">
|
63
|
+
<!-- Header -->
|
64
|
+
<header class="bg-white dark:bg-gray-800 shadow-sm border-b border-gray-200 dark:border-gray-700">
|
65
|
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
66
|
+
<div class="flex items-center justify-between h-16">
|
67
|
+
<div class="flex items-center space-x-3">
|
68
|
+
<div class="flex-shrink-0">
|
69
|
+
<span class="material-icons text-primary-600 dark:text-primary-400 text-3xl">payments</span>
|
70
|
+
</div>
|
71
|
+
<div>
|
72
|
+
<h1 class="text-xl font-bold text-gray-900 dark:text-white">
|
73
|
+
{% block header_title %}Payment Dashboard{% endblock %}
|
74
|
+
</h1>
|
75
|
+
<p class="text-sm text-gray-500 dark:text-gray-400">
|
76
|
+
{% block header_subtitle %}Monitor and manage payment transactions{% endblock %}
|
77
|
+
</p>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
<div class="flex items-center space-x-3">
|
81
|
+
{% block header_actions %}
|
82
|
+
<a href="{% url 'payments_dashboard:list' %}"
|
83
|
+
class="inline-flex items-center px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors duration-200">
|
84
|
+
<span class="material-icons text-sm mr-2">history</span>
|
85
|
+
Payment History
|
86
|
+
</a>
|
87
|
+
<a href="{% url 'payments_dashboard:create' %}"
|
88
|
+
class="inline-flex items-center px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors duration-200">
|
89
|
+
<span class="material-icons text-sm mr-2">add</span>
|
90
|
+
New Payment
|
91
|
+
</a>
|
92
|
+
<button id="theme-toggle"
|
93
|
+
class="group inline-flex items-center justify-center px-3 py-2 rounded-md bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
|
94
|
+
<span class="material-icons text-gray-600 dark:text-yellow-400 group-hover:text-blue-600 dark:group-hover:text-yellow-300 transition-colors duration-200">light_mode</span>
|
95
|
+
</button>
|
96
|
+
{% endblock %}
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
</header>
|
101
|
+
|
102
|
+
<!-- Live Status Indicator -->
|
103
|
+
<div id="live-status" class="bg-success-50 border-b border-success-200 px-4 py-2 hidden">
|
104
|
+
<div class="max-w-7xl mx-auto">
|
105
|
+
<div class="flex items-center justify-center">
|
106
|
+
<div class="flex items-center">
|
107
|
+
<div class="w-2 h-2 bg-success-500 rounded-full mr-2 animate-pulse"></div>
|
108
|
+
<span class="text-sm text-success-700 font-medium">Real-time updates active</span>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<!-- Main content -->
|
115
|
+
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
116
|
+
{% block content %}{% endblock %}
|
117
|
+
</main>
|
118
|
+
|
119
|
+
<!-- Footer -->
|
120
|
+
<footer class="bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 mt-12">
|
121
|
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
122
|
+
<div class="flex items-center justify-between">
|
123
|
+
<div class="text-sm text-gray-500 dark:text-gray-400">
|
124
|
+
{% block footer_text %}
|
125
|
+
Django-CFG Payment System •
|
126
|
+
<span id="connection-status" class="text-success-600">Connected</span>
|
127
|
+
{% endblock %}
|
128
|
+
</div>
|
129
|
+
<div class="flex items-center space-x-4 text-sm text-gray-500 dark:text-gray-400">
|
130
|
+
<span>Last update: <span id="last-update">{% now "H:i:s" %}</span></span>
|
131
|
+
<span class="material-icons text-sm">schedule</span>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
</footer>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<!-- Notification Container -->
|
139
|
+
<div id="notification-container" class="fixed top-4 left-1/2 transform -translate-x-1/2 z-50 space-y-2"></div>
|
140
|
+
|
141
|
+
<!-- Modal Container -->
|
142
|
+
<div id="modal-container"></div>
|
143
|
+
|
144
|
+
<!-- JavaScript -->
|
145
|
+
<script src="{% static 'payments/js/theme.js' %}"></script>
|
146
|
+
<script src="{% static 'payments/js/notifications.js' %}"></script>
|
147
|
+
<script src="{% static 'payments/js/payment-utils.js' %}"></script>
|
148
|
+
{% block extra_js %}{% endblock %}
|
149
|
+
|
150
|
+
<!-- Real-time updates -->
|
151
|
+
<script>
|
152
|
+
// Global payment system initialization
|
153
|
+
document.addEventListener('DOMContentLoaded', function() {
|
154
|
+
// Update connection status
|
155
|
+
const updateConnectionStatus = () => {
|
156
|
+
const statusEl = document.getElementById('connection-status');
|
157
|
+
const lastUpdateEl = document.getElementById('last-update');
|
158
|
+
const liveStatusEl = document.getElementById('live-status');
|
159
|
+
|
160
|
+
if (statusEl) {
|
161
|
+
statusEl.textContent = 'Connected';
|
162
|
+
statusEl.className = 'text-success-600';
|
163
|
+
}
|
164
|
+
|
165
|
+
if (lastUpdateEl) {
|
166
|
+
lastUpdateEl.textContent = new Date().toLocaleTimeString();
|
167
|
+
}
|
168
|
+
|
169
|
+
if (liveStatusEl) {
|
170
|
+
liveStatusEl.classList.remove('hidden');
|
171
|
+
}
|
172
|
+
};
|
173
|
+
|
174
|
+
// Initial status update
|
175
|
+
updateConnectionStatus();
|
176
|
+
|
177
|
+
// Periodic status update
|
178
|
+
setInterval(updateConnectionStatus, 30000); // Every 30 seconds
|
179
|
+
});
|
180
|
+
</script>
|
181
|
+
</body>
|
182
|
+
</html>
|