Revision 8fb8d0cf snf-astakos-app/astakos/im/project_notif.py

b/snf-astakos-app/astakos/im/project_notif.py
7 7
logger = logging.getLogger(__name__)
8 8

  
9 9
MEM_CHANGE_NOTIF = {
10
    'subject' : _(messages.PROJECT_MEMBERSHIP_CHANGE_SUBJECT),
10
    'subject':   _(messages.PROJECT_MEMBERSHIP_CHANGE_SUBJECT),
11 11
    'template': 'im/projects/project_membership_change_notification.txt',
12
    }
12
}
13 13

  
14 14
MEM_ENROLL_NOTIF = {
15
    'subject' : _(messages.PROJECT_MEMBERSHIP_ENROLL_SUBJECT),
15
    'subject':   _(messages.PROJECT_MEMBERSHIP_ENROLL_SUBJECT),
16 16
    'template': 'im/projects/project_membership_enroll_notification.txt',
17
    }
17
}
18 18

  
19 19
SENDER = settings.SERVER_EMAIL
20 20
NOTIFY_RECIPIENTS = [e[1] for e in settings.MANAGERS + settings.HELPDESK]
21 21

  
22

  
22 23
def membership_change_notify(project, user, action):
23 24
    try:
24 25
        notification = build_notification(
25 26
            SENDER,
26 27
            [user.email],
27 28
            MEM_CHANGE_NOTIF['subject'] % project.__dict__,
28
            template= MEM_CHANGE_NOTIF['template'],
29
            dictionary={'object':project, 'action':action})
29
            template=MEM_CHANGE_NOTIF['template'],
30
            dictionary={'object': project, 'action': action})
30 31
        notification.send()
31 32
    except NotificationError, e:
32 33
        logger.error(e.message)
33 34

  
35

  
34 36
def membership_enroll_notify(project, user):
35 37
    try:
36 38
        notification = build_notification(
37 39
            SENDER,
38 40
            [user.email],
39 41
            MEM_ENROLL_NOTIF['subject'] % project.__dict__,
40
            template= MEM_ENROLL_NOTIF['template'],
41
            dictionary={'object':project})
42
            template=MEM_ENROLL_NOTIF['template'],
43
            dictionary={'object': project})
42 44
        notification.send()
43 45
    except NotificationError, e:
44 46
        logger.error(e.message)
45 47

  
48

  
46 49
def membership_request_notify(project, requested_user):
47 50
    try:
48 51
        notification = build_notification(
49 52
            SENDER,
50 53
            [project.application.owner.email],
51 54
            _(messages.PROJECT_MEMBERSHIP_REQUEST_SUBJECT) % project.__dict__,
52
            template= 'im/projects/project_membership_request_notification.txt',
53
            dictionary={'object':project, 'user':requested_user.email})
55
            template='im/projects/project_membership_request_notification.txt',
56
            dictionary={'object': project, 'user': requested_user.email})
54 57
        notification.send()
55 58
    except NotificationError, e:
56 59
        logger.error(e.message)
57 60

  
61

  
58 62
def membership_leave_request_notify(project, requested_user):
63
    template = 'im/projects/project_membership_leave_request_notification.txt'
59 64
    try:
60 65
        notification = build_notification(
61 66
            SENDER,
62 67
            [project.application.owner.email],
63 68
            _(messages.PROJECT_MEMBERSHIP_LEAVE_REQUEST_SUBJECT) %
64 69
            project.__dict__,
65
            template= 'im/projects/project_membership_leave_request_notification.txt',
66
            dictionary={'object':project, 'user':requested_user.email})
70
            template=template,
71
            dictionary={'object': project, 'user': requested_user.email})
67 72
        notification.send()
68 73
    except NotificationError, e:
69 74
        logger.error(e.message)
70 75

  
76

  
71 77
def application_submit_notify(application):
72 78
    try:
73 79
        notification = build_notification(
74 80
            SENDER, NOTIFY_RECIPIENTS,
75 81
            _(messages.PROJECT_CREATION_SUBJECT) % application.__dict__,
76 82
            template='im/projects/project_creation_notification.txt',
77
            dictionary={'object':application})
83
            dictionary={'object': application})
78 84
        notification.send()
79 85
    except NotificationError, e:
80 86
        logger.error(e.message)
81 87

  
88

  
82 89
def application_deny_notify(application):
83 90
    try:
84 91
        notification = build_notification(
......
86 93
            [application.owner.email],
87 94
            _(messages.PROJECT_DENIED_SUBJECT) % application.__dict__,
88 95
            template='im/projects/project_denial_notification.txt',
89
            dictionary={'object':application})
96
            dictionary={'object': application})
90 97
        notification.send()
91 98
    except NotificationError, e:
92 99
        logger.error(e.message)
93 100

  
101

  
94 102
def application_approve_notify(application):
95 103
    try:
96 104
        notification = build_notification(
......
98 106
            [application.owner.email],
99 107
            _(messages.PROJECT_APPROVED_SUBJECT) % application.__dict__,
100 108
            template='im/projects/project_approval_notification.txt',
101
            dictionary={'object':application})
109
            dictionary={'object': application})
102 110
        notification.send()
103 111
    except NotificationError, e:
104 112
        logger.error(e.message)
105 113

  
114

  
106 115
def project_termination_notify(project):
107 116
    try:
108 117
        notification = build_notification(
......
110 119
            [project.application.owner.email],
111 120
            _(messages.PROJECT_TERMINATION_SUBJECT) % project.__dict__,
112 121
            template='im/projects/project_termination_notification.txt',
113
            dictionary={'object':project}
122
            dictionary={'object': project}
114 123
        ).send()
115 124
    except NotificationError, e:
116 125
        logger.error(e.message)
117 126

  
127

  
118 128
def project_suspension_notify(project):
119 129
    try:
120 130
        notification = build_notification(
......
122 132
            [project.application.owner.email],
123 133
            _(messages.PROJECT_SUSPENSION_SUBJECT) % project.__dict__,
124 134
            template='im/projects/project_suspension_notification.txt',
125
            dictionary={'object':project}
135
            dictionary={'object': project}
126 136
        ).send()
127 137
    except NotificationError, e:
128 138
        logger.error(e.message)

Also available in: Unified diff