My code:
def save_model(self, request, obj, form, change):
if "_continue" in request.POST:
if "PAN_ID" in request.POST and not change:
try:
data = Dematad.objects.filter(
Q(PAN1=obj.PAN_ID) | Q(PAN2=obj.PAN_ID) | Q(PAN3=obj.PAN_ID)
).get()
obj.email= data.EMAIL1.strip() or data.EMAIL2.strip() or data.EMAIL3.strip() or None
obj.full_name = data.NAME
obj.address = ", ".join(
[data.AD1, data.AD2, data.AD3, data.AD4, data.PIN]
)
except Dematad.DoesNotExist:
self.message_user(
request, "User created and saved. No data available in database."
)
if not change:
obj.is_superuser = False
obj.is_staff = True
obj.set_password(User.objects.make_random_password(20))
return super().save_model(request, obj, form, change)
I want to simplify the code and thus tried to model the if conditions through logic. Consider the try, except block together as D
S1: $A \implies ((B \land \tilde C) \implies D)$
S2: $ \tilde C \implies E $
How do I connect these statements? How do I simplify my if conditions?
EDIT: By simplification I' m meaning to remove the inner block, or avoid nested if's. I want to know how can expressions be simplified.
I personally don't think you can combine or simplify because:
Edit. WolframAlpha cannot reduce the combined expressions.