Skip to content

Commit 7e5dca7

Browse files
Hot fix 4
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 3548a0e commit 7e5dca7

File tree

5 files changed

+98
-12
lines changed

5 files changed

+98
-12
lines changed

cla-backend/cla/models/dynamo_models.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def get_value(self, value):
735735
return set()
736736
if self.attr_type == 'SS' and 'L' in value:
737737
value = {'SS':list(map(lambda x: x['S'], value['L']))}
738-
super(PatchedUnicodeSetAttribute, self).get_value(value)
738+
return super(PatchedUnicodeSetAttribute, self).get_value(value)
739739

740740
def deserialize(self, value):
741741
if not value:
@@ -2013,7 +2013,6 @@ def preprocess_pattern(self, emails, patterns) -> bool:
20132013
:rtype: bool
20142014
"""
20152015
fn = 'dynamo_models.preprocess_pattern'
2016-
cla.log.debug(f"{fn}: LG: self={self}, emails={emails}, patterns={patterns}")
20172016
for pattern in patterns:
20182017
if pattern.startswith("*."):
20192018
pattern = pattern.replace("*.", ".*")
@@ -2024,12 +2023,10 @@ def preprocess_pattern(self, emails, patterns) -> bool:
20242023

20252024
preprocessed_pattern = "^.*@" + pattern + "$"
20262025
pat = re.compile(preprocessed_pattern)
2027-
cla.log.debug(f"{fn}: LG: patters={pattern}, preprocessed_pattern={preprocessed_pattern}, pat={pat}")
20282026
for email in emails:
20292027
if pat.match(email) is not None:
20302028
self.log_debug(f'{fn} - found user email in email approval pattern')
20312029
return True
2032-
cla.log.debug(f"{fn}: LG: no match")
20332030
return False
20342031

20352032
# Accepts a Signature object
@@ -2045,14 +2042,11 @@ def is_approved(self, ccla_signature: Signature) -> bool:
20452042
:rtype: bool
20462043
"""
20472044
fn = 'dynamo_models.is_approved'
2048-
cla.log.debug(f"{fn}: LG: self={self}, ccla_signature={ccla_signature}")
20492045
# Returns the union of lf_emails and emails (separate columns)
20502046
emails = self.get_all_user_emails()
2051-
cla.log.debug(f"{fn}: LG: emails={emails}")
20522047
if len(emails) > 0:
20532048
# remove leading and trailing whitespace before checking emails
20542049
emails = [email.strip() for email in emails]
2055-
cla.log.debug(f"{fn}: LG: emails={emails} (stripped)")
20562050

20572051
# First, we check email whitelist
20582052
whitelist = ccla_signature.get_email_whitelist()

cla-backend/cla/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,6 @@ def user_signed_project_signature(user: User, project: Project) -> bool:
683683

684684
# Check if we have an CCLA for this user
685685
company_id = user.get_user_company_id()
686-
cla.log.debug(f"{fn}: LG: company_id={company_id}")
687686

688687
ccla_pass = False
689688
if company_id is not None:
@@ -696,7 +695,6 @@ def user_signed_project_signature(user: User, project: Project) -> bool:
696695
employee_signature = user.get_latest_signature(
697696
project.get_project_id(), company_id=company_id, signature_signed=True, signature_approved=True
698697
)
699-
cla.log.debug(f"{fn}: LG: employee_signature={employee_signature}")
700698

701699
if employee_signature is not None:
702700
cla.log.debug(
@@ -714,7 +712,6 @@ def user_signed_project_signature(user: User, project: Project) -> bool:
714712
f"company with id does not exist: {company_id}."
715713
)
716714
return False
717-
cla.log.debug(f"{fn}: LG: company={company}")
718715

719716
# Get CCLA signature of company to access whitelist
720717
cla.log.debug(
@@ -724,7 +721,6 @@ def user_signed_project_signature(user: User, project: Project) -> bool:
724721
signature = company.get_latest_signature(
725722
project.get_project_id(), signature_signed=True, signature_approved=True
726723
)
727-
cla.log.debug(f"{fn}: LG: signature={signature}")
728724

729725
# Don't check the version for employee signatures.
730726
if signature is not None:
@@ -743,7 +739,6 @@ def user_signed_project_signature(user: User, project: Project) -> bool:
743739
# 'project requires ICLA signature as well as CCLA signature ')
744740
if user.is_approved(signature):
745741
ccla_pass = True
746-
cla.log.debug(f"{fn}: LG: ccla_pass={ccla_pass}")
747742
else:
748743
# Set user signatures approved = false due to user failing whitelist checks
749744
cla.log.debug(
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# API_URL=https://3f13-147-75-85-27.ngrok-free.app (defaults to localhost:5000)
3+
# user_id='9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5'
4+
# company_id='862ff296-6508-4f10-9147-2bc2dd7bfe80'
5+
# project_id='88ee12de-122b-4c46-9046-19422054ed8d'
6+
# DEBUG=1 ./utils/check_prepare_employee_signature_py 9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5 862ff296-6508-4f10-9147-2bc2dd7bfe80 88ee12de-122b-4c46-9046-19422054ed8d github 'http://localhost'
7+
# DEBUG=1 ./utils/check_prepare_employee_signature_py.sh 65d22813-1ac0-4292-bb68-fdcb278473a5 4930fe6e-e023-4f56-9767-6f1996a7b730 43c546ff-bc79-4a32-9454-77dabd6afaee
8+
9+
if [ -z "$1" ]
10+
then
11+
echo "$0: you need to specify user_id as a 1st parameter"
12+
exit 1
13+
fi
14+
export user_id="$1"
15+
16+
if [ -z "$2" ]
17+
then
18+
echo "$0: you need to specify company_id as a 2nd parameter"
19+
exit 2
20+
fi
21+
export company_id="$2"
22+
23+
if [ -z "$3" ]
24+
then
25+
echo "$0: you need to specify project_id as a 3rd parameter"
26+
exit 3
27+
fi
28+
export project_id="$3"
29+
30+
if [ -z "$API_URL" ]
31+
then
32+
export API_URL="http://localhost:5000"
33+
fi
34+
35+
if [ ! -z "$DEBUG" ]
36+
then
37+
echo "curl -s -XPOST -H 'Content-Type: application/json' '${API_URL}/v2/check-prepare-employee-signature' -d '{\"project_id\":\"${project_id}\",\"user_id\":\"${user_id}\",\"company_id\":\"${company_id}\"}\"}' | jq -r '.'"
38+
fi
39+
curl -s -XPOST -H "Content-Type: application/json" "${API_URL}/v2/check-prepare-employee-signature" -d "{\"project_id\":\"${project_id}\",\"user_id\":\"${user_id}\",\"company_id\":\"${company_id}\"}" | jq -r '.'

utils/copy_prod_case.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
echo "copy project"
3+
./utils/copy_prod_to_dev.sh projects project_id 43c546ff-bc79-4a32-9454-77dabd6afaee
4+
echo "copy user"
5+
./utils/copy_prod_to_dev.sh users user_id 65d22813-1ac0-4292-bb68-fdcb278473a5
6+
echo "copy company"
7+
./utils/copy_prod_to_dev.sh companies company_id 4930fe6e-e023-4f56-9767-6f1996a7b730
8+
echo "copy signature (CCLA)"
9+
./utils/copy_prod_to_dev.sh signatures signature_id b90452c9-97b3-411e-9004-b58260297fcb
10+
echo "copy signature (ECLA)"
11+
./utils/copy_prod_to_dev.sh signatures signature_id 167e04e4-650a-40ef-a138-c1087201231e
12+
13+
echo "project:"
14+
./utils/scan.sh projects project_id 43c546ff-bc79-4a32-9454-77dabd6afaee
15+
echo "user:"
16+
./utils/scan.sh users user_id 65d22813-1ac0-4292-bb68-fdcb278473a5
17+
echo "company:"
18+
./utils/scan.sh companies company_id 4930fe6e-e023-4f56-9767-6f1996a7b730
19+
echo "CCLA signature:"
20+
./utils/scan.sh signatures signature_id b90452c9-97b3-411e-9004-b58260297fcb
21+
echo "ECLA signature:"
22+
./utils/scan.sh signatures signature_id 167e04e4-650a-40ef-a138-c1087201231e

utils/copy_prod_to_dev.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]
4+
then
5+
echo "$0: you need to specify table to copy from"
6+
exit 1
7+
fi
8+
table="${1}"
9+
10+
if [ -z "$2" ]
11+
then
12+
echo "$0: you need to specify ${table} key column name"
13+
exit 2
14+
fi
15+
key_column="${2}"
16+
17+
if [ -z "$3" ]
18+
then
19+
echo "$0: you need to specify ${table} ${key_column} value"
20+
exit 3
21+
fi
22+
key_value="${3}"
23+
24+
if [ ! -z "$DEBUG" ]
25+
then
26+
echo "aws --profile lfproduct-prod dynamodb get-item --table-name cla-prod-${table} --key {\"${key_column}\": {\"S\": \"${key_value}\"}} | jq -c .Item"
27+
fi
28+
29+
object=$(aws --profile lfproduct-prod dynamodb get-item --table-name cla-prod-${table} --key "{\"${key_column}\": {\"S\": \"${key_value}\"}}" | jq -c .Item)
30+
command="aws --profile lfproduct-dev dynamodb put-item --table-name \"cla-dev-${table}\" --item '${object}'"
31+
if [ ! -z "$DEBUG" ]
32+
then
33+
echo "${object}" | jq .
34+
echo "${command}"
35+
fi
36+
eval $command

0 commit comments

Comments
 (0)