def printItemPage(self, fields, params): item = self.getItem(params) if 'error' in item: return self.sbuilder.throwWebError(item['error'], 'item') item.update(prettyItemBonus(item, self.balance.stats_name)) author = self.model.players.getPlayerBy_ID(item['author'], {'name':1}) if author: item.update({'author_name': author['name']}) item['img'] = '/'+item['img']+'_fit.png' item['img_info'] = miscController.formatArtworkInfo(item['img_info']) fields.update(item) likes = self.model.items.getItemLikes(item['_id']) if 'reject' in item: try: rejecter = self.model.players.getPlayerBy_ID(item['reject']['rejecter_id'], {'name':1}) fields.update({'reject_name': rejecter['name']}) except Exception: fields.update({'reject_name': 'game'}) if self.cur_player: fields.update({ 'inventory_count': self.model.items.getInventoryCount(self.cur_player['login_id']), 'inventory_max': self.sbuilder.balance.INVENTORY_SIZE }) fields.update({ self.title: item['name']+' page', 'likes': len(likes['people']), 'is_like': self.cur_player and self.cur_player['login_id'] in likes['people'], 'is_reported': self.cur_player and self.model.items.isReportItem(item['_id'], self.cur_player['login_id']), 'reasons': self.balance.getRejectReasons(self.balance.item_reject_reasons), 'categories': self.balance.categories }) return basic.defaultController._printTemplate(self, 'item_page', fields)
def printSpellPage(self, fields, params): spell = self.getSpell(params) if 'error' in spell: return self.sbuilder.throwWebError(spell['error'], 'spell') author = self.model.players.getPlayerBy_ID(spell['author'], {'name':1}) if author: spell.update({'author_name': author['name']}) spell['img'] += '_fit.png' spell['img_info'] = miscController.formatArtworkInfo(spell['img_info']) fields.update(spell) likes = self.model.items.getItemLikes(spell['_id']) if 'reject' in spell: try: rejecter = self.model.players.getPlayerBy_ID(spell['reject']['rejecter_id'], {'name':1}) fields.update({'reject_name': rejecter['name']}) except Exception: fields.update({'reject_name': 'game'}) if self.cur_player: fields.update({'already_have': self.model.spells.haveThisSpell(self.cur_player['login_id'], spell['name'])}) fields.update({ self.title: author['name']+' spell page', 'likes': len(likes['people']), 'is_like': self.cur_player and self.cur_player['login_id'] in likes['people'], 'is_reported': self.cur_player and self.model.items.isReportItem(spell['_id'], self.cur_player['login_id']), 'reasons': self.balance.getRejectReasons(self.balance.spell_reject_reasons), 'categories': self.balance.categories }) return basic.defaultController._printTemplate(self, 'spell_page', fields)
def printArtworkPage(self, fields, params): artwork = self.getArtwork(params) if 'error' in artwork: return self.sbuilder.throwWebError(artwork['error'], 'Artwork') if 'author' in artwork: author = self.model.players.getPlayerBy_ID(artwork['author'], {'name': 1}) if author: artwork.update({'author_name': author['name']}) if 'UID' in artwork: artwork[ 'img'] = self.core.ARTWORK_SHOP_PATH + artwork['img'] + '.jpg' else: artwork['img'] += '_fit.png' artwork['img_info'] = miscController.formatArtworkInfo( artwork['img_info']) if 'reject' in artwork: try: rejecter = self.model.players.getPlayerBy_ID( artwork['reject']['rejecter_id'], {'name': 1}) fields.update({'reject_name': rejecter['name']}) except Exception: fields.update({'reject_name': 'game'}) artwork.update({ 'race_name': self.balance.races[artwork['faction']][artwork['race']], 'class_name': self.balance.classes[str(artwork['class'])] }) fields.update(artwork) if self.cur_player: artworks = self.model.misc.getPlayersBuyedArtworks( self.cur_player['login_id']) for art in artworks: if art['name'] == artwork['name']: already_have = True break else: already_have = False fields.update({ 'already_have': already_have, 'player_race_name': self.balance.races[self.cur_player['login_faction']][ self.cur_player['login_race']], 'player_class_name': self.balance.classes[str(self.cur_player['login_class'])] }) likes = self.model.items.getItemLikes(artwork['_id']) fields.update({ self.title: artwork['name'] + ' artwork page', 'likes': len(likes['people']), 'is_like': self.cur_player and self.cur_player['login_id'] in likes['people'], 'is_reported': self.cur_player and self.model.items.isReportItem( artwork['_id'], self.cur_player['login_id']), 'reasons': self.balance.getRejectReasons(self.balance.artwork_reject_reasons), 'categories': self.balance.categories }) return basic.defaultController._printTemplate(self, 'artwork_page', fields)
def printArtworkPage(self, fields, params): artwork = self.getArtwork(params) if 'error' in artwork: return self.sbuilder.throwWebError(artwork['error'], 'Artwork') if 'author' in artwork: author = self.model.players.getPlayerBy_ID(artwork['author'], {'name':1}) if author: artwork.update({'author_name': author['name']}) if 'UID' in artwork: artwork['img'] = self.core.ARTWORK_SHOP_PATH+artwork['img']+'.jpg' else: artwork['img'] += '_fit.png' artwork['img_info'] = miscController.formatArtworkInfo(artwork['img_info']) if 'reject' in artwork: try: rejecter = self.model.players.getPlayerBy_ID(artwork['reject']['rejecter_id'], {'name':1}) fields.update({'reject_name': rejecter['name']}) except Exception: fields.update({'reject_name': 'game'}) artwork.update({ 'race_name': self.balance.races[artwork['faction']][artwork['race']], 'class_name': self.balance.classes[str(artwork['class'])] }) fields.update(artwork) if self.cur_player: artworks = self.model.misc.getPlayersBuyedArtworks(self.cur_player['login_id']) for art in artworks: if art['name'] == artwork['name']: already_have = True break else: already_have = False fields.update({ 'already_have': already_have, 'player_race_name': self.balance.races[self.cur_player['login_faction']][self.cur_player['login_race']], 'player_class_name': self.balance.classes[str(self.cur_player['login_class'])] }) likes = self.model.items.getItemLikes(artwork['_id']) fields.update({ self.title: artwork['name']+' artwork page', 'likes': len(likes['people']), 'is_like': self.cur_player and self.cur_player['login_id'] in likes['people'], 'is_reported': self.cur_player and self.model.items.isReportItem(artwork['_id'], self.cur_player['login_id']), 'reasons': self.balance.getRejectReasons(self.balance.artwork_reject_reasons), 'categories': self.balance.categories }) return basic.defaultController._printTemplate(self, 'artwork_page', fields)