diff --git a/app/__init__.py b/app/__init__.py index e96c8b3403..442743aa22 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -31,7 +31,8 @@ from app.views import BlueprintsManager from app.api.helpers.auth import AuthManager from app.api.helpers.scheduled_jobs import send_after_event_mail, send_event_fee_notification, \ - send_event_fee_notification_followup, change_session_state_on_event_completion, expire_pending_tickets_after_one_day + send_event_fee_notification_followup, change_session_state_on_event_completion, \ + expire_pending_tickets_after_three_days from app.models.event import Event from app.models.role_invite import RoleInvite from app.views.healthcheck import health_check_celery, health_check_db, health_check_migrations, check_migrations @@ -232,7 +233,7 @@ def update_sent_state(sender=None, headers=None, **kwargs): scheduler.add_job(send_event_fee_notification, 'cron', day=1) scheduler.add_job(send_event_fee_notification_followup, 'cron', day=15) scheduler.add_job(change_session_state_on_event_completion, 'cron', hour=5, minute=30) -scheduler.add_job(expire_pending_tickets_after_one_day, 'cron', hour=5) +scheduler.add_job(expire_pending_tickets_after_three_days, 'cron', hour=5) scheduler.start() diff --git a/app/api/helpers/scheduled_jobs.py b/app/api/helpers/scheduled_jobs.py index ec0903cad5..261193c451 100644 --- a/app/api/helpers/scheduled_jobs.py +++ b/app/api/helpers/scheduled_jobs.py @@ -142,7 +142,7 @@ def send_event_fee_notification_followup(): incomplete_invoice.event.id) -def expire_pending_tickets_after_one_day(): +def expire_pending_tickets_after_three_days(): from app import current_app as app with app.app_context(): db.session.query(Order).filter(Order.status == 'pending', diff --git a/app/api/orders.py b/app/api/orders.py index e369d12922..0798efe77e 100644 --- a/app/api/orders.py +++ b/app/api/orders.py @@ -58,9 +58,9 @@ def before_post(self, args, kwargs, data=None): del data['on_site_tickets'] require_relationship(['ticket_holders'], data) - # Ensuring that default status is always pending, unless the user is event co-organizer + # Ensuring that default status is always initializing, unless the user is event co-organizer if not has_access('is_coorganizer', event_id=data['event']): - data['status'] = 'pending' + data['status'] = 'initializing' def before_create_object(self, data, view_kwargs): """ @@ -201,7 +201,7 @@ def query(self, view_kwargs): # orders under an event query_ = event_query(self, query_, view_kwargs) - # expire the pending orders if the time limit is over. + # expire the initializing orders if the time limit is over. orders = query_.all() for order in orders: set_expiry_for_order(order) @@ -241,7 +241,7 @@ def before_get_object(self, view_kwargs): if not has_access('is_coorganizer_or_user_itself', event_id=order.event_id, user_id=order.user_id): return ForbiddenException({'source': ''}, 'You can only access your orders or your event\'s orders') - # expire the pending order if time limit is over. + # expire the initializing order if time limit is over. set_expiry_for_order(order) def before_update_object(self, order, data, view_kwargs): @@ -251,7 +251,7 @@ def before_update_object(self, order, data, view_kwargs): 2. event organizer a. own orders: he/she can update selected fields. b. other's orders: can only update the status that too when the order mode is free. No refund system. - 3. order user can update selected fields of his/her order when the status is pending. + 3. order user can update selected fields of his/her order when the status is initializing. The selected fields mentioned above can be taken from get_updatable_fields method from order model. :param order: :param data: @@ -287,9 +287,9 @@ def before_update_object(self, order, data, view_kwargs): "You cannot update the status of a cancelled order") elif current_user.id == order.user_id: - if order.status != 'pending': + if order.status != 'initializing' and order.status != 'pending': raise ForbiddenException({'pointer': ''}, - "You cannot update a non-pending order") + "You cannot update a non-initialized or non-pending order") else: for element in data: if element == 'is_billing_enabled' and order.status == 'completed' and data[element]\