Commit cf673b7e by François C.

Fix 500 error if a member has not a shif_template id set

parent 396a54e3
Pipeline #3420 failed with stage
in 1 minute 7 seconds
......@@ -389,7 +389,7 @@ class CagetteMember(models.Model):
res = {}
# First, update couchdb data
c_db = CouchDB(arg_db='member')
shift_template = json.loads(post_data['shift_template'])
# shift_template = json.loads(post_data['shift_template'])
received_data = {'birthdate': post_data['birthdate'],
'city': post_data['city'],
'zip': post_data['zip'],
......@@ -573,11 +573,14 @@ class CagetteMember(models.Model):
# We add the associated member to the "associate" shift template so we can find them in Odoo
elif 'is_associated_people' not in post_data or 'is_associated_people' in post_data and 'parent_id' not in post_data:
# Create shift suscription if is not associated
shift_template = json.loads(post_data['shift_template'])
shift_t_id = shift_template['data']['id']
stype = shift_template['data']['type']
res['shift'] = \
m.create_coop_shift_subscription(shift_t_id, stype)
try:
shift_template = json.loads(post_data['shift_template'])
shift_t_id = shift_template['data']['id']
stype = shift_template['data']['type']
res['shift'] = \
m.create_coop_shift_subscription(shift_t_id, stype)
except Exception as no_shift_e:
coop_logger.error("Pas de créneau défini : %s \n %s", str(post_data), str(no_shift_e))
# m.add_first_point(stype) # Not needed anymore
# Update couchdb do with new data
......@@ -1396,4 +1399,4 @@ class CagetteUser(models.Model):
return answer
from shifts.models import CagetteShift
\ No newline at end of file
from shifts.models import CagetteShift
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