tum 5 years ago
parent
commit
169120f2f5
6 changed files with 38 additions and 7 deletions
  1. BIN
      __pycache__/app.cpython-36.pyc
  2. BIN
      __pycache__/fpl_lib.cpython-36.pyc
  3. 11 6
      app.py
  4. 11 0
      fpl_lib.py
  5. 2 1
      templates/index.html
  6. 14 0
      templates/player.html

BIN
__pycache__/app.cpython-36.pyc


BIN
__pycache__/fpl_lib.cpython-36.pyc


+ 11 - 6
app.py

@@ -18,6 +18,11 @@ def search_player(name):
18 18
     results = sfp.search_player(name)
19 19
     return jsonify(output=results)
20 20
 
21
+@app.route('/player/<pid>')
22
+def get_player(pid):
23
+    player = sfp.get_player(int(pid))
24
+    return render_template("player.html", player = player)
25
+
21 26
 @app.route('/lgs', methods=["GET", "POST"])
22 27
 def lgs():
23 28
     lgs = mongo.db.lgs.find()
@@ -57,12 +62,12 @@ def team(team_id):
57 62
 
58 63
     currentPlayers = []
59 64
 
60
-
61
-    for p in team['players']:
62
-        try:
63
-            currentPlayers.append(sfp.get_player(p))
64
-        except:
65
-            currentPlayers.append(None)
65
+    if 'players' in team:
66
+        for p in team['players']:
67
+            try:
68
+                currentPlayers.append(sfp.get_player(p))
69
+            except:
70
+                currentPlayers.append(None)
66 71
 
67 72
     if 'searchBtn' in request.form:
68 73
         name = request.form.get('name', '')

+ 11 - 0
fpl_lib.py

@@ -19,6 +19,17 @@ class Team:
19 19
         total = sum(p.goals_scored for p in self.players)
20 20
         print(f"Total Score => {total}")
21 21
 
22
+    def manage_squad(self):
23
+        pass
24
+
25
+    def set_starting(self):
26
+        pass
27
+
28
+    def transfer(self):
29
+        pass
30
+
31
+
32
+
22 33
 
23 34
 class Leauge:
24 35
     def __init__(self, title, mongo=None):

+ 2 - 1
templates/index.html

@@ -6,13 +6,14 @@
6 6
         <input type=hidden name='selectTeam' value="{{ selectTeam }}" />
7 7
     <ol>
8 8
     {% for p in players %}
9
-    <li><input type=checkbox name="players" value="{{ p.id }}" />{{ p }}</li>
9
+    <li><input type=checkbox name="players" value="{{ p.id }}" /><a href="{{ url_for(".get_player", pid = p.id) }}">{{ p }}</a></li>
10 10
     {% endfor %}
11 11
     </ol>
12 12
     <input type="submit" name="selectPlayerBtn"  value="Select Player">
13 13
     </form>
14 14
     </div>
15 15
     <div style='width:50%; float:left'>
16
+        <a href="{{ url_for("lgs") }}">Lgs</a>
16 17
         <h1>Teams</h1>
17 18
         {{ currentTeam }}
18 19
         <h2>P</h2>

+ 14 - 0
templates/player.html

@@ -0,0 +1,14 @@
1
+{% extends "base.html" %}
2
+{% block content %}
3
+<h1>Player Info</h1>
4
+<table class='table table-bordered table-striped'>
5
+    {% for k  in player.__dir__() %}
6
+    <tr>
7
+        <td>{{ k }}</td>
8
+        <td>{{ player[k] }}</td>
9
+    </tr>
10
+    {% endfor %}
11
+</table>
12
+
13
+        
14
+{% endblock %}