Minor tweaks to templates, permissions fix

This commit is contained in:
root 2019-11-27 12:44:54 +01:00
parent a54ec52f52
commit c61adb84e2
4 changed files with 12 additions and 10 deletions

View File

@ -162,11 +162,14 @@ class NewGameView(views.LoginRequiredMixin, View):
) )
class RoundView(views.LoginRequiredMixin, UpdateView): class RoundView(views.UserPassesTestMixin, UpdateView):
model = GameRound model = GameRound
form_class = GuessForm form_class = GuessForm
template_name = 'main/round.html' template_name = 'main/round.html'
def test_func(self, *args, **kwargs):
return self.request.user == get_object_or_404(Game, pk=self.kwargs.get('game_pk', 0)).user
def get_object(self): def get_object(self):
round_id = self.kwargs.get('round_pk', 0) round_id = self.kwargs.get('round_pk', 0)
return get_object_or_404(GameRound, pk=round_id) return get_object_or_404(GameRound, pk=round_id)

View File

@ -11,7 +11,9 @@
<link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/> <link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/>
<title>Geogame</title> <title>Geogame</title>
</head> </head>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<body> <body>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<img id="logo" src="{% static 'brand.png' %}"></img> <img id="logo" src="{% static 'brand.png' %}"></img>
@ -21,11 +23,11 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item {% if request.path == "/" %} active {% endif %}"> <li class="nav-item {% if request.resolver_match.url_name == 'home' %} active {% endif %}">
<a href="{% url 'home' %}" class="nav-link">Home</a> <a href="{% url 'home' %}" class="nav-link">Home</a>
</li> </li>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<li class="nav-item"> <li class="nav-item {% if request.resolver_match.url_name == 'profile' %} active {% endif %}">
<a href="{% url 'profile' %}" class="nav-link">Profile</a> <a href="{% url 'profile' %}" class="nav-link">Profile</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
@ -50,8 +52,4 @@
{% endif %} {% endif %}
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body> </body>

View File

@ -1,4 +1,4 @@
{% extends 'base.html' %} {% extends 'game_base.html' %}
{% load staticfiles%} {% load staticfiles%}
{% block content %} {% block content %}

View File

@ -36,7 +36,8 @@
You must be logged in to play the game. Please read the FAQ for more info. You must be logged in to play the game. Please read the FAQ for more info.
</div> </div>
<button type="button" class="btn btn-info btn-lg btn-block" disabled>Continue Last Game</button> <button type="button" class="btn btn-info btn-lg btn-block" disabled>Continue Last Game</button>
<button type="button" class="btn btn-success btn-lg btn-block" disabled>New Game</button> <button type="button" class="btn btn-success btn-lg btn-block" disabled>New Random Game</button>
<button type="button" class="btn btn-warning btn-lg btn-block" disabled>View Challenges</button>
{% endif %} {% endif %}
</div> </div>
</div> </div>