Skip to content

Commit

Permalink
Merge pull request #4485 from communitybridge/lukaszgryglicki-4482-ad…
Browse files Browse the repository at this point in the history
…d-embargo_acked-to-cla-signatures

Add support for embargo acknowledgement in python and golang backends
lukaszgryglicki authored Dec 5, 2024
2 parents 8467aec + 9442e3a commit f786536
Showing 27 changed files with 173 additions and 142 deletions.
2 changes: 2 additions & 0 deletions cla-backend-go/signatures/converters.go
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ func (repo repository) buildProjectSignatureModels(ctx context.Context, results
SignatureReferenceNameLower: dbSignature.SignatureReferenceNameLower,
SignatureSigned: dbSignature.SignatureSigned,
SignatureApproved: dbSignature.SignatureApproved,
SignatureEmbargoAcked: dbSignature.SignatureEmbargoAcked,
SignatureDocumentMajorVersion: strconv.Itoa(dbSignature.SignatureDocumentMajorVersion),
SignatureDocumentMinorVersion: strconv.Itoa(dbSignature.SignatureDocumentMinorVersion),
Version: strconv.Itoa(dbSignature.SignatureDocumentMajorVersion) + "." + strconv.Itoa(dbSignature.SignatureDocumentMinorVersion),
@@ -237,6 +238,7 @@ func (repo repository) buildProjectSignatureSummaryModels(ctx context.Context, r
SignatureReferenceNameLower: dbSignature.SignatureReferenceNameLower,
SignatureSigned: dbSignature.SignatureSigned,
SignatureApproved: dbSignature.SignatureApproved,
SignatureEmbargoAcked: dbSignature.SignatureEmbargoAcked,
SignatureReferenceType: dbSignature.SignatureReferenceType,
ProjectID: dbSignature.SignatureProjectID,
SignedOn: dbSignature.SignedOn,
1 change: 1 addition & 0 deletions cla-backend-go/signatures/dbmodels.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ type ItemSignature struct {
DateModified string `json:"date_modified,omitempty"`
SignatureApproved bool `json:"signature_approved,omitempty"`
SignatureSigned bool `json:"signature_signed"`
SignatureEmbargoAcked bool `json:"signature_embargo_acked,omitempty"`
SignatureDocumentMajorVersion int `json:"signature_document_major_version,omitempty"`
SignatureDocumentMinorVersion int `json:"signature_document_minor_version,omitempty"`
SignatureSignURL string `json:"signature_sign_url,omitempty"`
1 change: 1 addition & 0 deletions cla-backend-go/signatures/models.go
Original file line number Diff line number Diff line change
@@ -97,6 +97,7 @@ type SignatureDynamoDB struct {
SignatureACL []string `json:"signature_acl"` // [github:1234567]
SignatureApproved bool `json:"signature_approved"` // true if the signature is approved, false if revoked/invalidated
SignatureSigned bool `json:"signature_signed"` // true if the signature has been signed
SignatureEmbargoAcked bool `json:"signature_embargo_acked"` // true if the signature's embargo was acknowledged
SignatureReferenceType string `json:"signature_reference_type"` // one of: user, company
SignatureReferenceName string `json:"signature_reference_name"` // John Doe
SignatureReferenceNameLower string `json:"signature_reference_name_lower"` // john doe
12 changes: 11 additions & 1 deletion cla-backend-go/signatures/repository.go
Original file line number Diff line number Diff line change
@@ -2126,6 +2126,11 @@ func (repo repository) ValidateProjectRecord(ctx context.Context, signatureID, n
expressionAttributeValues[":a"] = &dynamodb.AttributeValue{BOOL: aws.Bool(true)}
updateExpression = updateExpression + " #A = :a,"

// Set embago acknowledged flag
// expressionAttributeNames["#E"] = aws.String("signature_embargo_acked")
// expressionAttributeValues[":e"] = &dynamodb.AttributeValue{BOOL: aws.Bool(true)}
// updateExpression = updateExpression + " #E = :e,"

expressionAttributeNames["#S"] = aws.String("note")
expressionAttributeValues[":s"] = &dynamodb.AttributeValue{S: aws.String(note)}
updateExpression = updateExpression + " #S = :s"
@@ -2527,6 +2532,7 @@ func (repo repository) CreateProjectCompanyEmployeeSignature(ctx context.Context
SignatureReferenceID: employeeUserModel.UserID,
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureDocumentMajorVersion: 2,
SignatureDocumentMinorVersion: 0,
SigTypeSignedApprovedID: fmt.Sprintf("ecla#true#true#%s", companyModel.CompanyID),
@@ -4545,6 +4551,7 @@ func (repo repository) getIntermediateICLAResponse(f logrus.Fields, dbSignatures
LfUsername: sig.UserLFUsername,
SignatureApproved: sig.SignatureApproved,
SignatureSigned: sig.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureModified: sig.DateModified,
SignatureID: sig.SignatureID,
SignedOn: sigSignedTime,
@@ -4928,7 +4935,10 @@ func (repo repository) ActivateSignature(ctx context.Context, signatureID string
}

// Build the expression
expressionUpdate := expression.Set(expression.Name("signature_approved"), expression.Value(true)).Set(expression.Name("signature_signed"), expression.Value(false))
expressionUpdate := expression.
Set(expression.Name("signature_approved"), expression.Value(true)).
Set(expression.Name("signature_signed"), expression.Value(false)).
Set(expression.Name("signature_embargo_acked"), expression.Value(true))

expr, err := expression.NewBuilder().WithUpdate(expressionUpdate).Build()
if err != nil {
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/corporate-signature.yaml
Original file line number Diff line number Diff line change
@@ -38,6 +38,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/icla-signature.yaml
Original file line number Diff line number Diff line change
@@ -52,6 +52,11 @@ properties:
description: the signature signed flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureModified:
type: string
description: the signature modified created time
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/signature-summary.yaml
Original file line number Diff line number Diff line change
@@ -29,6 +29,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/signature.yaml
Original file line number Diff line number Diff line change
@@ -38,6 +38,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
7 changes: 7 additions & 0 deletions cla-backend-go/v2/company/service_test.go
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-13T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -48,6 +49,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-15T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -57,6 +59,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-14T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -76,6 +79,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-13T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -85,6 +89,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-15T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -94,6 +99,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-14T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
@@ -103,6 +109,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id_empty",
1 change: 1 addition & 0 deletions cla-backend-go/v2/dynamo_events/cla_manager.go
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ func (s *service) SetInitialCLAManagerACSPermissions(ctx context.Context, signat
f["projectID"] = sig.ProjectID
f["signed"] = sig.SignatureSigned
f["approved"] = sig.SignatureApproved
f["embargo_acked"] = sig.SignatureEmbargoAcked
f["companyName"] = sig.CompanyName
f["claType"] = sig.ClaType

3 changes: 3 additions & 0 deletions cla-backend-go/v2/dynamo_events/signatures.go
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ type Signature struct {
DateModified string `json:"date_modified"`
SignatureApproved bool `json:"signature_approved"`
SignatureSigned bool `json:"signature_signed"`
SignatureEmbargoAcked bool `json:"signature_embargo_acked"`
SignatureDocumentMajorVersion string `json:"signature_document_major_version"`
SignatureDocumentMinorVersion string `json:"signature_document_minor_version"`
SignatureReferenceID string `json:"signature_reference_id"`
@@ -95,6 +96,7 @@ func (s *service) SignatureAssignContributorEvent(event events.DynamoDBEventReco
f["projectID"] = newSignature.SignatureProjectID
f["approved"] = newSignature.SignatureApproved
f["signed"] = newSignature.SignatureSigned
f["embargo_acked"] = newSignature.SignatureEmbargoAcked

if !oldSignature.SignatureSigned && newSignature.SignatureSigned {
log.WithFields(f).Debug("signature is now signed - assigning contributor...")
@@ -138,6 +140,7 @@ func (s *service) SignatureSignedEvent(event events.DynamoDBEventRecord) error {
f["projectID"] = newSignature.SignatureProjectID
f["approved"] = newSignature.SignatureApproved
f["signed"] = newSignature.SignatureSigned
f["embargo_acked"] = newSignature.SignatureEmbargoAcked

// check if signature signed event is received
if !oldSignature.SignatureSigned && newSignature.SignatureSigned {
16 changes: 13 additions & 3 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
@@ -422,6 +422,7 @@ func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
@@ -657,6 +658,7 @@ func (s *service) SignedIndividualCallbackGitlab(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
@@ -890,6 +892,7 @@ func (s *service) SignedIndividualCallbackGerrit(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
@@ -1138,9 +1141,10 @@ func (s *service) SignedCorporateCallback(ctx context.Context, payload []byte, c
if status == DocusignCompleted && !signature.SignatureSigned {
_, currentTime := utils.CurrentTime()
updates := map[string]interface{}{
"signature_signed": true,
"date_modified": currentTime,
"signed_on": currentTime,
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
}

userSignedDate := info.EnvelopeStatus.RecipientStatuses[0].Signed
@@ -1371,6 +1375,7 @@ func (s *service) RequestIndividualSignature(ctx context.Context, input *models.
SignatureProjectID: latestSignature.ProjectID,
SignatureApproved: latestSignature.SignatureApproved,
SignatureSigned: latestSignature.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureReferenceName: latestSignature.SignatureReferenceName,
SignatureReferenceNameLower: latestSignature.SignatureReferenceNameLower,
SignedOn: latestSignature.SignedOn,
@@ -1443,6 +1448,7 @@ func (s *service) RequestIndividualSignature(ctx context.Context, input *models.
DateModified: currentTime,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureDocumentMajorVersion: majorVersion,
SignatureDocumentMinorVersion: minorVersion,
SignatureReferenceID: *input.UserID,
@@ -2359,6 +2365,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureProjectID: latestSignature.ProjectID,
SignatureApproved: latestSignature.SignatureApproved,
SignatureSigned: latestSignature.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureReferenceName: latestSignature.SignatureReferenceName,
SignatureReferenceNameLower: latestSignature.SignatureReferenceNameLower,
SignedOn: latestSignature.SignedOn,
@@ -2397,6 +2404,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureReferenceType: utils.SignatureReferenceTypeUser,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureType: utils.SignatureTypeCLA,
SignatureReferenceID: *input.UserID,
SignatureReturnURLType: input.ReturnURLType,
@@ -2571,6 +2579,7 @@ func (s *service) requestCorporateSignature(ctx context.Context, apiURL string,
SignatoryName: signatoryName,
SignatureSigned: companySignature.SignatureSigned,
SignatureApproved: companySignature.SignatureApproved,
SignatureEmbargoAcked: true,
DateCreated: companySignature.Created,
SignatureDocumentMajorVersion: majorVersion,
SignatureDocumentMinorVersion: minorVersion,
@@ -2611,6 +2620,7 @@ func (s *service) requestCorporateSignature(ctx context.Context, apiURL string,
SignatoryName: signatoryName,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureCallbackURL: callbackURL,
SignatureReturnURL: input.ReturnURL,
SigtypeSignedApprovedID: fmt.Sprintf("%s#%v#%v#%s", utils.SignatureTypeCCLA, signed, approved, signatureID),
16 changes: 16 additions & 0 deletions cla-backend/cla/controllers/signature.py
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
signature_type='cla',
signature_approved=False,
signature_signed=False,
signature_embargo_acked=True,
signature_return_url=None,
signature_sign_url=None,
signature_user_ccla_company_id=None,
@@ -74,6 +75,8 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
:type signature_signed: boolean
:param signature_approved: Whether or not the signature has been approved.
:type signature_approved: boolean
:param signature_embargo_acked: Whether or not the embargo was acknowledged
:type signature_embargo_acked: boolean
:param signature_return_url: The URL the user will be redirected to after signing.
:type signature_return_url: string
:param signature_sign_url: The URL the user must visit to sign the signature.
@@ -125,6 +128,7 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
signature.set_signature_type(signature_type)
signature.set_signature_signed(signature_signed)
signature.set_signature_approved(signature_approved)
signature.set_signature_embargo_acked(signature_embargo_acked)
signature.set_signature_return_url(signature_return_url)
signature.set_signature_sign_url(signature_sign_url)
if signature_user_ccla_company_id is not None:
@@ -151,6 +155,7 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
signature_type=None,
signature_approved=None,
signature_signed=None,
signature_embargo_acked=True,
signature_return_url=None,
signature_sign_url=None,
domain_whitelist=None,
@@ -177,6 +182,8 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
:type signature_signed: boolean | None
:param signature_approved: Whether this signature is approved or not.
:type signature_approved: boolean | None
:param signature_embargo_acked: Whether this signature's embargo is acknowledged
:type signature_embargo_acked: boolean | None
:param signature_return_url: The URL the user will be sent to after signing.
:type signature_return_url: string | None
:param signature_sign_url: The URL the user must visit to sign the signature.
@@ -238,6 +245,13 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
update_str += f'signature_approved updated to {val} \n'
except KeyError:
return {'errors': {'signature_approved': 'Invalid value passed in for true/false field'}}
if signature_embargo_acked is not None:
try:
val = hug.types.smart_boolean(signature_embargo_acked)
signature.set_signature_embargo_acked(val)
update_str += f'signature_embargo_acked updated to {val} \n'
except KeyError:
return {'errors': {'signature_embargo_acked': 'Invalid value passed in for true/false field'}}
if signature_return_url is not None:
try:
val = cla.hug_types.url(signature_return_url)
@@ -554,6 +568,8 @@ def create_bot_signature(bot_user: User, signature: Signature) -> Optional[Signa
bot_sig.set_signature_document_minor_version(signature.get_signature_document_minor_version())
bot_sig.set_signature_approved(True)
bot_sig.set_signature_signed(True)
# should bot signature by automaticaly set to "embargo acknowledged"?
bot_sig.set_signature_embargo_acked(True)
bot_sig.set_signature_type('cla')
bot_sig.set_signature_reference_type('user')
bot_sig.set_signature_user_ccla_company_id(bot_user.get_user_company_id())
Loading

0 comments on commit f786536

Please sign in to comment.