Browse Source

Fix login issue, add link to RR page

JoostSijm 6 years ago
parent
commit
f31d9fab0a
4 changed files with 29 additions and 37 deletions
  1. 4 0
      app/models.py
  2. 1 1
      app/modules/auth/app.py
  3. 2 2
      app/modules/vote/app.py
  4. 22 34
      app/modules/vote/templates/vote/codes.j2

+ 4 - 0
app/models.py

@@ -53,6 +53,10 @@ class User(db.Model, UserMixin):
         """Check if password is correct"""
         """Check if password is correct"""
         return argon2.check_password_hash(self.password, password)
         return argon2.check_password_hash(self.password, password)
 
 
+    def game_url(self):
+        """Give profile url"""
+        return "https://rivalregions.com/#slide/profile/%d" % self.game_id
+
 
 
     question_id = db.Column(
     question_id = db.Column(
         db.Integer,
         db.Integer,

+ 1 - 1
app/modules/auth/app.py

@@ -92,4 +92,4 @@ def register():
 def logout():
 def logout():
     """Logout function for users"""
     """Logout function for users"""
     logout_user()
     logout_user()
-    return redirect(url_for('static.show'))
+    return redirect('')

+ 2 - 2
app/modules/vote/app.py

@@ -21,8 +21,8 @@ BLUEPRINT = Blueprint(
 )
 )
 
 
 @register_menu(BLUEPRINT, 'vote', 'Vote')
 @register_menu(BLUEPRINT, 'vote', 'Vote')
-@login_required
 @BLUEPRINT.route("/")
 @BLUEPRINT.route("/")
+@login_required
 def main():
 def main():
     """Ballots overview"""
     """Ballots overview"""
     ballots = Ballot.query.all()
     ballots = Ballot.query.all()
@@ -33,8 +33,8 @@ def main():
     )
     )
 
 
 
 
-@login_required
 @BLUEPRINT.route("/codes")
 @BLUEPRINT.route("/codes")
+@login_required
 def codes():
 def codes():
     """codes overview"""
     """codes overview"""
     code = Code.query.order_by(Code.expire_date.desc()).first()
     code = Code.query.order_by(Code.expire_date.desc()).first()

+ 22 - 34
app/modules/vote/templates/vote/codes.j2

@@ -1,38 +1,26 @@
 {% extends "layout/backend.j2" %}
 {% extends "layout/backend.j2" %}
 {% block content %}
 {% block content %}
-<h1>Votes</h1>
-<div class="row">
-    <div class="col-sm">
-        <div class="card">
-            <div class="card-header">
-                Votes
-                <div class="float-right">
-                    <a href="{{ url_for('vote.create') }}" class="btn btn-secondary btn-sm">Create</a>
-                </div>
-            </div>
-            <div class="card-body table-responsive">
-                <table class="table table-striped table-sm">
-                    <thead>
-                        <tr>
-                            <th>Name</th>
-                            <th>Discord</th>
-                            <th>Rival Regions</th>
-                            <th>Code</th>
-                        </tr>
-                    </thead>
-                    <tbody>
-                        {% for user in users %}
-                        <tr>
-                            <td>{{ user.name }}</td>
-                            <td>{{ user.discord }}</td>
-                            <td>{{ user.game_id }}</td>
-                            <td>{{ code.get_digest(user.id) }}</td>
-                        </tr>
-                        {%- endfor -%}
-                    </tbody>
-                </table>
-            </div>
-        </div>
-    </div>
+<h1>Codes</h1>
+<div class="table-responsive">
+    <table class="table table-striped table-sm">
+        <thead>
+            <tr>
+                <th>Name</th>
+                <th>Discord</th>
+                <th>Rival Regions</th>
+                <th>Code</th>
+            </tr>
+        </thead>
+        <tbody>
+            {% for user in users %}
+            <tr>
+                <td>{{ user.name }}</td>
+                <td>{{ user.discord }}</td>
+                <td><a href="{{ user.game_url() }}" target="_blank">{{ user.game_id }}</a></td>
+                <td>{{ code.get_digest(user.id) }}</td>
+            </tr>
+            {%- endfor -%}
+        </tbody>
+    </table>
 </div>
 </div>
 {% endblock %}
 {% endblock %}