-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
767 lines (685 loc) · 32.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import webapp2
import jinja2
import os
import random
import datetime
from google.appengine.api import users
from models import *
JINJA_ENVIRONMENT=jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'],
autoescape=True)
class TemplateRender(webapp2.RequestHandler):
def render_webpage(self,template_values,template):
self.response.headers['Content-Type'] = 'text/html'
self.response.write(template.render(template_values))
def get_template(self,template_file):
return JINJA_ENVIRONMENT.get_template(template_file)
class Index(TemplateRender):
#template_values:
#
#{
#'authorization_season_add':
#'authorization_payment_view':
#'authorization_match_add':
#'authorization_payment_add':
#'authenticated':
#'authorization_player_add':
#'authorization_admin':
#'matches': [
# {
# 'season':
# 'list_matches': [
# {
# 'match_round':
# 'teamA_score':
# 'teamB_score':
# 'match_date':
# 'players': []
# }
# ]
# }
#]
#}
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
else:
template_values = {}
season_id = self.request.query_string
if season_id == '':
season = Season.get_season_list()[0]
else:
season = season_id.split("=")[1]
matches = []
#for season in season_list:
season_dict = {'season': season}
season_key = Season.get_season_key(season)
if season_key:
all_matches_in_season = Match.get_all_matches(season_key)
else:
webapp2.abort(404)
list_matches = []
for match in all_matches_in_season:
match_data = {
'match_round': match.match_round,
'match_date': match.match_date,
'teamA_score': match.teamA_score,
'teamB_score': match.teamB_score,
}
teamA = [Player.get_player_by_id(player) for player in match.teamA]
teamB = [Player.get_player_by_id(player) for player in match.teamB]
teamA_players = []
for player in teamA:
teamA_players.append(player['player_lastname'] + ' ' + player['player_firstname'])
teamB_players = []
for player in teamB:
teamB_players.append(player['player_lastname'] + ' ' + player['player_firstname'])
match_data['players'] = map(None,teamA_players,teamB_players)
list_matches.append(match_data)
season_dict['list_matches'] = list_matches
matches.append(season_dict)
template_values['matches'] = matches
season_list = Season.get_season_list()
template_values['season_list'] = season_list
self.render_webpage(template_values,self.get_template('list_match.html'))
#self.response.write(Season.get_season_key(season))
class AddSeason(TemplateRender):
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
if template_values['authorization_season_add']:
season_list = Season.get_season_list()
template_values['seasons'] = season_list
self.render_webpage(template_values,self.get_template('add_season.html'))
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_season.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_season.html'))
def post(self):
user = users.get_current_user()
if user:
user_authorization = UserAuthorization.get_authorization(user.email())
if user_authorization['authorization_season_add']:
season_number = self.request.get('season')
season = Season(id=season_number)
season.put()
self.redirect('add_season')
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_season.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_season.html'))
class AddPlayer(TemplateRender):
#template_values:
#
#{
#'authorization_season_add':
#'authorization_payment_view':
#'authorization_match_add':
#'authorization_payment_add':
#'authenticated':
#'authorization_player_add':
#'authorization_admin':
#'players': [
# {
# 'season':
# 'player_list': [
# {
# 'player_id':
# 'player_firstname':
# 'player_lastname':
# }
# ]
# }
#]
#}
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
if template_values['authorization_player_add']:
season_list = Season.get_season_list()
player_data_season = []
for season in season_list:
player_list = Player.get_all_players_from_season(Season.get_season_key(season))
player_data = []
for player in player_list:
player_dict = {
'player_id': player.player_id,
'player_firstname': player.player_firstname,
'player_lastname': player.player_lastname,
}
player_data.append(player_dict)
player_data_season.append({'season': season, 'player_list': player_data})
template_values['players'] = player_data_season
self.render_webpage(template_values,self.get_template('add_player.html'))
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_player.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_player.html'))
def post(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
if template_values['authorization_player_add']:
player_id = int(Player.get_highest_player_id() + 1)
player_firstname = self.request.get('firstname')
player_lastname = self.request.get('lastname')
player_season = self.request.get('season')
season_key = Season.get_season_key(player_season)
player_data = {
'player_id': player_id,
'player_firstname': player_firstname,
'player_lastname': player_lastname,
'season_key': season_key
}
player_key = Player.add_player(player_data)
PlayerStat.init_player_stat(player_key)
self.redirect('add_player')
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_player.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_player.html'))
class AddMatch(TemplateRender):
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
if template_values['authorization_match_add']:
season = self.request.query_string
if season == '':
season_list = Season.get_season_list()
template_values['seasons'] = season_list
else:
season = season.split("=")[1]
season_key = Season.get_season_key(season)
players = Player.get_all_players_from_season(season_key)
player_list = []
for player in players:
player_list.append({
'player_id': player.player_id,
'player_firstname': player.player_firstname,
'player_lastname': player.player_lastname,
})
template_values['season'] = season
template_values['player_list'] = player_list
template_values['add_match_block'] = True
self.render_webpage(template_values,self.get_template('add_match.html'))
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_match.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_match.html'))
def post(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
if template_values['authorization_match_add']:
request_data = self.request.body.split('&')
season = request_data[0].split('=')[1]
season_key = Season.get_season_key(season)
match_date = request_data[1].split('=')[1].split('-')
teamA_score = int(request_data[2].split('=')[1])
teamB_score = int(request_data[3].split('=')[1])
match_round = Match.get_highest_match_round(season_key) + 1
teamA = []
teamB = []
for player in request_data[4:]:
player_split = player.split('=')
if not player_split[1] == '':
if player[4] == 'A':
teamA.append(int(player_split[1]))
elif player[4] == 'B':
teamB.append(int(player_split[1]))
match_data = {
'season_key': season_key,
'match_round': match_round,
'match_date': datetime.date(int(match_date[0]),int(match_date[1]),int(match_date[2])),
'teamA_score': teamA_score,
'teamB_score': teamB_score,
'teamA': teamA,
'teamB': teamB,
}
Match.add_match(match_data)
players = Player.get_all_players_from_season(season_key)
for player in players:
if player.player_id in teamA+teamB:
match_data = {'played': 1}
if teamA_score > teamB_score:
if player.player_id in teamA:
match_data['win'] = 1
elif player.player_id in teamB:
match_data['win'] = 0
elif teamA_score == teamB_score:
match_data['win'] = 0.5
else:
if player.player_id in teamA:
match_data['win'] = 0
elif player.player_id in teamB:
match_data['win'] = 1
if player.player_id in teamA:
match_data['goals_for'] = teamA_score
match_data['goals_against'] = teamB_score
else:
match_data['goals_for'] = teamB_score
match_data['goals_against'] = teamA_score
else:
match_data = {'played': 0, 'win': 0, 'goals_for': 0, 'goals_against': 0}
PlayerStat.update_player_stat(player.key,match_data,match_round)
self.redirect('add_match')
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_match.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_match.html'))
class ListStat(TemplateRender):
#template_values:
#
#{
#'authorization_season_add':
#'authorization_payment_view':
#'authorization_match_add':
#'authorization_payment_add':
#'authenticated':
#'authorization_player_add':
#'authorization_admin':
#'players_stat': [
# {
# 'season':
# 'player_list': [
# {
# 'player_id':
# 'player_firstname':
# 'player_lastname':
# }
# ]
# }
#]
#}
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
else:
template_values = {}
season_id = self.request.query_string
if season_id == '':
season = Season.get_season_list()[0]
else:
season = season_id.split("=")[1]
stat_list = []
#for season in season_list:
season_key = Season.get_season_key(season)
if season_key:
player_stat_for_season = PlayerStat.get_player_stat(Season.get_season_key(season))
else:
webapp2.abort(404)
all_players_data = []
counter = 1
for player_stat in player_stat_for_season:
player = player_stat.key.parent().get()
player_data = {
'player_id': player.player_id,
'player_firstname': player.player_firstname,
'player_lastname': player.player_lastname,
'player_ontable': player_stat.on_table,
'player_number_of_games_played': player_stat.number_of_games_played,
'player_wins': player_stat.wins,
'player_wins_percentage': format(player_stat.wins_percentage,'.2f'),
'player_goals_for': player_stat.goals_for,
'player_goals_against': player_stat.goals_against,
'player_goals_diff': player_stat.goals_diff,
'player_participation': format(player_stat.participation, '.2f'),
}
if player_stat.on_table:
player_data['player_position'] = counter
counter = counter + 1
else:
player_data['player_position'] = 0
all_players_data.append(player_data)
stat_list.append({'season': season, 'player_stat': all_players_data})
template_values['stat_list'] = stat_list
season_list = Season.get_season_list()
template_values['season_list'] = season_list
## Za per player statistiko
all_players = Player.get_all_players_from_season(season_key)
all_matches = Match.get_all_matches(season_key)
player_position_in_matrix = {}
matrix_data = {
'wins': 0,
'matches': 0,
'percentage': 0.0,
'goals_for': 0,
'goals_against': 0,
'goals_diff': 0,
}
matrix = [[matrix_data for x in range(len(all_players))] for x in range(len(all_players))]
counter = 0
for player in all_players:
player_position_in_matrix[player.player_id] = counter
counter = counter + 1
for match in all_matches:
teamA = match.teamA
teamB = match.teamB
teamA_score = match.teamA_score
teamB_score = match.teamB_score
for player in teamA:
if teamA_score > teamB_score:
wins = 1
elif teamA_score == teamB_score:
wins = 0.5
else:
wins = 0
for player2 in teamA:
if player != player2:
current_data = matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]].copy()
current_data['wins'] = current_data['wins'] + wins
current_data['matches'] = current_data['matches'] + 1
current_data['percentage'] = format(100*current_data['wins']/float(current_data['matches']),'.2f')
current_data['goals_for'] = current_data['goals_for'] + teamA_score
current_data['goals_against'] = current_data['goals_against'] + teamB_score
current_data['goals_diff'] = current_data['goals_for'] - current_data['goals_against']
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = current_data
else:
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = None
for player in teamB:
if teamA_score > teamB_score:
wins = 0
elif teamA_score == teamB_score:
wins = 0.5
else:
wins = 1
for player2 in teamB:
if player != player2:
current_data = matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]].copy()
current_data['wins'] = current_data['wins'] + wins
current_data['matches'] = current_data['matches'] + 1
current_data['percentage'] = format(100*current_data['wins']/float(current_data['matches']),'.2f')
current_data['goals_for'] = current_data['goals_for'] + teamB_score
current_data['goals_against'] = current_data['goals_against'] + teamA_score
current_data['goals_diff'] = current_data['goals_for'] - current_data['goals_against']
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = current_data
else:
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = None
player_index_list = range(len(all_players))
for player_key in player_position_in_matrix.keys():
player = Player.get_player_by_id(player_key)
player_index_list[player_position_in_matrix[player_key]] = player['player_lastname'] + ' ' + player['player_firstname']
template_values['player_index_list'] = player_index_list
template_values['per_player_stat'] = matrix
self.render_webpage(template_values,self.get_template('list_stat.html'))
class AddPayment(TemplateRender):
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
if template_values['authorization_payment_add']:
season_list = Season.get_season_list()
for season in season_list:
player_list = Player.get_all_players_from_season(Season.get_season_key(season))
season_string = self.request.query_string
if season_string == '':
season_list = Season.get_season_list()
template_values['seasons'] = season_list
else:
season = season_string.split("=")[1]
season_key = Season.get_season_key(season)
players = Player.get_all_players_from_season(season_key)
player_list = []
for player in players:
player_list.append({
'player_id': player.player_id,
'player_firstname': player.player_firstname,
'player_lastname': player.player_lastname,
})
template_values['season'] = season
template_values['player_list'] = player_list
template_values['add_payment_block'] = True
self.render_webpage(template_values,self.get_template('add_payment.html'))
else:
template_values['error_msg_add_payment'] = True
self.render_webpage(template_values,self.get_template('add_payment.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_payment.html'))
def post(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
if template_values['authorization_payment_add']:
request_data = self.request.body.split('&')
season = request_data[0].split('=')[1]
match_date = request_data[1].split('=')[1].split('-')
number_of_entries = len(request_data[2:])/3
for i in range(number_of_entries):
player_data = {
'player_key': Player.get_player_key_by_id(int(request_data[2 + i*3].split('=')[1])),
'date': datetime.date(int(match_date[0]),int(match_date[1]),int(match_date[2])),
'payment': float(request_data[3 + i*3].split('=')[1]),
'debt': float(request_data[4 + i*3].split('=')[1]),
}
payment_key = PlayerPayments.add_payment(player_data)
self.redirect('add_payment')
else:
template_values['error_msg_authorization'] = True
self.render_webpage(template_values,self.get_template('add_match.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('add_match.html'))
class ListPayments(TemplateRender):
def get(self):
user = users.get_current_user()
if user:
template_values = UserAuthorization.get_authorization(user.email())
template_values['authenticated'] = True
if template_values['authorization_payment_view']:
request_player_id = self.request.query_string
if request_player_id == '':
template_values['payments_list_block'] = True
season_list = Season.get_season_list()
payments = []
for season in season_list:
player_list = Player.get_all_players_from_season(Season.get_season_key(season))
payment_for_player_season = []
for player in player_list:
player_payments_data = PlayerPayments.calculate_payment_data(player.key)
player_payments_data['player_owe'] = player_payments_data['player_debt'] - player_payments_data['player_payments']
player_payments_data['player_id'] = player.player_id
player_payments_data['player_firstname'] = player.player_firstname
player_payments_data['player_lastname'] = player.player_lastname
payment_for_player_season.append(player_payments_data)
payments.append({'season': season, 'player_payment_data': payment_for_player_season})
template_values['payments'] = payments
else:
player_id = int(request_player_id.split('=')[1])
player_key = Player.get_player_key_by_id(player_id)
player_data = player_key.get()
template_values['player_firstname'] = player_data.player_firstname
template_values['player_lastname'] = player_data.player_lastname
player_payments = PlayerPayments.get_all_payments_for_player(player_key)
payments = []
if player_payments:
for payment in player_payments:
payments.append({
'payment_date': payment.date,
'payment_payment': payment.payment,
'payment_debt': payment.debt,
})
template_values['payments'] = payments
self.render_webpage(template_values,self.get_template('list_payments.html'))
else:
template_values['error_msg_list_payments'] = True
self.render_webpage(template_values,self.get_template('list_payments.html'))
else:
template_values = {'error_msg_login': True}
self.render_webpage(template_values,self.get_template('list_payments.html'))
class Login(TemplateRender):
def get(self):
self.redirect(users.create_login_url('/'))
class Logout(TemplateRender):
def get(self):
self.redirect(users.create_logout_url('/'))
class Authorization(TemplateRender):
def get(self):
template_values = {}
self.render_webpage(template_values,self.get_template('authorization.html'))
def post(self):
user_email = self.request.get('email')
user_admin = True if self.request.get('admin') == 'on' else False
user_season = True if self.request.get('season') == 'on' else False
user_player = True if self.request.get('player') == 'on' else False
user_match = True if self.request.get('match') == 'on' else False
user_payment_add = True if self.request.get('payment_add') == 'on' else False
user_payment_view = True if self.request.get('payment_view') == 'on' else False
userauthorization = UserAuthorization(
user_email = user_email,
authorization_payment_view = user_payment_view,
authorization_payment_add = user_payment_add,
authorization_season_add = user_season,
authorization_player_add = user_player,
authorization_match_add = user_match,
authorization_admin = user_admin)
userauthorization.put()
self.response.write(userauthorization)
class Test(TemplateRender):
def get(self):
all_seasons = Season.get_season_list()
season_key = Season.get_season_key(all_seasons[0])
all_players = Player.get_all_players_from_season(season_key)
all_matches = Match.get_all_matches(season_key)
player_position_in_matrix = {}
matrix_data = {
'wins': 0,
'matches': 0,
'percentage': 0.0,
'goals_for': 0,
'goals_against': 0,
'goals_diff': 0,
}
matrix = [[matrix_data for x in range(len(all_players))] for x in range(len(all_players))]
counter = 0
for player in all_players:
player_position_in_matrix[player.player_id] = counter
counter = counter + 1
for match in all_matches:
teamA = match.teamA
teamB = match.teamB
teamA_score = match.teamA_score
teamB_score = match.teamB_score
for player in teamA:
#self.response.write(player)
if teamA_score > teamB_score:
wins = 1
elif teamA_score == teamB_score:
wins = 0.5
else:
wins = 0
self.response.write(player)
for player2 in teamA:
self.response.write(player2)
if player != player2:
current_data = matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]].copy()
#self.response.write(current_data)
current_data['wins'] = current_data['wins'] + wins
#self.response.write(current_data)
#self.response.write(matrix)
self.response.write('<br>')
current_data['matches'] = current_data['matches'] + 1
current_data['percentage'] = format(current_data['wins']/float(current_data['matches']),'.2f')
current_data['goals_for'] = current_data['goals_for'] + teamA_score
current_data['goals_against'] = current_data['goals_against'] + teamB_score
current_data['goals_diff'] = current_data['goals_for'] - current_data['goals_against']
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = current_data
else:
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = None
for player in teamB:
#self.response.write(player)
if teamA_score > teamB_score:
wins = 0
elif teamA_score == teamB_score:
wins = 0.5
else:
wins = 1
self.response.write(player)
for player2 in teamB:
self.response.write(player2)
if player != player2:
current_data = matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]].copy()
#self.response.write(current_data)
current_data['wins'] = current_data['wins'] + wins
#self.response.write(current_data)
#self.response.write(matrix)
self.response.write('<br>')
current_data['matches'] = current_data['matches'] + 1
current_data['percentage'] = format(current_data['wins']/float(current_data['matches']),'.2f')
current_data['goals_for'] = current_data['goals_for'] + teamB_score
current_data['goals_against'] = current_data['goals_against'] + teamA_score
current_data['goals_diff'] = current_data['goals_for'] - current_data['goals_against']
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = current_data
else:
matrix[player_position_in_matrix[player]][player_position_in_matrix[player2]] = None
self.response.write('<br>')
self.response.write('<br>')
self.response.write(player_position_in_matrix)
self.response.write('<br>')
self.response.write('<br>')
self.response.write('<table border="1" style="width:100%"><tr><td>')
for i in matrix:
for j in i:
self.response.write(j)
self.response.write('<br>')
self.response.write('<br>')
self.response.write('</td></tr></table>')
# self.response.write(matrix)
#self.response.write(all_players)
#self.response.write(all_matches)
#self.response.write(player_position_in_matrix)
#self.response.write(len(all_players))
#self.render_webpage(template_values,self.get_template('list_stat.html'))
app = webapp2.WSGIApplication([
('/', Index),
('/add_season', AddSeason),
('/add_player', AddPlayer),
('/add_match', AddMatch),
('/list_stat', ListStat),
('/add_payment', AddPayment),
('/list_payments', ListPayments),
('/authorization', Authorization),
('/login', Login),
('/logout', Logout),
('/test', Test),
], debug=False)