def togglePin(request): try: if request.session.get('player') and request.method == "POST": player = getPlayer(request.session["player"].get("tId")) pinnedAwards = json.loads(player.awardsPinn) awardId = request.POST.get("awardId") if awardId is not None and not request.POST.get("check", False): if awardId in pinnedAwards: pinnedAwards.remove(awardId) else: if len(pinnedAwards) == 3: pinnedAwards.pop(0) pinnedAwards.append(awardId) player.awardsPinn = json.dumps(pinnedAwards) player.save() return render(request, "awards/pin-button.html", { "player": player, "awardId": awardId, "pinnedAwards": pinnedAwards }) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception as e: return returnError(exc=e, session=request.session)
def attacks(request): try: if request.session.get('player'): print('[view.traget.attacks] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.save() error = updateAttacks(player) targetJson = json.loads(player.targetJson) attacks = targetJson.get("attacks") if "attacks" in targetJson else dict({}) targets = targetJson.get("targets") if "targets" in targetJson else dict({}) context = {"player": player, "targetcat": True, "attacks": attacks, "targets": targets, "view": {"attacks": True}} if error: context.update(error) page = 'target/content-reload.html' if request.method == "POST" else 'target.html' return render(request, page, context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def toggleNoti(request): try: if request.session.get('player') and request.method == "POST": print('[view.bot.toggleNoti] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() type = request.POST["type"] notifications = json.loads(player.notifications) if type in notifications: del notifications[type] else: notifications[type] = dict({}) player.activateNotifications = bool(len(notifications)) player.notifications = json.dumps(notifications) player.save() context = {'player': player, "type": type, 'notifications': notifications} return render(request, "bot/commands-api-notifications.html".format(type), context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def revives(request): try: if request.session.get('player'): print('[view.traget.attacks] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.save() error = updateRevives(player) revives = player.revive_set.all() context = { "player": player, "targetcat": True, "revives": revives, "view": { "revives": True } } if error: context.update(error) page = 'target/content-reload.html' if request.method == "POST" else 'target.html' return render(request, page, context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def prune(request): try: if request.session.get('player'): tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() nPlayers = PlayerData.objects.first() context = { "player": player, "nTotal": nPlayers.nTotal, "nInact": nPlayers.nInact, "nValid": nPlayers.nValid, "nInval": nPlayers.nInval, "nPrune": nPlayers.nPrune, "view": { "prune": True } } return render(request, "yata.html", context) else: return returnError(type=403, msg="You might want to log in.") except Exception as e: return returnError(exc=e, session=request.session)
def index(request): try: if request.session.get('player'): print('[view.bot.index] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.active = True if player.dId: print("registered to discord") else: print("not registered to discord") preference = player.preference_set.first() if preference is None: preference = player.preference_set.create() player.save() context = {"player": player, "preference": preference} return render(request, "bot.html", context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def __call__(self, request): # get banned ips playerdata = PlayerData.objects.first() if playerdata is None: ipsBan = [] uidBan = [] else: ipsBan = json.loads(playerdata.ipsBan) uidBan = json.loads(playerdata.uidBan) # return 403 if request.session.get('player', False) and request.session['player'].get( 'tId', -1) in uidBan: return returnError( type=403, msg=mark_safe( '<p><i class="fas fa-gavel"></i>  Your user ID is banned from YATA.</p>' ), home=False) # return 403 elif request.META.get('REMOTE_ADDR') in ipsBan: message = '<p><i class="fas fa-gavel"></i>  You are banned from YATA by IP address.</p>\ <p>If you want to know why contact ingame <a href="https://www.torn.com/profiles.php?XID=2000607" target="_blank">Kivou [2000607]</a>.</p>' return returnError(type=403, msg=mark_safe(message), home=False) else: return self.get_response(request)
def prices(request, itemId): try: if request.method == "POST": item = Item.objects.filter(tId=itemId).first() # create price histogram priceHistory = sorted(json.loads(item.priceHistory).items(), key=lambda x: x[0]) # plot only last 8 points of the Tendency graph = [[t, p, item.weekTendencyA * float(t) + item.weekTendencyB, item.monthTendencyA * float(t) + item.monthTendencyB] for t, p in priceHistory] graphLength = 0 maxTS = priceHistory[-1][0] for i, (t, p, wt, mt) in enumerate(graph): if not int(p): graph[i][1] = "null" # graph[i][2] = "null" # graph[i][3] = "null" else: graphLength += 1 if int(maxTS) - int(t) > 3600 * 24 * 7 or wt < 0: graph[i][2] = "null" if int(maxTS) - int(t) > 3600 * 24 * 31 or mt < 0: graph[i][3] = "null" # convert timestamp to date graph[i][0] = timestampToDate(int(t)) context = {'item': item, "graph": graph, "graphLength": graphLength} return render(request, 'bazaar/prices.html', context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def toggle(request, itemId): try: if request.session.get('player') and request.method == "POST": print('[view.bazaar.updateItem] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() bazaarJson = json.loads(player.bazaarJson) playerList = bazaarJson.get("list", []) item = Item.objects.filter(tId=itemId).first() if itemId in playerList: playerList.remove(itemId) else: playerList.append(itemId) item.stockI = bazaarJson["inventory"].get(str(item.tId), 0) item.stockB = bazaarJson["bazaar"].get(str(item.tId), 0) item.stockD = bazaarJson["display"].get(str(item.tId), 0) item.stock = item.stockI + item.stockB + item.stockD bazaarJson["list"] = playerList player.bazaarJson = json.dumps(bazaarJson) player.save() context = {'player': player, 'item': item, 'list': playerList, "view": {"timer": True}} return render(request, "bazaar/item.html", context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def my(request): try: if request.session.get('player'): player = getPlayer( request.session.get("player", {}).get("tId", -1)) # get/update inventory inventory = player.getInventory(force=True) error = inventory if 'apiError' in inventory else False # get items itemsOnMarket = Item.objects.filter( tId__in=inventory.get("bazaar", {})).order_by('tName') tTypes = { r["tType"] for r in itemsOnMarket.values("tType").distinct() } items = [] # build item list for tType in tTypes: item_list = [] for item in itemsOnMarket.filter(tType=tType): item.stockI = inventory.get("inventory", {}).get(str(item.tId), [0, 0])[0] item.stockB = inventory.get("bazaar", {}).get(str(item.tId), [0, 0])[0] item.stockBP = inventory.get("bazaar", {}).get( str(item.tId), [0, 0])[1] item.stockD = inventory.get("display", {}).get(str(item.tId), [0, 0])[0] item.stock = item.stockI + item.stockB + item.stockD item_list.append(item) items.append((tType, item_list)) context = { "player": player, 'list': json.loads(player.bazaarList), "bazaarcat": True, "allItemsOnMarket": items, "view": { "refreshType": True, "timer": True, "summaryByType": True, "loopType": True }, "keyLevelRequired": 2 } if error: context.update(error) page = 'bazaar/content-reload.html' if request.method == 'POST' else "bazaar.html" return render(request, page, context) else: return returnError(type=403, msg="You might want to log in.") except Exception as e: return returnError(exc=e, session=request.session)
def updateNote(request): try: if request.session.get('player') and request.method == "POST": print('[view.target.updateNote] get player id from session and check POST') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() targetId = request.POST.get("targetId") note = request.POST.get("note") print('[view.target.updateNote] {}: {}'.format(targetId, note)) targetJson = json.loads(player.targetJson) if targetJson["targets"].get(targetId) is not None: targetJson["targets"][targetId]["note"] = note player.targetJson = json.dumps(targetJson) player.save() context = {"target": {"note": note}, "targetId": targetId} return render(request, 'target/targets-line-note.html', context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def index(request): try: if request.session.get('player'): print('[view.traget.index] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.active = True targets = json.loads(player.targetJson).get("targets", dict({})) player.targetInfo = len(targets) player.save() context = { "player": player, "targetcat": True, "targets": targets, "ts": int(timezone.now().timestamp()), "view": { "targets": True } } # if error: # context.update(error) return render(request, 'target.html', context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def updateId(request): try: if request.session.get('player') and request.method == "POST": print('[view.bot.updateId] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() # update inventory of bazaarJson error = False discord = apiCall("user", "", "discord", player.key) if 'apiError' in discord: error = {"apiErrorSub": discord["apiError"]} else: dId = discord.get('discord', {'discordID': ''})['discordID'] player.dId = 0 if dId in [''] else dId player.save() context = {'player': player, 'error': error} return render(request, "bot/discord-id.html", context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def default(request): try: if request.session.get('player'): print('[view.bazaar.default] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.save() # key = player.key bazaarJson = json.loads(player.bazaarJson) playerList = bazaarJson.get("list", []) print('[view.bazaar.default] get all items on market') itemsOnMarket = Item.objects.filter( onMarket=True).order_by('tName') print('[view.bazaar.default] get all tTypes') tTypes = [ r["tType"] for r in itemsOnMarket.values("tType").distinct() ] # print('[view.bazaar.default] {}'.format(tTypes)) print('[view.bazaar.default] create output items') items = {tType: [] for tType in tTypes} inventory = bazaarJson.get("inventory", dict({})) bazaar = bazaarJson.get("bazaar", dict({})) display = bazaarJson.get("display", dict({})) for tType in items: for item in itemsOnMarket.filter(tType=tType): item.stockI = inventory.get(str(item.tId), 0) item.stockB = bazaar.get(str(item.tId), 0) item.stockD = display.get(str(item.tId), 0) item.stock = item.stockI + item.stockB + item.stockD items[tType].append(item) # item.save() context = { "player": player, 'list': playerList, "bazaarcat": True, "allItemsOnMarket": items, "view": { "refreshType": True, "timer": True, "hideType": True } } page = 'bazaar/content-reload.html' if request.method == 'POST' else "bazaar.html" return render(request, page, context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def update(request, itemId): try: if request.session.get('player') and request.method == "POST": print('[view.bazaar.updateItem] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() key = player.key bazaarJson = json.loads(player.bazaarJson) playerList = bazaarJson.get("list", []) print('[view.bazaar.updateItem] get item') item = Item.objects.filter(tId=itemId).first() print('[view.bazaar.updateItem] {}'.format(item)) baz = item.update_bazaar(key=key, n=BazaarData.objects.first().nItems) error = False if 'apiError' in baz: error = baz # update inventory of bazaarJson error = False invtmp = apiCall("user", "", "inventory,display,bazaar", key) for k, v in invtmp.items(): if v is None: invtmp[k] = dict({}) if 'apiError' in invtmp: error = {"apiErrorSub": invtmp["apiError"]} else: # modify user bazaarJson["inventory"] = {str(v["ID"]): v["quantity"] for v in invtmp.get("inventory", dict({}))} bazaarJson["bazaar"] = {str(v["ID"]): v["quantity"] for v in invtmp.get("bazaar", dict({}))} bazaarJson["display"] = {str(v["ID"]): v["quantity"] for v in invtmp.get("display", dict({}))} item.stockI = bazaarJson["inventory"].get(str(item.tId), 0) item.stockB = bazaarJson["bazaar"].get(str(item.tId), 0) item.stockD = bazaarJson["display"].get(str(item.tId), 0) item.stock = item.stockI + item.stockB + item.stockD # item.save() player.bazaarJson = json.dumps(bazaarJson) player.save() context = {'player': player, 'list': playerList, 'item': item, "view": {"timer": True}} if error: context.update(error) return render(request, "bazaar/item.html", context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def login(request): try: print('[view.yata.login] START') if request.method == 'POST': p = request.POST print('[view.yata.login] API call with key: {}'.format(p.get('key'))) user = apiCall('user', '', 'profile', p.get('key')) if 'apiError' in user: print('[view.yata.login] API error: {}'.format(user)) context = user return render(request, 'yata/login.html', context) # create/update player in the database player = Player.objects.filter(tId=user.get('player_id')).first() print('[view.yata.login] get player from database: {}'.format(player)) if player is None: print('[view.yata.login] create new player') player = Player.objects.create(tId=int(user.get('player_id'))) print('[view.yata.login] update player') player.key = p.get('key') player.active = True player.update_info() player.lastActionTS = int(timezone.now().timestamp()) print('[view.yata.login] save player') player.save() print('[view.yata.login] create session') request.session['player'] = {'tId': player.tId, 'name': str(player), 'login': True} check = json.loads(p.get('check')) if check: print('[view.yata.login] set session to expirate in 1 month') # request.session.set_expiry(31536000) # 1 year request.session.set_expiry(2592000) # 1 month else: print('[view.yata.login] set session to expirate when browser closes') request.session.set_expiry(0) # logout when close browser context = {"player": player} return render(request, 'yata/login.html', context) # if not post else: return returnError(type=403, msg="You need to post. Don\'t try to be a smart ass.") # return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def top10(request): try: if request.session.get('player'): print('[view.bazaar.default] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.save() # key = player.key bazaarJson = json.loads(player.bazaarJson) playerList = bazaarJson.get("list", []) print('[view.bazaar.default] create output items') items = {"Sell": [], "Buy": []} inventory = bazaarJson.get("inventory", dict({})) bazaar = bazaarJson.get("bazaar", dict({})) display = bazaarJson.get("display", dict({})) for item in Item.objects.all().order_by('weekTendency')[:10]: item.stockI = inventory.get(str(item.tId), 0) item.stockB = bazaar.get(str(item.tId), 0) item.stockD = display.get(str(item.tId), 0) item.stock = item.stockI + item.stockB + item.stockD items["Buy"].append(item) # item.save() for item in Item.objects.all().order_by('-weekTendency')[:10]: item.stockI = inventory.get(str(item.tId), 0) item.stockB = bazaar.get(str(item.tId), 0) item.stockD = display.get(str(item.tId), 0) item.stock = item.stockI + item.stockB + item.stockD items["Sell"].append(item) # item.save() context = { "player": player, 'list': playerList, "bazaarcat": True, "allItemsOnMarket": items, "view": { "refreshType": True, "timer": True } } page = 'bazaar/content-reload.html' if request.method == 'POST' else "bazaar.html" return render(request, page, context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def readNews(request): try: if request.session.get('player') and request.method == 'POST': tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() news = News.objects.last() news.player.add(player) return HttpResponse("{} marked as read".format(news.type)) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def details(request, tId): try: if request.method == "POST": stock = {'t': Stock.objects.filter(tId=tId).first()} context = {'stock': stock} return render(request, 'stock/details.html', context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def details(request, itemId): try: if request.method == "POST": item = Item.objects.filter(tId=itemId).first() context = {'item': item} return render(request, 'bazaar/details.html', context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception as e: return returnError(exc=e, session=request.session)
def showPinned(request): try: if request.session.get('player') and request.method == "POST": player = getPlayer(request.session["player"].get("tId")) awardsPlayer, awardsTorn, error = player.getAwards() pinnedAwards = awardsPlayer.get('pinnedAwards') return render(request, "awards/pin.html", {"player": player, "pinnedAwards": pinnedAwards}) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception as e: return returnError(exc=e, session=request.session)
def index(request): try: if request.session.get('player'): print('[view.awards.index] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) awardsJson = json.loads(player.awardsJson) userInfo = awardsJson.get('userInfo') error = False tornAwards = Call.objects.first().load() userInfo = apiCall('user', '', 'personalstats,crimes,education,battlestats,workstats,perks,networth,merits,profile,medals,honors,icons', player.key) if 'apiError' in userInfo: error = userInfo else: print("[view.awards.index] update awards") awardsJson["userInfo"] = userInfo player.awardsJson = json.dumps(awardsJson) updatePlayerAwards(player, tornAwards, userInfo) player.save() # get graph data awards = awardsJson.get('awards') graph = [] for k, h in sorted(tornAwards.get("honors").items(), key=lambda x: x[1]["circulation"], reverse=True): # if h.get("rarity") not in ["Unknown Rarity"]: if h.get("circulation", 0) > 0: graph.append([h.get("name", "?"), h.get("circulation", 0), int(h.get("achieve", 0)), h.get("img", ""), h.get("rScore", 0), h.get("unreach", 0)]) graph2 = [] for k, h in sorted(tornAwards.get("medals").items(), key=lambda x: x[1]["circulation"], reverse=True): # if h.get("rarity") not in ["Unknown Rarity"]: if h.get("circulation", 0) > 0: graph2.append([h.get("name", "?"), h.get("circulation", 0), int(h.get("achieve", 0)), h.get("img", ""), h.get("rScore", 0), h.get("unreach", 0)]) context = {"player": player, "graph": graph, "graph2": graph2, "awardscat": True, "view": {"awards": True}} for k, v in json.loads(player.awardsJson).items(): context[k] = v if error: context.update(error) return render(request, "awards.html", context) else: return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def index(request): try: tId = request.session["player"].get("tId") if request.session.get( 'player') else -1 player = getPlayer(tId) awardsPlayer, awardsTorn, error = player.getAwards(force=True) # get graph data awards = awardsPlayer.get('awards') pinnedAwards = awardsPlayer.get('pinnedAwards') graph = [] for k, h in sorted(awardsTorn.get("honors").items(), key=lambda x: x[1]["circulation"], reverse=True): # if h.get("rarity") not in ["Unknown Rarity"]: if h.get("circulation", 0) > 0: graph.append([ h.get("name", "?"), h.get("circulation", 0), int(h.get("achieve", 0)), h.get("img", ""), h.get("rScore", 0), h.get("unreach", 0) ]) graph2 = [] for k, h in sorted(awardsTorn.get("medals").items(), key=lambda x: x[1]["circulation"], reverse=True): # if h.get("rarity") not in ["Unknown Rarity"]: if h.get("circulation", 0) > 0: graph2.append([ h.get("name", "?"), h.get("circulation", 0), int(h.get("achieve", 0)), h.get("img", ""), h.get("rScore", 0), h.get("unreach", 0) ]) context = { "player": player, "pinnedAwards": pinnedAwards, "graph": graph, "graph2": graph2, "awardscat": True, "view": { "awards": True } } for k, v in awardsPlayer.items(): context[k] = v if error: context.update(error) return render(request, "awards.html", context) except Exception as e: return returnError(exc=e, session=request.session)
def index(request): try: if request.session.get('player'): print('[view.bot.index] get player id from session') tId = request.session["player"].get("tId") else: print('[view.bot.index] anon session') tId = -1 player = Player.objects.filter(tId=tId).first() notifications = json.loads(player.notifications) # update discord id error = player.update_discord_id() # get guilds guilds = [[guild.guildName, guild.guildId] for guild in DiscordApp.objects.filter(pk=2).first().guild_set.all()] # this is just for me... apps = False if player.tId in [2000607]: saveBotsConfigs() apps = DiscordApp.objects.values() for app in apps: app["variables"] = json.loads(app["variables"]) context = {"player": player, "apps": apps, "guilds": guilds, "notifications": notifications, "error": error} return render(request, "bot.html", context) except Exception: return returnError()
def index(request): try: if request.session.get('player'): print('[view.loot.index] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() player.lastActionTS = int(timezone.now().timestamp()) player.active = True player.save() context = { "player": player, "NPCs": [npc for npc in NPC.objects.filter(show=True).order_by('tId')] } return render(request, "loot.html", context) else: player = Player.objects.filter(tId=-1).first() context = { "player": player, "NPCs": [npc for npc in NPC.objects.filter(show=True).order_by('tId')] } return render(request, "loot.html", context) # return returnError(type=403, msg="You might want to log in.") except Exception: return returnError()
def togglePin(request): if request.session.get('player') and request.method == "POST": post_payload = get_payload(request) player = getPlayer(request.session["player"].get("tId")) pinnedAwards = json.loads(player.awardsPinn) awardId = post_payload.get("awardId") if awardId is not None and not post_payload.get("check", False): if awardId in pinnedAwards: pinnedAwards.remove(awardId) else: if awardId.split("_")[-1].isdigit(): if len(pinnedAwards) == 3: pinnedAwards.pop(0) pinnedAwards.append(awardId) player.awardsPinn = json.dumps(pinnedAwards) player.save() if request.session.get('json-output'): return JsonResponse({"awardId": awardId, "pinnedAwards": pinnedAwards}, status=200) else: return render(request, "awards/pin-button.html", {"player": player, "awardId": awardId, "pinnedAwards": pinnedAwards}) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message)
def analytics(request): try: fold = "analytics" ls = sorted(os.listdir("{}/{}".format(settings.STATIC_ROOT, fold))) context = {"reports": ls, 'view': {'analytics': True}} return render(request, 'yata.html', context) except BaseException: return returnError()
def logout(request): try: print('[view.yata.logout] delete session') del request.session['player'] return HttpResponseRedirect(reverse('index')) except Exception: return returnError()
def updateId(request): try: if request.session.get('player') and request.method == "POST": print('[view.bot.updateId] get player id from session') tId = request.session["player"].get("tId") player = Player.objects.filter(tId=tId).first() error = player.update_discord_id() context = {'player': player, 'error': error} return render(request, "bot/discord-id.html", context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception: return returnError()
def delete(request, itemId): try: if request.session.get('player') and request.method == "POST": item = Item.objects.filter(tId=itemId).first() item.lastUpdateTS = 0 item.marketdata_set.all().delete() item.save() context = {'item': item, "view": {"timer": True}} return render(request, "bazaar/item.html", context) else: message = "You might want to log in." if request.method == "POST" else "You need to post. Don\'t try to be a smart ass." return returnError(type=403, msg=message) except Exception as e: return returnError(exc=e, session=request.session)