-
Notifications
You must be signed in to change notification settings - Fork 45
/
repository.go
1113 lines (1045 loc) · 59.8 KB
/
repository.go
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright The Linux Foundation and each contributor to CommunityBridge.
// SPDX-License-Identifier: MIT
package template
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"time"
"github.com/communitybridge/easycla/cla-backend-go/utils"
"github.com/sirupsen/logrus"
log "github.com/communitybridge/easycla/cla-backend-go/logging"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/communitybridge/easycla/cla-backend-go/gen/v1/models"
)
var (
// ErrTemplateNotFound error
ErrTemplateNotFound = errors.New("template not found")
)
var (
// ApacheStyleTemplateID is template ID of the Apache Style
ApacheStyleTemplateID = "fb4cc144-a76c-4c17-8a52-c648f158fded"
// ASWFStyleTemplateID is template id for ASWF
ASWFStyleTemplateID = "18b8ad08-d7d4-4d75-ad25-30bbfffd59cf"
)
// RepositoryInterface interface functions
type RepositoryInterface interface {
GetTemplates(ctx context.Context) ([]models.Template, error)
GetTemplateName(ctx context.Context, templateID string) (string, error)
GetTemplate(templateID string) (models.Template, error)
CLAGroupTemplateExists(ctx context.Context, templateID string) bool
GetCLAGroup(claGroupID string) (*models.ClaGroup, error)
GetCLADocuments(claGroupID string, claType string) ([]models.ClaGroupDocument, error)
UpdateDynamoContractGroupTemplates(ctx context.Context, ContractGroupID string, template models.Template, pdfUrls models.TemplatePdfs, projectCCLAEnabled, projectICLAEnabled bool) error
}
// Repository object/struct
type Repository struct {
stage string // The AWS stage (dev, staging, prod)
dynamoDBClient *dynamodb.DynamoDB
}
// CLAGroup structure
type CLAGroup struct {
}
// DynamoProjectCorporateDocuments model
type DynamoProjectCorporateDocuments struct {
DynamoProjectDocument []DynamoProjectDocument `json:":project_corporate_documents"`
}
// DynamoProjectIndividualDocuments model
type DynamoProjectIndividualDocuments struct {
DynamoProjectDocument []DynamoProjectDocument `json:":project_individual_documents"`
}
// DynamoProjectDocument model
type DynamoProjectDocument struct {
DocumentName string `json:"document_name"`
DocumentFileID string `json:"document_file_id"`
DocumentContentType string `json:"document_content_type"`
DocumentMajorVersion int `json:"document_major_version"`
DocumentMinorVersion int `json:"document_minor_version"`
DocumentCreationDate string `json:"document_creation_date"`
DocumentPreamble string `json:"document_preamble"`
DocumentLegalEntityName string `json:"document_legal_entity_name"`
DocumentAuthorName string `json:"document_author_name"`
DocumentS3URL string `json:"document_s3_url"`
DocumentTabs []DocumentTab `json:"document_tabs"`
}
// DocumentTab structure
type DocumentTab struct {
// Note: these are arranged to optimize structure memory alignment - see the lint: maligned
DocumentTabType string `json:"document_tab_type"`
DocumentTabID string `json:"document_tab_id"`
DocumentTabName string `json:"document_tab_name"`
DocumentTabAnchorString string `json:"document_tab_anchor_string"`
DocumentTabPage int64 `json:"document_tab_page"`
DocumentTabWidth int64 `json:"document_tab_width"`
DocumentTabAnchorXOffset int64 `json:"document_tab_anchor_x_offset"`
DocumentTabAnchorYOffset int64 `json:"document_tab_anchor_y_offset"`
DocumentTabPositionX int64 `json:"document_tab_position_x"`
DocumentTabPositionY int64 `json:"document_tab_position_y"`
DocumentTabHeight int64 `json:"document_tab_height"`
DocumentTabIsLocked bool `json:"document_tab_is_locked"`
DocumentTabIsRequired bool `json:"document_tab_is_required"`
DocumentTabAnchorIgnoreIfNotPresent bool `json:"document_tab_anchor_ignore_if_not_present"`
}
// NewRepository creates a new instance of the Repository service
func NewRepository(awsSession *session.Session, stage string) Repository {
return Repository{
stage: stage,
dynamoDBClient: dynamodb.New(awsSession),
}
}
// GetTemplates returns a list containing all the template models
func (r Repository) GetTemplates(ctx context.Context) ([]models.Template, error) {
f := logrus.Fields{
"functionName": "GetTemplates",
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
}
log.WithFields(f).Debug("Loading templates...")
var templates []models.Template
for _, template := range templateMap {
templates = append(templates, template)
}
// Sort the template list based on the name
log.WithFields(f).Debug("Sorting templates...")
sort.Slice(templates, func(i, j int) bool {
return strings.ToLower(templates[i].Name) < strings.ToLower(templates[j].Name)
})
return templates, nil
}
// GetTemplateName returns the template name when provided the template ID
func (r Repository) GetTemplateName(ctx context.Context, templateID string) (string, error) {
f := logrus.Fields{
"functionName": "v1.template.repository.GetTemplateName",
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
"templateID": templateID,
}
// For each template...
for _, template := range templateMap {
// If we have a match
if template.ID == templateID {
return template.Name, nil
}
}
log.WithFields(f).Warnf("unable to locate template with ID: %s", templateID)
return "", nil
}
// GetTemplate returns the template based on the template ID
func (r Repository) GetTemplate(templateID string) (models.Template, error) {
template, ok := templateMap[templateID]
if !ok {
return models.Template{}, ErrTemplateNotFound
}
return template, nil
}
// CLAGroupTemplateExists return true if the specified template ID exists, false otherwise
func (r Repository) CLAGroupTemplateExists(ctx context.Context, templateID string) bool {
_, ok := templateMap[templateID]
return ok
}
// GetCLAGroup This method belongs in the contract group package. We are leaving it here
// because it accesses DynamoDB, but the contract group Repository is designed
// to connect to postgres
func (r Repository) GetCLAGroup(claGroupID string) (*models.ClaGroup, error) {
log.Debugf("GetCLAGroup - claGroupID: %s", claGroupID)
dbModel, err := r.fetchCLAGroup(claGroupID)
if err != nil {
return nil, err
}
return r.buildProjectModel(*dbModel), nil
}
// GetCLADocuments fetches the cla documents inside of the CLA Group, it's separate method for perf reasons
func (r Repository) GetCLADocuments(claGroupID string, claType string) ([]models.ClaGroupDocument, error) {
log.Debugf("GetCLADocuments - claGroupID: %s - claType : %s", claGroupID, claType)
dbModel, err := r.fetchCLAGroup(claGroupID)
if err != nil {
return nil, err
}
var projectDocuments []models.ClaGroupDocument
switch claType {
case "icla":
projectDocuments = r.buildProjectDocuments(dbModel.ProjectIndividualDocuments)
case "ccla":
projectDocuments = r.buildProjectDocuments(dbModel.ProjectCorporateDocuments)
default:
return nil, fmt.Errorf("not supported cla type supplied")
}
return projectDocuments, nil
}
func (r Repository) buildProjectDocuments(dbProjectDocumentModels []DBProjectDocumentModel) []models.ClaGroupDocument {
if len(dbProjectDocumentModels) == 0 {
return nil
}
var projectDocuments []models.ClaGroupDocument
for _, dbProjectDocumentModel := range dbProjectDocumentModels {
projectDocuments = append(projectDocuments, models.ClaGroupDocument{
DocumentAuthorName: dbProjectDocumentModel.DocumentAuthorName,
DocumentContentType: dbProjectDocumentModel.DocumentContentType,
DocumentCreationDate: dbProjectDocumentModel.DocumentCreationDate,
DocumentFileID: dbProjectDocumentModel.DocumentFileID,
DocumentLegalEntityName: dbProjectDocumentModel.DocumentLegalEntityName,
DocumentMajorVersion: dbProjectDocumentModel.DocumentMajorVersion,
DocumentMinorVersion: dbProjectDocumentModel.DocumentMinorVersion,
DocumentName: dbProjectDocumentModel.DocumentName,
DocumentPreamble: dbProjectDocumentModel.DocumentPreamble,
DocumentS3URL: dbProjectDocumentModel.DocumentS3URL,
})
}
return projectDocuments
}
// fetchCLAGroup brings back the CLA db model from dynamodb
func (r Repository) fetchCLAGroup(claGroupID string) (*DBProjectModel, error) {
var dbModel DBProjectModel
tableName := fmt.Sprintf("cla-%s-projects", r.stage)
result, err := r.dynamoDBClient.GetItem(&dynamodb.GetItemInput{
TableName: aws.String(tableName),
Key: map[string]*dynamodb.AttributeValue{
"project_id": {
S: aws.String(claGroupID),
},
},
})
if err != nil {
log.Warnf("error getting CLAGroup: %+v", err)
}
err = dynamodbattribute.UnmarshalMap(result.Item, &dbModel)
if err != nil {
log.Warnf("error unmarshalling db project model, error: %+v", err)
return nil, err
}
return &dbModel, nil
}
// buildProjectModel maps the database model to the API response model
func (r Repository) buildProjectModel(dbModel DBProjectModel) *models.ClaGroup {
return &models.ClaGroup{
ProjectID: dbModel.ProjectID,
ProjectExternalID: dbModel.ProjectExternalID,
ProjectName: dbModel.ProjectName,
ProjectACL: dbModel.ProjectACL,
ProjectCCLAEnabled: dbModel.ProjectCclaEnabled,
ProjectICLAEnabled: dbModel.ProjectIclaEnabled,
ProjectCCLARequiresICLA: dbModel.ProjectCclaRequiresIclaSignature,
DateCreated: dbModel.DateCreated,
DateModified: dbModel.DateModified,
Version: dbModel.Version,
}
}
// UpdateDynamoContractGroupTemplates updates the templates in the data store
func (r Repository) UpdateDynamoContractGroupTemplates(ctx context.Context, claGroupID string, template models.Template, pdfUrls models.TemplatePdfs, projectCCLAEnabled, projectICLAEnabled bool) error {
f := logrus.Fields{
"functionName": "UpdateDynamoContractGroupTemplates",
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
"claGroupID": claGroupID,
"templateID": template.ID,
"templateName": template.Name,
"cclaEnabled": projectCCLAEnabled,
"iclaEnabled": projectICLAEnabled,
}
tableName := fmt.Sprintf("cla-%s-projects", r.stage)
// Find Contract Group to update the Templates on
key := map[string]*dynamodb.AttributeValue{
"project_id": {
S: aws.String(claGroupID),
},
}
if projectCCLAEnabled {
log.WithFields(f).Debugf("updating CLA Group %s document list...", utils.ClaTypeCCLA)
// Map the fields to the dynamo model as the attribute names are different
// Map Template Fields into DocumentTab
var cclaDocumentTabs []DocumentTab
for _, field := range template.CclaFields {
dynamoTab := DocumentTab{
DocumentTabType: field.FieldType,
DocumentTabID: field.ID,
DocumentTabPage: 1,
DocumentTabName: field.Name,
DocumentTabWidth: field.Width,
DocumentTabHeight: field.Height,
DocumentTabIsLocked: field.IsEditable,
DocumentTabAnchorString: field.AnchorString,
DocumentTabIsRequired: field.IsOptional,
DocumentTabAnchorIgnoreIfNotPresent: field.IsOptional,
DocumentTabAnchorXOffset: field.OffsetX,
DocumentTabAnchorYOffset: field.OffsetY,
DocumentTabPositionX: 0,
DocumentTabPositionY: 0,
}
cclaDocumentTabs = append(cclaDocumentTabs, dynamoTab)
}
currentTime := time.Now().Format(time.RFC3339)
// Map Template to Document
majorVersion := int(template.TemplateMajorVersion)
minorVersion := int(template.TemplateMinorVersion)
dynamoCorporateProjectDocument := DynamoProjectDocument{
DocumentName: template.Name,
DocumentFileID: template.ID,
DocumentContentType: "storage+pdf",
DocumentMajorVersion: majorVersion,
DocumentMinorVersion: minorVersion,
DocumentCreationDate: currentTime,
DocumentPreamble: template.Name,
DocumentLegalEntityName: template.Name,
DocumentAuthorName: template.Name,
DocumentS3URL: pdfUrls.CorporatePDFURL,
DocumentTabs: cclaDocumentTabs,
}
// project_corporate_documents is a List type, and thus the item needs to be in a slice
var dynamoCorporateProjectDocuments []DynamoProjectDocument
dynamoCorporateProjectDocuments = append(dynamoCorporateProjectDocuments, dynamoCorporateProjectDocument)
// Marshal object into dynamodb attribute
expr, err := dynamodbattribute.MarshalList(dynamoCorporateProjectDocuments)
if err != nil {
log.WithFields(f).Warnf("Error updating the CLA Group corporate document with template from: %s, error: %+v", template.Name, err)
return err
}
_, now := utils.CurrentTime()
log.WithFields(f).Debugf("Updating table %s with corporate template details - CLA Group id: %s.", tableName, claGroupID)
input := &dynamodb.UpdateItemInput{
ExpressionAttributeNames: map[string]*string{
"#project_corporate_documents": aws.String("project_corporate_documents"),
"#date_modified": aws.String("date_modified"),
},
//ExpressionAttributeValues: expr,
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":project_corporate_documents": {
L: expr,
},
":date_modified": {
S: aws.String(now),
},
}, TableName: aws.String(tableName),
Key: key,
ReturnValues: aws.String("UPDATED_NEW"),
UpdateExpression: aws.String("set #date_modified = :date_modified, #project_corporate_documents = list_append(#project_corporate_documents, :project_corporate_documents)"),
}
_, err = r.dynamoDBClient.UpdateItem(input)
if err != nil {
log.WithFields(f).Warnf("Error updating the CLA Group corporate document with template from: %s, error: %+v", template.Name, err)
return err
}
}
if projectICLAEnabled {
log.WithFields(f).Debugf("updating CLA Group %s document list...", utils.ClaTypeCCLA)
// Map ICLA Template Fields into DocumentTab
var iclaDocumentTabs []DocumentTab
for _, field := range template.IclaFields {
dynamoTab := DocumentTab{
DocumentTabType: field.FieldType,
DocumentTabID: field.ID,
DocumentTabPage: 1,
DocumentTabName: field.Name,
DocumentTabWidth: field.Width,
DocumentTabHeight: field.Height,
DocumentTabIsLocked: field.IsEditable,
DocumentTabIsRequired: field.IsOptional,
DocumentTabAnchorString: field.AnchorString,
DocumentTabAnchorIgnoreIfNotPresent: field.IsOptional,
DocumentTabAnchorXOffset: field.OffsetX,
DocumentTabAnchorYOffset: field.OffsetY,
DocumentTabPositionX: 0,
DocumentTabPositionY: 0,
}
iclaDocumentTabs = append(iclaDocumentTabs, dynamoTab)
}
currentTime := time.Now().Format(time.RFC3339)
// Map Template to Document
majorVersion := int(template.TemplateMajorVersion)
minorVersion := int(template.TemplateMinorVersion)
dynamoIndividualDocument := DynamoProjectDocument{
DocumentName: template.Name,
DocumentFileID: template.ID,
DocumentContentType: "storage+pdf",
DocumentMajorVersion: majorVersion,
DocumentMinorVersion: minorVersion,
DocumentCreationDate: currentTime,
DocumentPreamble: template.Name,
DocumentLegalEntityName: template.Name,
DocumentAuthorName: template.Name,
DocumentS3URL: pdfUrls.IndividualPDFURL,
DocumentTabs: iclaDocumentTabs,
}
var dynamoProjectIndividualDocuments []DynamoProjectDocument
dynamoProjectIndividualDocuments = append(dynamoProjectIndividualDocuments, dynamoIndividualDocument)
expr, err := dynamodbattribute.MarshalList(dynamoProjectIndividualDocuments)
if err != nil {
log.WithFields(f).Warnf("Error updating the CLA Group individual document with template from: %s, error: %+v", template.Name, err)
return err
}
_, now := utils.CurrentTime()
log.WithFields(f).Debugf("Updating table %s with individual template details - CLA Group id: %s.", tableName, claGroupID)
input := &dynamodb.UpdateItemInput{
ExpressionAttributeNames: map[string]*string{
"#project_individual_documents": aws.String("project_individual_documents"),
"#date_modified": aws.String("date_modified"),
},
//ExpressionAttributeValues: expr,
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":project_individual_documents": {
L: expr,
},
":date_modified": {
S: aws.String(now),
},
},
TableName: aws.String(tableName),
Key: key,
ReturnValues: aws.String("UPDATED_NEW"),
UpdateExpression: aws.String("set #date_modified = :date_modified, #project_individual_documents = list_append(#project_individual_documents, :project_individual_documents)"),
}
log.WithFields(f).Debugf("Updating table %s with individual template details - CLA Group id: %s.", tableName, claGroupID)
_, err = r.dynamoDBClient.UpdateItem(input)
if err != nil {
log.WithFields(f).Warnf("Error updating the CLA Group individual document with template from: %s, error: %+v", template.Name, err)
return err
}
}
return nil
}
// templateMap contains a list of our template models
var templateMap = map[string]models.Template{
ApacheStyleTemplateID: {
ID: ApacheStyleTemplateID,
Name: "Apache Style",
Description: "For use of projects under the Apache style of CLA.",
TemplateMajorVersion: 2,
TemplateMinorVersion: 0,
MetaFields: []*models.MetaField{
{
Name: "Project Name",
Description: "Project's Full Name.",
TemplateVariable: "PROJECT_NAME",
},
{
Name: "Project Entity Name",
Description: "The Full Entity Name of the Project.",
TemplateVariable: "PROJECT_ENTITY_NAME",
},
{
Name: "Contact Email Address",
Description: "The E-Mail Address of the Person managing the CLA.",
TemplateVariable: "CONTACT_EMAIL",
},
},
IclaFields: []*models.Field{
{
ID: "full_name",
Name: "Full Name",
AnchorString: "Full name:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 65, // 55 need to move over
OffsetY: -8,
},
{
ID: "mailing_address1",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 300,
Height: 20,
OffsetX: 105,
OffsetY: -7,
},
{
ID: "mailing_address2",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 0,
OffsetY: 20,
},
{
ID: "mailing_address3",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_optional",
IsOptional: true,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 0, // should be aligned with the above
OffsetY: 48, // 47 should move down some
},
{
ID: "country",
Name: "Country",
AnchorString: "Country:",
FieldType: "text_unlocked",
IsOptional: true,
IsEditable: false,
Width: 300,
Height: 20,
OffsetX: 60, // 50 slightly move over to give it some space
OffsetY: -7,
},
{
ID: "email",
Name: "Email",
AnchorString: "E-Mail:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 300, // 320 same length as above
Height: 20,
OffsetX: 60, // 40 move over a bit
OffsetY: -8,
},
{
ID: "sign",
Name: "Please Sign",
AnchorString: "Please Sign:",
FieldType: "sign",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 80, // 70 move to the right some
OffsetY: -5,
},
{
ID: "date",
Name: "Date",
AnchorString: "Date:",
FieldType: "date",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 40, // 30 move to the right some
OffsetY: -7,
},
},
CclaFields: []*models.Field{
{
ID: "sign",
Name: "Please Sign",
AnchorString: "Please sign:",
FieldType: "sign",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 100,
OffsetY: -6,
},
{
ID: "date",
Name: "Date",
AnchorString: "Date:",
FieldType: "date",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 40,
OffsetY: -7,
},
{
ID: "signatory_name",
Name: "Signatory Name",
AnchorString: "Signatory Name:",
FieldType: "text",
IsOptional: false,
IsEditable: false,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -5,
},
{
ID: "signatory_email",
Name: "Signatory E-mail",
AnchorString: "Signatory E-mail:",
FieldType: "text",
IsOptional: false,
IsEditable: false,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -5,
},
{
ID: "signatory_title",
Name: "Signatory Title",
AnchorString: "Signatory Title:",
FieldType: "text",
IsOptional: true,
IsEditable: true,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -6,
},
{
ID: "corporation_name",
Name: "Corporation Name",
AnchorString: "Corporation Name:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 355,
Height: 20,
OffsetX: 130,
OffsetY: -5,
},
{
ID: "corporation_address1",
Name: "Corporation Address1",
AnchorString: "Corporation Address:",
FieldType: "text",
IsOptional: false,
IsEditable: true,
Width: 230,
Height: 20,
OffsetX: 135,
OffsetY: -8,
},
{
ID: "corporation_address2",
Name: "Corporation Address2",
AnchorString: "Corporation Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: true,
Width: 350,
Height: 20,
OffsetX: 0,
OffsetY: 20,
},
{
ID: "corporation_address3",
Name: "Corporation Address3",
AnchorString: "Corporation Address:",
FieldType: "text_optional",
IsOptional: true,
IsEditable: true,
Width: 350,
Height: 20,
OffsetX: 0,
OffsetY: 50,
},
{
ID: "cla_manager_name",
Name: "Initial CLA Manager Name",
AnchorString: "Initial CLA Manager Name:",
FieldType: "text",
IsOptional: false,
IsEditable: false,
Width: 385,
Height: 20,
OffsetX: 190,
OffsetY: -7,
},
{
ID: "cla_manager_email",
Name: "Initial CLA Manager Email",
AnchorString: "Initial CLA Manager E-Mail:",
FieldType: "text",
IsOptional: false,
IsEditable: false,
Width: 385,
Height: 20,
OffsetX: 190,
OffsetY: -7,
},
},
IclaHTMLBody: `
<html><body>
<p>
Project Name: {{ PROJECT_NAME }}</br>
Project Entity: {{ PROJECT_ENTITY_NAME }}</br>
If emailing signed PDF, send to: {{ CONTACT_EMAIL }}
</p>
<h3 style="text-align: center">Individual Contributor License Agreement (“Agreement”) v2.0</h3>
<p>Thank you for your interest in the project specified above (the “Project”). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Project must have a Contributor License Agreement (CLA) on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Project and its users; it does not change your rights to use your own Contributions for any other purpose. </p>
<p>If you have not already done so, please complete and sign this Agreement using the electronic signature portal made available to you by the Project or its third-party service providers, or email a PDF of the signed agreement to the email address specified above. Please read this document carefully before signing and keep a copy for your records.</p>
<p>You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Project. In return, the Project shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with its charter at the time of the Contribution. Except for the license granted herein to the Project and recipients of software distributed by the Project, You reserve all right, title, and interest in and to Your Contributions.</p>
<p>1. Definitions.</p>
<p>“You” (or “Your”) shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the Project. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.</p>
<p>“Contribution” shall mean the code, documentation or other original works of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Project for inclusion in, or documentation of, any of the products owned or managed by the Project (the “Work”). For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Project or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as “Not a Contribution.”</p>
<p>2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.</p>
<p>3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) were submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.</p>
<p>4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Project, or that your employer has executed a separate Corporate CLA with the Project.</p>
<p>5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.</p>
<p>6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.</p>
<p>7. Should You wish to submit work that is not Your original creation, You may submit it to the Project separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as “Submitted on behalf of a third-party: [named here]”.</p>
<p>8. You agree to notify the Project of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.</p>
<p style="page-break-after: always; text-align: center">[Please complete and sign on the next page.]</p>
<p>Please sign: __________________________________ Date: _______________ </p>
<p>Full name: __________________________________________________________ </p>
<p>Mailing Address: ____________________________________________________ </p>
<p>_____________________________________________________________________ </p>
<p>_____________________________________________________________________ </p>
<p>Country: ________________________________________</p>
<p>E-Mail: _________________________________________</p>
</body></html>
`,
CclaHTMLBody: `
<html><body>
<p>
Project Name: {{ PROJECT_NAME }}</br>
Project Entity: {{ PROJECT_ENTITY_NAME }}</br>
If emailing signed PDF, send to: {{ CONTACT_EMAIL }}
</p>
<h3 style="text-align: center"> Software Grant and Corporate Contributor License Agreement (“Agreement”) v2.0 </h3>
<p>Thank you for your interest in the project specified above (the “Project”). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Project must have a Contributor License Agreement (CLA) on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Project and its users; it does not change your rights to use your own Contributions for any other purpose. </p>
<p>This version of the Agreement allows an entity (the “Corporation”) to submit Contributions to the Project, to authorize Contributions submitted by its designated employees to the Project, and to grant copyright and patent licenses thereto. </p>
<p>If you have not already done so, please complete and sign this Agreement using the electronic signature portal made available to you by the Project or its third-party service providers, or email a PDF of the signed agreement to the email address specified above. Please read this document carefully before signing and keep a copy for your records. </p>
<p>You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Project. In return, the Project shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with its charter at the time of the Contribution. Except for the license granted herein to the Project and recipients of software distributed by the Project, You reserve all right, title, and interest in and to Your Contributions. </p>
<p>1. Definitions. </p>
<p>“You” (or “Your”) shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the Project. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.</p>
<p>“Contribution” shall mean the code, documentation or other original works of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Project for inclusion in, or documentation of, any of the products owned or managed by the Project (the “Work”). For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Project or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as “Not a Contribution.” </p>
<p>2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.</p>
<p>3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) were submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. </p>
<p>4. You represent that You are legally entitled to grant the above license. You represent further that the employee of the Corporation designated as the Initial CLA Manager below (and each who is designated in a subsequent written modification to the list of CLA Managers) (each, a “CLA Manager”) is authorized to maintain (1) the list of employees of the Corporation who are authorized to submit Contributions on behalf of the Corporation, and (2) the list of CLA Managers; in each case, using the designated system for managing such lists (the “CLA Tool”).</p>
<p>5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others).</p>
<p>6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.</p>
<p>7. Should You wish to submit work that is not Your original creation, You may submit it to the Project separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as “Submitted on behalf of a third-party: [named here]”.</p>
<p>8. It is your responsibility to use the CLA Tool when any change is required to the list of designated employees authorized to submit Contributions on behalf of the Corporation, or to the list of the CLA Managers.</p>
<p style="page-break-after: always; text-align: center">[Please complete and sign on the next page.]</p>
<p>Please sign: __________________________________ Date: _______________ </p>
<p>Signatory Name: ______________________________________________________</p>
<p>Signatory E-mail: ____________________________________________________</p>
<p>Signatory Title: _____________________________________________________</p>
<p>Corporation Name: ____________________________________________________</p>
<p>Corporation Address: _________________________________________________</p>
<p>______________________________________________________________________</p>
<p>______________________________________________________________________</p>
<p>Initial CLA Manager Name: ____________________________________________</p>
<p>Initial CLA Manager E-Mail: __________________________________________</p>
</body></html>`,
},
ASWFStyleTemplateID: {
ID: ASWFStyleTemplateID,
Name: "ASWF 2020 v2.1",
Description: "For use of projects under the ASWF 2020 v2.1 of CLA.",
TemplateMajorVersion: 2,
TemplateMinorVersion: 1,
MetaFields: []*models.MetaField{
{
Name: "Project Name",
Description: "Project's Full Name.",
TemplateVariable: "PROJECT_NAME",
},
{
Name: "Project Entity Name",
Description: "The Full Entity Name of the Project.",
TemplateVariable: "PROJECT_ENTITY_NAME",
},
{
Name: "Contact Email Address",
Description: "The E-Mail Address of the Person managing the CLA.",
TemplateVariable: "CONTACT_EMAIL",
},
},
IclaFields: []*models.Field{
{
ID: "full_name",
Name: "Full Name",
AnchorString: "Full name:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 65,
OffsetY: -8,
},
{
ID: "mailing_address1",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 300,
Height: 20,
OffsetX: 105,
OffsetY: -7,
},
{
ID: "mailing_address2",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 0,
OffsetY: 22,
},
{
ID: "mailing_address3",
Name: "Mailing Address",
AnchorString: "Mailing Address:",
FieldType: "text_optional",
IsOptional: true,
IsEditable: false,
Width: 340,
Height: 20,
OffsetX: 0, // should be aligned with the above
OffsetY: 50,
},
{
ID: "country",
Name: "Country",
AnchorString: "Country:",
FieldType: "text_unlocked",
IsOptional: true,
IsEditable: false,
Width: 300,
Height: 20,
OffsetX: 60,
OffsetY: -7,
},
{
ID: "email",
Name: "Email",
AnchorString: "E-Mail:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 300, // 320 same length as above
Height: 20,
OffsetX: 50, // 40 move over a bit
OffsetY: -8,
},
{
ID: "sign",
Name: "Please Sign",
AnchorString: "Please Sign:",
FieldType: "sign",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 80, // 70 move to the right some
OffsetY: -5,
},
{
ID: "date",
Name: "Date",
AnchorString: "Date:",
FieldType: "date",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 40,
OffsetY: -7,
},
},
CclaFields: []*models.Field{
{
ID: "sign",
Name: "Please Sign",
AnchorString: "Please sign:",
FieldType: "sign",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 100,
OffsetY: -6,
},
{
ID: "date",
Name: "Date",
AnchorString: "Date:",
FieldType: "date",
IsOptional: false,
IsEditable: false,
Width: 0,
Height: 0,
OffsetX: 40,
OffsetY: -7,
},
{
ID: "signatory_name",
Name: "Signatory Name",
AnchorString: "Signatory Name:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: true,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -5,
},
{
ID: "signatory_email",
Name: "Signatory E-mail",
AnchorString: "Signatory E-mail:",
FieldType: "text",
IsOptional: false,
IsEditable: false,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -5,
},
{
ID: "signatory_title",
Name: "Signatory Title",
AnchorString: "Signatory Title:",
FieldType: "text",
IsOptional: true,
IsEditable: true,
Width: 355,
Height: 20,
OffsetX: 120,
OffsetY: -6,
},
{
ID: "corporation_name",
Name: "Corporation Name",
AnchorString: "Corporation Name:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: false,
Width: 355,
Height: 20,
OffsetX: 130,
OffsetY: -5,
},
{
ID: "corporation_address1",
Name: "Corporation Address1",
AnchorString: "Corporation Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: true,
Width: 230,
Height: 20,
OffsetX: 135,
OffsetY: -8,
},
{
ID: "corporation_address2",
Name: "Corporation Address2",
AnchorString: "Corporation Address:",
FieldType: "text_unlocked",
IsOptional: false,
IsEditable: true,