Commit 0e1681db by Damien Moulard

allow attached people to connect

parent a479186a
...@@ -95,11 +95,18 @@ class CagetteMember(models.Model): ...@@ -95,11 +95,18 @@ class CagetteMember(models.Model):
api = OdooAPI() api = OdooAPI()
cond = [['email', '=', login]] cond = [['email', '=', login]]
if getattr(settings, 'ALLOW_NON_MEMBER_TO_CONNECT', False) is False: if getattr(settings, 'ALLOW_NON_MEMBER_TO_CONNECT', False) is False:
cond.append('|')
cond.append(['is_member', '=', True]) 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) res = api.search_read('res.partner', cond, fields)
if (res and len(res) >= 1): if (res and len(res) >= 1):
for coop in res: for item in res:
coop = item
if item["is_associated_people"] == True:
break
y, m, d = coop['birthdate'].split('-') y, m, d = coop['birthdate'].split('-')
password = password.replace('/', '') password = password.replace('/', '')
if (password == d + m + y): if (password == d + m + y):
...@@ -108,6 +115,7 @@ class CagetteMember(models.Model): ...@@ -108,6 +115,7 @@ class CagetteMember(models.Model):
data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest() data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest()
data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest() data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest()
data['coop_state'] = coop['cooperative_state'] data['coop_state'] = coop['cooperative_state']
if not ('auth_token' in data): if not ('auth_token' in data):
data['failure'] = True data['failure'] = True
data['msg'] = "Erreur dans le mail ou le mot de passe" data['msg'] = "Erreur dans le mail ou le mot de passe"
......
...@@ -37,7 +37,8 @@ class CagetteShift(models.Model): ...@@ -37,7 +37,8 @@ class CagetteShift(models.Model):
'shift_type', 'date_alert_stop', 'date_delay_stop', 'extension_ids', 'shift_type', 'date_alert_stop', 'date_delay_stop', 'extension_ids',
'cooperative_state', 'final_standard_point', 'create_date', 'cooperative_state', 'final_standard_point', 'create_date',
'final_ftop_point', 'in_ftop_team', 'leave_ids', 'makeups_to_do', 'barcode_base', '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) partnerData = self.o_api.search_read('res.partner', cond, fields, 1)
if partnerData: if partnerData:
partnerData = partnerData[0] partnerData = partnerData[0]
......
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
"mobile" : "{{partnerData.mobile}}", "mobile" : "{{partnerData.mobile}}",
"phone" : "{{partnerData.phone}}", "phone" : "{{partnerData.phone}}",
"email" : "{{partnerData.email}}", "email" : "{{partnerData.email}}",
"is_associated_people" : "{{partnerData.is_associated_people}}",
"parent_id" : "{{partnerData.parent_id}}",
} }
</script> </script>
<script src="{% static "js/all_common.js" %}?v="></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