def create_location_notification(location): notification_type = ActionNotificationType.objects.get(code='LOC') patterns = {"user": location.user.username, "location": location.location} notification = ActionNotification(notification_type=notification_type, user=location.user, patterns=dict_to_string(patterns), content_object=location, object_id=location.id) notification.save()
def create_status_notification(user_status): notification_type = ActionNotificationType.objects.get(code='STAT') patterns = {"user": user_status.user.username, "status": user_status.content} status_notification = ActionNotification(notification_type=notification_type, user=user_status.user, patterns=dict_to_string(patterns), content_object=user_status, object_id=user_status.id) status_notification.save()
def create_event_notification(event): # insert error handling here, to handle the case in which event notification type is not in the database notification_type = ActionNotificationType.objects.get(code='EVT') patterns = {"user": event.user.username, "title": event.title} event_notification = ActionNotification(notification_type=notification_type, user=event.user, patterns=dict_to_string(patterns), content_object=event, object_id=event.id) event_notification.save()