fossasia / open-event-server

if statements can be merged PTC-W0048
Anti-pattern
Major
9 occurrences in this check
Consider merging collapsible if statements
 96                    {'event_id': data['event']}, "Event does not exist"
 97                )
 98
 99            if data.get('type') == 'paid' or data.get('type') == 'donation':100                if not event.is_payment_enabled():
101                    raise UnprocessableEntityError(
102                        {'event_id': data['event']},
Consider merging collapsible if statements
 56                    "max-order should be greater than or equal to min-order",
 57                )
 58
 59        if 'quantity' in data and 'min_order' in data: 60            if data['quantity'] < data['min_order']:
 61                raise UnprocessableEntityError(
 62                    {'pointer': '/data/attributes/quantity'},
Consider merging collapsible if statements
 70                    "minimum price should be lesser than or equal to maximum price",
 71                )
 72
 73        if 'quantity' in data and 'max_order' in data: 74            if data['quantity'] < data['max_order']:
 75                raise UnprocessableEntityError(
 76                    {'pointer': '/data/attributes/quantity'},
Consider merging collapsible if statements
 49
 50    @validates_schema
 51    def validate_quantity(self, data):
 52        if 'max_order' in data and 'min_order' in data: 53            if data['max_order'] < data['min_order']:
 54                raise UnprocessableEntityError(
 55                    {'pointer': '/data/attributes/max-order'},
Consider merging collapsible if statements
 63                    "quantity should be greater than or equal to min-order",
 64                )
 65
 66        if 'min_price' in data and 'max_price' in data and data['type'] == 'donation': 67            if data['min_price'] > data['max_price']:
 68                raise UnprocessableEntityError(
 69                    {'pointer': '/data/attributes/min-price'},
Consider merging collapsible if statements
 32        :param data:
 33        :return:
 34        """
 35        if ( 36            'POST' in request.method
 37            or ('GET' in request.method and 'regenerate' in request.args)
 38            and data["status"] != 'completed'
Consider merging collapsible if statements
231                "Attendee can't be updated because the corresponding order is not in initializing state",
232            )
233
234        if 'device_name_checkin' in data:235            if 'checkin_times' not in data or data['checkin_times'] is None:
236                raise UnprocessableEntityError(
237                    {'pointer': '/data/attributes/device_name_checkin'},
Consider merging collapsible if statements
102                    "Check in Times missing for the corresponding device name",
103                )
104
105        if 'checkin_times' in data:106            if 'device_name_checkin' not in data or data['device_name_checkin'] is None:
107                data['device_name_checkin'] = '-'
108
Consider merging collapsible if statements
288                checkout_times.append(str(datetime.datetime.utcnow()))
289                data['checkout_times'] = ','.join(checkout_times)
290
291        if 'attendee_notes' in data:292            if obj.attendee_notes and data[
293                'attendee_notes'
294            ] not in obj.attendee_notes.split(","):