Fix this BS with foreignKey
This commit is contained in:
1 parent
07049b5bdb
commit
c977b07222
3 files changed
+2
-5
No files matched your search
@@ -296,7 +296,6 @@ def reportResults(data, wins, losses, draws, crashes, timeloss):
|
|||||||
'timeloss' : timeloss,
|
'timeloss' : timeloss,
|
||||||
'username' : USERNAME,
|
'username' : USERNAME,
|
||||||
'password' : PASSWORD,
|
'password' : PASSWORD,
|
||||||
'profileid' : data['profile']['id'],
|
|
||||||
'machineid' : data['machine']['id'],
|
'machineid' : data['machine']['id'],
|
||||||
'resultid' : data['result']['id'],
|
'resultid' : data['result']['id'],
|
||||||
'testid' : data['test']['id']}
|
'testid' : data['test']['id']}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ class Engine(Model):
|
|||||||
|
|
||||||
class Profile(Model):
|
class Profile(Model):
|
||||||
|
|
||||||
user = OneToOneField(User, on_delete=CASCADE)
|
user = ForeignKey(User, PROTECT, related_name='user')
|
||||||
games = IntegerField(default=0)
|
games = IntegerField(default=0)
|
||||||
tests = IntegerField(default=0)
|
tests = IntegerField(default=0)
|
||||||
repo = CharField(max_length=256, blank=True)
|
repo = CharField(max_length=256, blank=True)
|
||||||
|
|||||||
+1
-3
@@ -169,7 +169,6 @@ def workloadDictionary(machine, result, test):
|
|||||||
# specification for both engines. Group the dev and base
|
# specification for both engines. Group the dev and base
|
||||||
# options with the coressponding engine, for easy usage
|
# options with the coressponding engine, for easy usage
|
||||||
return {
|
return {
|
||||||
'profile' : { 'id' : profile.id },
|
|
||||||
'machine' : { 'id' : machine.id, },
|
'machine' : { 'id' : machine.id, },
|
||||||
'result' : { 'id' : result.id, },
|
'result' : { 'id' : result.id, },
|
||||||
'test' : {
|
'test' : {
|
||||||
@@ -214,7 +213,6 @@ def update(request):
|
|||||||
games = wins + losses + draws
|
games = wins + losses + draws
|
||||||
|
|
||||||
# Parse the various IDs sent back
|
# Parse the various IDs sent back
|
||||||
profileid = int(request.POST['profileid'])
|
|
||||||
machineid = int(request.POST['machineid'])
|
machineid = int(request.POST['machineid'])
|
||||||
resultid = int(request.POST['resultid'])
|
resultid = int(request.POST['resultid'])
|
||||||
testid = int(request.POST['testid'])
|
testid = int(request.POST['testid'])
|
||||||
@@ -232,7 +230,7 @@ def update(request):
|
|||||||
finished = passed or failed
|
finished = passed or failed
|
||||||
|
|
||||||
# Update total # of games played for the User
|
# Update total # of games played for the User
|
||||||
Profile.objects.filter(id=profileid).update(games=F('games') + games)
|
Profile.objects.filter(user=user).update(games=F('games') + games)
|
||||||
|
|
||||||
# Just force an update to Machine.update
|
# Just force an update to Machine.update
|
||||||
Machine.objects.filter(id=machineid).update()
|
Machine.objects.filter(id=machineid).update()
|
||||||
|
|||||||
Reference in new issue
Block a user