Create a setting recommendation notification. Returns (notification, created) tuple.
(cls, setting_key, recommended_value, reason, current_value=None)
| 585 | |
| 586 | @classmethod |
| 587 | def create_setting_recommendation(cls, setting_key, recommended_value, reason, current_value=None): |
| 588 | """Create a setting recommendation notification. Returns (notification, created) tuple.""" |
| 589 | key = f"setting-{setting_key}" |
| 590 | notification, created = cls.objects.update_or_create( |
| 591 | notification_key=key, |
| 592 | defaults={ |
| 593 | 'notification_type': cls.NotificationType.SETTING_RECOMMENDATION, |
| 594 | 'priority': cls.Priority.NORMAL, |
| 595 | 'title': f'Recommended Setting: {setting_key}', |
| 596 | 'message': reason, |
| 597 | 'action_data': { |
| 598 | 'setting_key': setting_key, |
| 599 | 'recommended_value': recommended_value, |
| 600 | 'current_value': current_value, |
| 601 | }, |
| 602 | 'is_active': True, |
| 603 | 'admin_only': True, |
| 604 | } |
| 605 | ) |
| 606 | return notification, created |
| 607 | |
| 608 | |
| 609 | class NotificationDismissal(models.Model): |
no outgoing calls
no test coverage detected