Exemplo n.º 1
0
 def save_model(self, request, obj, form, change):
     if 'status' in form.changed_data and obj.status!='Rejected':
         date = loyalty.set_date("Redemption", obj.status)
         obj.due_date = date['due_date']
         obj.expected_delivery_date = date['expected_delivery_date']
         obj.resolution_flag = False
     if 'status' in form.changed_data:
         if obj.status=='Approved':
             obj.is_approved=True
             obj.packed_by=obj.partner.user.user.username
             obj.approved_date=datetime.datetime.now()
         elif obj.status in ['Rejected', 'Open'] :
             obj.is_approved=False
             obj.packed_by=None
         elif obj.status=='Shipped':
             obj.shipped_date=datetime.datetime.now()
         elif obj.status=='Delivered':
             obj.delivery_date=datetime.datetime.now()
     if 'status' in form.changed_data:
         if obj.status=='Approved' and obj.refunded_points:
             loyalty.update_points(obj.member, redeem=obj.product.points)
             obj.refunded_points = False
         elif obj.status=='Rejected' and not obj.refunded_points:
             loyalty.update_points(obj.member, accumulate=obj.product.points)
             obj.refunded_points = True
     super(RedemptionRequestAdmin, self).save_model(request, obj, form, change)
     if 'status' in form.changed_data and obj.status in constants.STATUS_TO_NOTIFY:
         loyalty.send_request_status_sms(obj)
     if 'partner' in form.changed_data and obj.partner:
         loyalty.send_mail_to_partner(obj)
Exemplo n.º 2
0
 def save_model(self, request, obj, form, change):
     if 'partner' in form.changed_data and obj.partner and obj.status in ['Accepted', 'Open']:
             obj.packed_by=obj.partner.user.user.username
     if 'status' in form.changed_data:
         if obj.status=='Shipped':
             obj.shipped_date=datetime.datetime.now()
         elif obj.status=='Delivered':
             obj.delivery_date=datetime.datetime.now()
     date = loyalty.set_date("Welcome Kit", obj.status)
     obj.due_date = date['due_date']
     obj.expected_delivery_date = date['expected_delivery_date']
     obj.resolution_flag = False
     super(WelcomeKitAdmin, self).save_model(request, obj, form, change)
     if 'status' in form.changed_data and obj.status=="Shipped":
         loyalty.send_welcome_kit_delivery(obj)
     if 'partner' in form.changed_data and obj.partner:
         loyalty.send_welcome_kit_mail_to_partner(obj)