forked from mozilla/zamboni
/
log.py
261 lines (177 loc) · 5.77 KB
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
from collections import namedtuple
from celery.datastructures import AttributeDict
from tower import ugettext_lazy as _
__all__ = ('LOG', 'LOG_BY_ID', 'LOG_KEEP',)
_LOG = namedtuple('LOG', 'id format')
class CREATE_ADDON:
id = 1
format = _(u'{addon} was created.')
keep = True
class EDIT_PROPERTIES:
""" Expects: addon """
id = 2
format = _(u'{user.name} edited addon {addon} properties')
class EDIT_DESCRIPTIONS:
id = 3
format = _(u'{user.name} edited addon {addon} description')
class EDIT_CATEGORIES:
id = 4
format = _(u'{user.name} edited categories for {addon}')
class ADD_USER_WITH_ROLE:
id = 5
format = _(u'{user.name} added {0.name} to '
'addon {addon} with role {1}')
keep = True
class REMOVE_USER_WITH_ROLE:
id = 6
# L10n: {0} is the user being removed, {1} is their role.
format = _(u'{user.name} removed {0} with role {1}')
keep = True
class EDIT_CONTRIBUTIONS:
id = 7
format = _(u'{user.name} edited contributions for {addon}')
class SET_INACTIVE:
id = 8
format = _(u'{addon} set inactive')
keep = True
class UNSET_INACTIVE:
id = 9
format = _(u'{user.name} activated addon {addon}')
keep = True
class SET_PUBLIC_STATS:
id = 10
format = _(u'{user.name} set stats public for {addon}')
keep = True
class UNSET_PUBLIC_STATS:
id = 11
format = _(u'{user.name} set stats private for {addon}')
keep = True
class CHANGE_STATUS:
id = 12
# L10n: {0} is the status
format = _(u'{user.name} changed {addon} status to {0}')
keep = True
class ADD_PREVIEW:
id = 13
format = _(u'{user.name} added preview to {addon}')
class EDIT_PREVIEW:
id = 14
format = _(u'{user.name} edited preview for {addon}')
class DELETE_PREVIEW:
id = 15
format = _(u'{user.name} deleted preview from {addon}')
class ADD_VERSION:
id = 16
format = _(u'{version} added to {addon}.')
keep = True
class EDIT_VERSION:
id = 17
format = _(u'{user.name} edited version {0.version} of {addon}')
class DELETE_VERSION:
id = 18
format = _(u'{user.name} deleted version {0.version} from {addon}')
keep = True
class ADD_FILE_TO_VERSION:
id = 19
format = _(u'{user.name} added file {0.name} to '
'version {0.version} of {addon}')
class DELETE_FILE_FROM_VERSION:
""" Expecting: addon, filename, version
Because the file is being deleted, filename and version
should be strings and not the object.
"""
id = 20
format = _(u'File {0} deleted from {version} of {addon}')
class APPROVE_VERSION:
id = 21
format = _(u'Version {0.version} of {addon} approved')
keep = True
class RETAIN_VERSION:
id = 22
format = _(u'{user.name} retained version {0.version} of {addon}')
keep = True
class ESCALATE_VERSION:
id = 23
# L10n: {0.version} is the version of an addon.
format = _(u'{user.name} escalated review of {addon} {0.version}')
keep = True
class REQUEST_VERSION:
id = 24
# L10n: {0.version} is the version of an addon.
format = _(u'{user.name} requested more information regarding '
'{addon} {0.version}')
keep = True
class ADD_TAG:
id = 25
# L10n: {0} is the tag name.
format = _(u'{user.name} added tag {0} to {addon}')
class REMOVE_TAG:
id = 26
# L10n: {0} is the tag name.
format = _(u'{user.name} removed tag {0} from {addon}')
class ADD_TO_COLLECTION:
id = 27
format = _(u'{addon} added to {collection}.')
class REMOVE_FROM_COLLECTION:
id = 28
forma = _(u'{addon} removed from {collection}')
class ADD_REVIEW:
id = 29
format = _(u'{review} for {addon} written.')
class ADD_RECOMMENDED_CATEGORY:
id = 31
# L10n: {0} is a category name.
format = _(u'{addon} featured in {0}')
class REMOVE_RECOMMENDED_CATEGORY:
id = 32
# L10n: {0} is a category name.
format = _(u'{addon} no longer featured in {0}')
class ADD_RECOMMENDED:
id = 33
format = _(u'{addon} is now featured')
keep = True
class REMOVE_RECOMMENDED:
id = 34
format = _(u'{addon} is no longer featured')
keep = True
class ADD_APPVERSION:
id = 35
# L10n: {0} is the application, {1.min/max} is the min/max version of the
# app
format = _(u'addon now supports {0} {1.min}-{1.max}')
class CHANGE_USER_WITH_ROLE:
""" Expects: author.user, role, addon """
id = 36
format = _(u'{user.name} changed {0.name} for '
'addon {addon} with {1}')
keep = True
class CHANGE_LICENSE:
""" Expects: license, addon """
id = 37
format = _(u'{user.name} changed {addon} to '
'use license {0.name}')
class CHANGE_POLICY:
""" Expects: addon """
id = 38
format = _(u'{user.name} changed {addon} policy')
class CUSTOM_TEXT:
id = 98
format = '{0}'
class CUSTOM_HTML:
id = 99
format = '{0}'
LOGS = (CREATE_ADDON, EDIT_PROPERTIES, EDIT_DESCRIPTIONS, EDIT_CATEGORIES,
ADD_USER_WITH_ROLE, REMOVE_USER_WITH_ROLE, EDIT_CONTRIBUTIONS,
SET_INACTIVE, UNSET_INACTIVE, SET_PUBLIC_STATS, UNSET_PUBLIC_STATS,
CHANGE_STATUS, ADD_PREVIEW, EDIT_PREVIEW, DELETE_PREVIEW,
ADD_VERSION, EDIT_VERSION, DELETE_VERSION, ADD_FILE_TO_VERSION,
DELETE_FILE_FROM_VERSION, APPROVE_VERSION, RETAIN_VERSION,
ESCALATE_VERSION, REQUEST_VERSION, ADD_TAG, REMOVE_TAG,
ADD_TO_COLLECTION, REMOVE_FROM_COLLECTION, ADD_REVIEW,
ADD_RECOMMENDED_CATEGORY, REMOVE_RECOMMENDED_CATEGORY, ADD_RECOMMENDED,
REMOVE_RECOMMENDED, ADD_APPVERSION, CUSTOM_TEXT, CUSTOM_HTML,
CHANGE_USER_WITH_ROLE, CHANGE_LICENSE, CHANGE_POLICY
)
LOG_BY_ID = dict((l.id, l) for l in LOGS)
LOG = AttributeDict((l.__name__, l) for l in LOGS)
LOG_KEEP = (l.id for l in LOGS if hasattr(l, 'keep'))