def register_transaction(registration, amount, currency, action, provider=None, data=None): """Create a new transaction for a certain transaction action. :param registration: the `Registration` associated to the transaction :param amount: the (strictly positive) amount of the transaction :param currency: the currency used for the transaction :param action: the `TransactionAction` of the transaction :param provider: the payment method name of the transaction, or '_manual' if no payment method has been used :param data: arbitrary JSON-serializable data specific to the transaction's provider """ new_transaction = PaymentTransaction.create_next(registration=registration, action=action, amount=amount, currency=currency, provider=provider, data=data) if new_transaction: db.session.flush() if new_transaction.status == TransactionStatus.successful: registration.update_state(paid=True) elif new_transaction.status == TransactionStatus.cancelled: registration.update_state(paid=False) notify_registration_state_update(registration) return new_transaction
def register_transaction(registration, amount, currency, action, provider=None, data=None): """Creates a new transaction for a certain transaction action. :param registration: the `Registration` associated to the transaction :param amount: the (strictly positive) amount of the transaction :param currency: the currency used for the transaction :param action: the `TransactionAction` of the transaction :param provider: the payment method name of the transaction, or '_manual' if no payment method has been used :param data: arbitrary JSON-serializable data specific to the transaction's provider """ new_transaction, double_payment = PaymentTransaction.create_next( registration=registration, action=action, amount=amount, currency=currency, provider=provider, data=data ) if new_transaction: db.session.flush() if double_payment: notify_double_payment(registration) if new_transaction.status == TransactionStatus.successful: registration.update_state(paid=True) elif new_transaction.status == TransactionStatus.cancelled: registration.update_state(paid=False) notify_registration_state_update(registration) return new_transaction
def _process(self): if self.registration.state in (RegistrationState.withdrawn, RegistrationState.rejected): raise BadRequest(_('The registration cannot be withdrawn in its current state.')) self.registration.update_state(withdrawn=True) flash(_('The registration has been withdrawn.'), 'success') logger.info('Registration %r was withdrawn by %r', self.registration, session.user) notify_registration_state_update(self.registration) return jsonify_data(html=_render_registration_details(self.registration))
def _modify_registration_status(registration, approve): if approve: registration.update_state(approved=True) else: registration.update_state(rejected=True) db.session.flush() notify_registration_state_update(registration) status = 'approved' if approve else 'rejected' logger.info('Registration %s was %s by %s', registration, status, session.user)
def _modify_registration_status(registration, approve): if approve: registration.update_state(approved=True) else: registration.update_state(rejected=True) db.session.flush() notify_registration_state_update(registration) status = 'approved' if approve else 'rejected' logger.info('Registration %s was %s by %s', registration, status, session.user)
def _modify_registration_status(registration, approve, rejection_reason='', attach_rejection_reason=False): if registration.state != RegistrationState.pending: return if approve: registration.update_state(approved=True) else: registration.rejection_reason = rejection_reason registration.update_state(rejected=True) db.session.flush() notify_registration_state_update(registration, attach_rejection_reason) status = 'approved' if approve else 'rejected' logger.info('Registration %s was %s by %s', registration, status, session.user)
def _process(self): if self.registration.has_conflict(): raise NoReportError(_('Cannot reset this registration since there is another valid registration for the ' 'same user or email.')) if self.registration.state in (RegistrationState.complete, RegistrationState.unpaid): self.registration.update_state(approved=False) elif self.registration.state == RegistrationState.rejected: self.registration.rejection_reason = '' self.registration.update_state(rejected=False) elif self.registration.state == RegistrationState.withdrawn: self.registration.update_state(withdrawn=False) notify_registration_state_update(self.registration) else: raise BadRequest(_('The registration cannot be reset in its current state.')) self.registration.checked_in = False logger.info('Registration %r was reset by %r', self.registration, session.user) return jsonify_data(html=_render_registration_details(self.registration))