Commit 0e1681db by Damien Moulard

allow attached people to connect

parent a479186a
......@@ -95,19 +95,27 @@ class CagetteMember(models.Model):
api = OdooAPI()
cond = [['email', '=', login]]
if getattr(settings, 'ALLOW_NON_MEMBER_TO_CONNECT', False) is False:
cond.append('|')
cond.append(['is_member', '=', True])
fields = ['name', 'email', 'birthdate', 'create_date', 'cooperative_state']
cond.append(['is_associated_people', '=', True])
fields = ['name', 'email', 'birthdate', 'create_date', 'cooperative_state', 'is_associated_people']
res = api.search_read('res.partner', cond, fields)
if (res and len(res) >= 1):
for coop in res:
y, m, d = coop['birthdate'].split('-')
password = password.replace('/', '')
if (password == d + m + y):
data['id'] = coop['id']
auth_token_seed = fp + coop['create_date']
data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest()
data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest()
data['coop_state'] = coop['cooperative_state']
for item in res:
coop = item
if item["is_associated_people"] == True:
break
y, m, d = coop['birthdate'].split('-')
password = password.replace('/', '')
if (password == d + m + y):
data['id'] = coop['id']
auth_token_seed = fp + coop['create_date']
data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest()
data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest()
data['coop_state'] = coop['cooperative_state']
if not ('auth_token' in data):
data['failure'] = True
data['msg'] = "Erreur dans le mail ou le mot de passe"
......
......@@ -37,7 +37,8 @@ class CagetteShift(models.Model):
'shift_type', 'date_alert_stop', 'date_delay_stop', 'extension_ids',
'cooperative_state', 'final_standard_point', 'create_date',
'final_ftop_point', 'in_ftop_team', 'leave_ids', 'makeups_to_do', 'barcode_base',
'street', 'street ,' 'zip', 'city', 'mobile', 'phone', 'email']
'street', 'street2 ,' 'zip', 'city', 'mobile', 'phone', 'email',
'is_associated_people', 'parent_id']
partnerData = self.o_api.search_read('res.partner', cond, fields, 1)
if partnerData:
partnerData = partnerData[0]
......
......@@ -59,6 +59,8 @@
"mobile" : "{{partnerData.mobile}}",
"phone" : "{{partnerData.phone}}",
"email" : "{{partnerData.email}}",
"is_associated_people" : "{{partnerData.is_associated_people}}",
"parent_id" : "{{partnerData.parent_id}}",
}
</script>
<script src="{% static "js/all_common.js" %}?v="></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment