def submit(self): print('Submitting investment') self.recalculate() self.validate_allocations() print('\tAmount: %s' % self.amount) print('\tAllocations (%s)' % self.amount_or_percentage) for allocation in self.allocations: allocation_size = allocation.percentage if self.is_in_percentage else allocation.amount print('\t\tFund %s(%s): %s (%s)' % (allocation.fund, allocation.fund_code, allocation_size, allocation.amount)) Session.delete(self)
def save_value_for(cls, view, form, key, value, value_type): for i in cls.find_for(view, form=form).filter_by(key=key): Session.delete(i) if value_type is str: assert isinstance(value, str), 'Cannot handle the value: ' + str(value) cls.save_for(view, form=form, key=key, value=value) elif value_type is list: assert all([isinstance(i, str) for i in value]), 'Cannot handle the value: ' + str(value) if value: for i in value: cls.save_for(view, form=form, key=key, value=i) else: cls.save_for(view, form=form, key=key, value=None) else: assert None, 'Cannot persist values of type: %s' % value_type
def submit(self): print('Submitting investment') self.recalculate() self.validate_allocations() if self.new_or_existing == 'new': print('\tName: %s' % self.name) print('\tSurname: %s' % self.surname) print('\t%s' % str(self.id_document)) else: print('\tExisting account number: %s' % self.existing_account_number) print('\tAgreed to terms: %s' % self.agreed_to_terms) print('\tAmount: %s' % self.amount) print('\tAllocations (%s)' % self.amount_or_percentage) for allocation in self.allocations: allocation_size = allocation.percentage if self.is_in_percentage else allocation.amount print('\t\tFund %s(%s): %s (%s)' % (allocation.fund, allocation.fund_code, allocation_size, allocation.amount)) Session.delete(self)
def test_session_keeps_living(web_fixture): """When SessionData is deleted, the associated UserSession is not affected.""" fixture = web_fixture UserSession.initialise_web_session_on(fixture.context) user_session = fixture.context.session ui_name = 'user_interface' channel_name = 'channel' session_data = SessionData(web_session=user_session, view_path='/', ui_name=ui_name, channel_name=channel_name) Session.add(session_data) Session.flush() Session.delete(session_data) assert Session.query(SessionData).filter_by( id=session_data.id).count() == 0 assert Session.query(UserSession).filter_by( id=user_session.id).one() is user_session
def test_session_data_disappears_when_session_does(web_fixture): """When a UserSession is deleted, all associated SessionData disappear as well.""" fixture = web_fixture UserSession.initialise_web_session_on(fixture.context) user_session = fixture.context.session ui_name = 'user_interface' channel_name = 'channel' session_data = SessionData(web_session=user_session, view_path='/', ui_name=ui_name, channel_name=channel_name) Session.add(session_data) Session.flush() Session.delete(user_session) assert Session.query(SessionData).filter_by( id=session_data.id).count() == 0 assert Session.query(UserSession).filter_by( id=user_session.id).count() == 0
def clear_for_form_except_inputs(cls, form): for stale in cls.for_input(form, None).all(): Session.delete(stale)
def remove_persisted_for_view(cls, view, key): for previous in cls.find_for(view, form=None).filter_by(key=key): Session.delete(previous)
def clear_for_view(cls, view): for stale in cls.find_for(view, form=None).all(): Session.delete(stale)
def clear_for_form(cls, form): for stale in cls.find_for(form.view, form=form).all(): Session.delete(stale)
def clear_for_all_inputs(cls, form): for e in super(PersistedException, cls).find_for(form.view, form=form).filter(cls.input_name != None): Session.delete(e)
def cancel_reservation(self): if self.account_enabled: raise ProgrammerError( 'attempted to cancel a reserved account which is already active' ) Session.delete(self)
def deferred_action_expired(self, deferred_action): self.deferred_actions.remove(deferred_action) if self.deferred_actions.count() == 0: Session.delete(self)
def expire(self): for requirement in self.requirements.all(): requirement.deferred_action_expired(self) Session.delete(self)
def delete_selected(self): for row in self.rows: if row.selected_by_user: Session.delete(row.address)
def clear_all_view_data(cls, view): web_session = ExecutionContext.get_context().session items = Session.query(cls).filter_by(web_session=web_session, view_path=view.full_path, ui_name=view.user_interface.name) for stale in items: Session.delete(stale)
def clear_for_all_inputs(cls, form): for e in super().find_for( form.view, form=form).filter(cls.input_name is not None): Session.delete(e)
def remove_persisted_for_form(cls, form, input_name, filename): persisted = cls.find_for(form.view, form=form).filter_by( input_name=input_name).filter_by(filename=filename) for persisted_file in persisted.all(): Session.delete(persisted_file)
def set_new_password(self, email, password): self.system_account.set_new_password(email, password) Session.delete(self)