27
27
BlockedEmailError ,
28
28
)
29
29
from website .settings import OSF_CONTACT_EMAIL , DOMAIN
30
+ from osf .models .notification_type import NotificationType , FrequencyChoices
30
31
from .node_relation import NodeRelation
31
32
from .nodelog import NodeLog
32
- from .notification import NotificationType , FrequencyChoices
33
33
from .subject import Subject
34
34
from .spam import SpamMixin , SpamStatus
35
35
from .validators import validate_title
@@ -1456,21 +1456,23 @@ def add_contributor(self, contributor, permissions=None, visible=True,
1456
1456
self .save ()
1457
1457
if self ._id and contrib_to_add :
1458
1458
# Get or create the notification type
1459
- notification_type , created = NotificationType .objects .get_or_create (
1460
- name = 'Add contributor' ,
1461
- defaults = {
1462
- 'notification_freq' : FrequencyChoices .INSTANTLY .value ,
1463
- 'template' : send_email
1464
- }
1465
- )
1459
+ if send_email == 'default' :
1460
+ notification_type_name = NotificationType .Type .USER_CONTRIBUTOR_ADDED_DEFAULT .value
1461
+ else :
1462
+ notification_type_name = NotificationType .Type .USER_CONTRIBUTOR_ADDED_DEFAULT .value
1463
+ notification_type = NotificationType .objects .get (name = notification_type_name )
1464
+
1465
+ auth_user_fullname = None
1466
+ if auth :
1467
+ auth_user_fullname = auth .user .fullname
1466
1468
1467
1469
event_context = {
1468
1470
'node' : {
1469
1471
'id' : self ._id ,
1470
1472
'title' : self .title ,
1471
1473
'absolute_url' : getattr (self , 'absolute_url' , '' ),
1472
1474
},
1473
- 'referrer_name' : auth . user . fullname ,
1475
+ 'referrer_name' : auth_user_fullname ,
1474
1476
'user' : {
1475
1477
'id' : contrib_to_add ._id ,
1476
1478
'fullname' : contrib_to_add .fullname ,
@@ -1482,9 +1484,10 @@ def add_contributor(self, contributor, permissions=None, visible=True,
1482
1484
'DOMAIN' : DOMAIN
1483
1485
}
1484
1486
}
1485
-
1487
+ breakpoint ()
1486
1488
notification_type .emit (
1487
- user = contributor ,
1489
+ user = contrib_to_add ,
1490
+ message_frequency = FrequencyChoices .INSTANTLY .value ,
1488
1491
subscribed_object = self ,
1489
1492
event_context = event_context
1490
1493
)
0 commit comments