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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
#
# ============LICENSE_START==========================================
# org.onap.vvp/engagementmgr
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# under the Apache License, Version 2.0 (the “License”);
# you may not use this software except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#
# Unless otherwise specified, all documentation contained herein is licensed
# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
# https://creativecommons.org/licenses/by/4.0/
#
# Unless required by applicable law or agreed to in writing, documentation
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ============LICENSE_END============================================
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
'''
Each entity has a model serializer that save/update the object in its create()/update() methods and a regular dictionary (map) serializer that return a new/updated instance of the object
'''
from rest_framework import serializers
from engagementmanager.models import NextStep, Notification, Activity, \
ChecklistTemplate, Checklist, ChecklistAuditLog, ChecklistDecision, \
ChecklistLineItem, ECOMPRelease, EngagementStatus, CustomUser, \
ChecklistSection
from .models import IceUserProfile, VFC, Engagement, VF, DeploymentTarget, Role, Vendor, DeploymentTargetSite
class RoleModelSerializer(serializers.ModelSerializer):
class Meta:
model = Role
fields = '__all__'
class VendorModelSerializer(serializers.ModelSerializer):
class Meta:
model = Vendor
fields = '__all__'
class ThinVendorModelSerializer(serializers.ModelSerializer):
class Meta:
model = Vendor
fields = ('uuid', 'name')
class SuperThinCustomUserModelSerializer(serializers.ModelSerializer):
class Meta:
model = CustomUser
fields = ('is_active', 'email', 'activation_token')
class ThinCustomUserModelSerializer(serializers.ModelSerializer):
class Meta:
model = CustomUser
fields = ('email', 'activation_token', 'is_active',
'activation_token_create_time')
class IceUserProfileModelSerializer(serializers.ModelSerializer):
role = RoleModelSerializer(many=False)
company = VendorModelSerializer(many=False)
user = ThinCustomUserModelSerializer(many=False)
class Meta:
model = IceUserProfile
class SuperThinIceUserProfileModelSerializer(serializers.ModelSerializer):
role = RoleModelSerializer(many=False)
company = VendorModelSerializer(many=False)
user = SuperThinCustomUserModelSerializer(many=False)
class Meta:
model = IceUserProfile
fields = ('full_name', 'email', 'uuid', 'role',
'user', 'company', 'phone_number')
class SuperThinIceUserProfileModelSerializerForSignals(serializers.ModelSerializer):
role = RoleModelSerializer(many=False)
class Meta:
model = IceUserProfile
fields = ('full_name', 'email', 'role', 'uuid', 'ssh_public_key')
class ThinIceUserProfileModelSerializer(serializers.ModelSerializer):
role = RoleModelSerializer(many=False)
company = VendorModelSerializer(many=False)
user = SuperThinCustomUserModelSerializer(many=False)
class Meta:
model = IceUserProfile
fields = ('email', 'full_name', 'user', 'is_service_provider_contact', 'phone_number', 'role', 'uuid', 'company',
'ssh_public_key', 'regular_email_updates', 'email_updates_on_every_notification',
'email_updates_daily_digest', 'rgwa_access_key')
class EngagementStatusModelSerializer(serializers.ModelSerializer):
creator = SuperThinIceUserProfileModelSerializer(many=False)
class Meta:
model = EngagementStatus
fields = '__all__'
class EngagementModelSerializer(serializers.ModelSerializer):
engagement_team = SuperThinIceUserProfileModelSerializer(many=True)
contact_user = SuperThinIceUserProfileModelSerializer(many=False)
creator = SuperThinIceUserProfileModelSerializer(many=False)
peer_reviewer = SuperThinIceUserProfileModelSerializer(many=False)
reviewer = SuperThinIceUserProfileModelSerializer(many=False)
starred_engagement = SuperThinIceUserProfileModelSerializer(many=True)
class Meta:
model = Engagement
fields = '__all__'
class ThinEngagementModelSerializer(serializers.ModelSerializer):
creator = SuperThinIceUserProfileModelSerializer(many=False)
engagement_team = SuperThinIceUserProfileModelSerializer(many=True)
peer_reviewer = SuperThinIceUserProfileModelSerializer(many=False)
reviewer = SuperThinIceUserProfileModelSerializer(many=False)
class Meta:
model = Engagement
fields = ('uuid', 'engagement_manual_id', 'creator',
'engagement_team', 'peer_reviewer', 'reviewer')
class DeploymentTargetModelSerializer(serializers.ModelSerializer):
class Meta:
model = DeploymentTarget
fields = ('uuid', 'name', 'version', 'weight', 'ui_visibility')
class ECOMPReleaseModelSerializer(serializers.ModelSerializer):
class Meta:
model = ECOMPRelease
fields = ('uuid', 'name', 'weight', 'ui_visibility')
class ThinVFModelSerializer(serializers.ModelSerializer):
engagement = ThinEngagementModelSerializer(many=False)
class Meta:
model = VF
fields = (
'uuid', 'name', 'engagement', 'is_service_provider_internal', 'ecomp_release')
class ThinDeploymentTargetSiteModelSerializer(serializers.ModelSerializer):
class Meta:
model = DeploymentTargetSite
fields = ('uuid', 'name')
class DeploymentTargetSiteModelSerializer(serializers.ModelSerializer):
class Meta:
model = DeploymentTargetSite
fields = '__all__'
class VFModelSerializer(serializers.ModelSerializer):
engagement = EngagementModelSerializer(many=False)
deployment_target = DeploymentTargetModelSerializer(many=False)
ecomp_release = ECOMPReleaseModelSerializer(many=False)
deployment_target_sites = ThinDeploymentTargetSiteModelSerializer(
many=True)
vendor = VendorModelSerializer(many=False)
class Meta:
model = VF
fields = '__all__'
class VFCModelSerializer(serializers.ModelSerializer):
class Meta:
model = VFC
fields = '__all__'
class ActivityModelSerializer(serializers.ModelSerializer):
class Meta:
model = Activity
fields = '__all__'
class ThinActivityModelSerializer(serializers.ModelSerializer):
class Meta:
model = Activity
fields = ('uuid', 'description', 'create_time', 'metadata')
class NotificationModelSerializer(serializers.ModelSerializer):
activity = ActivityModelSerializer(many=False)
class Meta:
model = Notification
fields = '__all__'
class ThinNotificationModelSerializer(serializers.ModelSerializer):
activity = ThinActivityModelSerializer(many=False)
class Meta:
model = Notification
fields = '__all__'
class ChecklistTemplateModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistTemplate
exclude = ('create_time', 'update_time', 'category', 'version')
class ThinChecklistTemplateModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistTemplate
fields = ('uuid', 'name')
class ChecklistModelSerializer(serializers.ModelSerializer):
class Meta:
model = Checklist
fields = '__all__'
class SuperThinChecklistModelSerializer(serializers.ModelSerializer):
owner = ThinIceUserProfileModelSerializer(many=False)
class Meta:
model = Checklist
fields = ('uuid', 'name', 'state', 'owner')
class ThinChecklistModelSerializer(serializers.ModelSerializer):
engagement = ThinEngagementModelSerializer(many=False)
template = ThinChecklistTemplateModelSerializer(many=False)
owner = ThinIceUserProfileModelSerializer(many=False)
class Meta:
model = Checklist
fields = ('uuid', 'name', 'state', 'owner', 'weight',
'associated_files', 'engagement', 'template')
class ThinPostChecklistResponseModelSerializer(serializers.ModelSerializer):
template = ThinChecklistTemplateModelSerializer(many=False)
class Meta:
model = Checklist
fields = ('uuid', 'name', 'state', 'associated_files', 'template')
class UserNextStepModelSerializer(serializers.ModelSerializer):
engagement_manual_id = serializers.CharField(
source='engagement.engagement_manual_id')
engagement_uuid = serializers.CharField(source='engagement.uuid')
creator_full_name = serializers.CharField(source='creator.full_name')
vf_name = serializers.CharField(source='engagement.vf.name')
class Meta:
model = NextStep
fields = ('due_date', 'engagement_manual_id', 'description',
'create_time', 'creator_full_name', 'vf_name', 'engagement_uuid')
class NextStepModelSerializer(serializers.ModelSerializer):
engagement = EngagementModelSerializer(many=False)
creator = SuperThinIceUserProfileModelSerializer(many=False)
last_updater = SuperThinIceUserProfileModelSerializer(many=False)
assignees = SuperThinIceUserProfileModelSerializer(many=True)
class Meta:
model = NextStep
fields = '__all__'
class ThinNextStepModelSerializer(serializers.ModelSerializer):
assignees = SuperThinIceUserProfileModelSerializer(many=True)
last_updater = SuperThinIceUserProfileModelSerializer(many=False)
class Meta:
ordering = ('position')
model = NextStep
fields = '__all__'
class TestEngineChecklistModelSerializer(serializers.ModelSerializer):
template_id = serializers.CharField(source='template.uuid')
engagement_manual_id = serializers.CharField(
source='engagement.engagement_manual_id')
engagement_id = serializers.CharField(source='engagement.uuid')
creator_id = serializers.CharField(source='engagement.creator.uuid')
class Meta:
model = Checklist
fields = ('uuid', 'state', 'associated_files', 'template_id',
'engagement_manual_id', 'engagement_id', 'creator_id')
class ChecklistAuditLogModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistAuditLog
fields = '__all__'
class ThinChecklistAuditLogModelSerializer(serializers.ModelSerializer):
creator = SuperThinIceUserProfileModelSerializer(many=False)
class Meta:
model = ChecklistAuditLog
fields = ('uuid', 'category', 'description', 'create_time', 'creator')
class ChecklistSectionModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistSection
exclude = ('template', 'parent_section', 'create_time', 'update_time')
class ChecklistLineItemModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistLineItem
exclude = ('section', 'template', 'create_time', 'update_time')
class ThinChecklistSectionModelSerializer(serializers.ModelSerializer):
class Meta:
model = ChecklistLineItem
fields = ('uuid', 'name', 'weight', 'description')
class ThinChecklistLineItemModelSerializer(serializers.ModelSerializer):
section = ThinChecklistSectionModelSerializer(many=False)
class Meta:
model = ChecklistLineItem
fields = ('uuid', 'name', 'line_type', 'weight',
'description', 'validation_instructions', 'section')
class ThinChecklistDecisionModelSerializer(serializers.ModelSerializer):
lineitem = ThinChecklistLineItemModelSerializer(many=False)
class Meta:
model = ChecklistDecision
fields = ('uuid', 'review_value', 'peer_review_value', 'lineitem')
class EngagementModelSerializerForSignal(serializers.ModelSerializer):
engagement_team = SuperThinIceUserProfileModelSerializerForSignals(
many=True)
contact_user = SuperThinIceUserProfileModelSerializerForSignals(many=False)
creator = SuperThinIceUserProfileModelSerializerForSignals(many=False)
peer_reviewer = SuperThinIceUserProfileModelSerializerForSignals(
many=False)
reviewer = SuperThinIceUserProfileModelSerializerForSignals(many=False)
starred_engagement = SuperThinIceUserProfileModelSerializerForSignals(
many=True)
class Meta:
model = Engagement
fields = '__all__'
class VFModelSerializerForSignal(serializers.ModelSerializer):
engagement = EngagementModelSerializerForSignal(many=False)
deployment_target = DeploymentTargetModelSerializer(many=False)
ecomp_release = ECOMPReleaseModelSerializer(many=False)
deployment_target_sites = ThinDeploymentTargetSiteModelSerializer(
many=True)
vendor = VendorModelSerializer(many=False)
class Meta:
model = VF
fields = '__all__'
|