def purchase_code(self, box): """ Modify the database to reflect purchase """ team = self.get_current_user().team source_code = SourceCode.by_box_id(box.id) team.money -= abs(source_code.price) team.purchased_source_code.append(source_code) logging.info("%s purchased '%s' from the source code market." % (team.name, source_code.file_name)) self.dbsession.add(team) self.dbsession.commit()
def purchase_code(self, box): ''' Modify the database to reflect purchase ''' team = self.get_current_user().team source_code = SourceCode.by_box_id(box.id) team.money -= abs(source_code.price) team.purchased_source_code.append(source_code) logging.info("%s purchased '%s' from the source code market." % ( team.name, source_code.file_name, )) self.dbsession.add(team) self.dbsession.commit()
def source_code(self): return SourceCode.by_box_id(self.id)