In [1]:
import os, sys
sys.path.insert(0, '/home/trax/trax/website')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trax.settings")
import django
django.setup()
from tracks.models import Track, Laptime
from players.models import Player
from events.models import *
from vehicles.models import *
In [3]:
# Track remover
for x in (127,):
t = Track.objects.get(pk=x)
print (t.title)
t.delete()
In [ ]:
p = Player.objects.get(username__icontains='fishy')
#for lt in p.laptime_set.all().order_by('-created')[1:]:
# lt
p
In [ ]:
a,b = list(Vehicle.objects.filter(name__icontains="Tyran"))
a
b
In [ ]:
b.delete()
In [ ]:
for t in Track.objects.filter(title__icontains="fish"):
t.creator = p
t.save()
In [ ]:
In [ ]:
print ([ (x.pk,x) for x in list(Track.objects.filter(title__istartswith="Grotti F1 Cluck", title__icontains="2017"))])
In [ ]:
In [ ]:
track.laptime_set.all()
In [ ]:
for t in Track.objects.filter(game_mode="land").order_by('route_length_km'):
print(t.route_length_km, t.typical_laptime)
#t.creator = p
#t.save()
In [ ]:
p = Player.objects.get(username="efo_kesha_f1")
p.set_password("Don0t4get")
p.save()
In [8]:
Player.objects.filter(username__icontains="worb")
Out[8]:
In [7]:
p = Player.objects.get(username="thqckbrwnfx")
p.username = 'XOFNWORBKCIUQEHT'.lower()
p.save()
In [ ]:
for t in Track.objects.filter(author__icontains="hiberg").order_by('-pk'):
print(t.get_absolute_url(), t.title, t.creator, t.duration, t.laptime_set.all().count())
In [ ]:
for x in Track.objects.all().order_by('-pk')[:50]:
print (x, x.get_absolute_url(), len(list(x.laptime_set.all())))
In [ ]:
from players.utils import update_player_racing_stats
for p in Player.objects.all().order_by("defaultspeedmultiplier"):
update_player_racing_stats(p)
print(p, p.defaultspeedmultiplier)
In [ ]:
u = Player.objects.get(username__startswith="tony_sop")
In [ ]:
x = u.laptime_set.all().order_by('-pk')[0]
In [ ]:
y = x.track.laptime_set.all().order_by('-pk')[0]
In [ ]:
y.delete()
In [ ]:
In [ ]:
lt = p.laptime_set.all().order_by('-pk')[0]
In [ ]:
import datetime
delt = datetime.timedelta(seconds=60*60)
delt
lt.created = lt.created - delt
lt.save()
In [ ]:
p = Player.objects.get(username__icontains='imfish')
t = Track.objects.get(title__icontains='maibats')
print(p, "-----", t, "-----", t.creator, t.author)
In [ ]:
t.creator = p
t.save()
In [ ]:
t.author
In [ ]:
In [ ]:
p = Player.objects.get(username__icontains='coyne')
from events.models import Hotlapping
h = Hotlapping.objects.get(pk=3)
h.owner = p
h.save()
In [ ]:
h.owner
In [ ]:
from tracks.models import Laptime
In [ ]:
xxx = list(Laptime.objects.filter(track=t))
In [ ]:
print ([(xx.created, xx.player.username, xx.vehicle.name) for xx in xxx])
In [ ]:
a = xxx[0]
a.delete()
In [ ]:
In [ ]:
l = Laptime.objects.filter(player__username="nerfstick").order_by("-pk")[0]
l.track, l.vehicle, l.duration
In [ ]:
l.millis = l.millis + 60000
l.millis_per_km = round(l.millis / l.track.route_length_km)
In [ ]:
l.save()
In [ ]:
l.millis_per_km
In [ ]:
l = Laptime.objects.all().order_by("-pk")[0]
In [ ]:
ss = l.ssrparticipation_set.all()[0]
In [ ]:
st = ss.staggeredstartrace
In [ ]:
for p in st.ssrparticipation_set.all():
print (p.player, p.vehicle, p.millis)
In [ ]:
p.laptime
In [ ]:
Hotlapevent stuff
In [ ]:
h = Hotlapping.objects.all().order_by('-pk')[0]
In [ ]:
h.owner = p
h.save()
In [ ]:
from vehicles.models import Vehicle
a,b = Vehicle.objects.filter(name__startswith="JB")
In [ ]:
a,b
In [ ]:
b.cc_laptime, a.cc_laptime
In [ ]:
b.delete()
In [ ]:
### MISC
t = Track.objects.get(pk=266)
t.delete()
In [ ]:
from vehicles.models import *
v = Vehicle.objects.get(name="Rat Rod")
v.delete()
In [ ]:
vc = VehicleClass.objects.all()[4]
dir(vc)
In [ ]:
vc.name
In [ ]:
for x in VehicleClass.objects.filter(name__endswith="_B"):
print(x.name)
for name in "Muscle Sports_Classic".split():
for ext in "AB":
cl = VehicleClass.objects.get(name="{0}_{1}".format(name, ext))
print(name, ext, '---------------')
print([x.name for x in list(cl.vehicle_set.all())])
#cl = VehicleClass(name="Sports_Classic_B")
#cl.save()
#for x in VehicleClass.objects.filter(name__endswith='_A'):
# if x.vehicle_set.all().count() == 0:
# x.delete()
In [ ]:
In [2]:
u=Player.objects.get(username__startswith="xenocl")
In [5]:
l = u.laptime_set.all()[0]
In [7]:
hltime = l.hotlappinglaptime_set.all()[0]
In [8]:
hltime.delete()
Out[8]:
In [14]:
a,b,c,d=u.laptime_set.all()[:4]
In [17]:
c.hotlapping_set.all().delete()
Out[17]:
In [18]:
a,b,c
Out[18]:
In [ ]: