This commit is contained in:
Niko Abeler 2023-06-22 20:35:43 +02:00
parent d4415445f3
commit d7dbc437fa
5 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Register">
</form>
{% endblock content %}

View File

@ -18,7 +18,7 @@ urlpatterns = [
), ),
name="logout", name="logout",
), ),
# path("players/", views.PlayerListView.as_view(), name="player_list"), path("accounts/register/", views.RegisterView.as_view(), name="register"),
path( path(
"players/create/", player_views.CreatePlayerView.as_view(), name="create_player" "players/create/", player_views.CreatePlayerView.as_view(), name="create_player"
), ),

View File

@ -1,8 +1,10 @@
from datetime import date from datetime import date
from django.urls import reverse
from django.views.generic import TemplateView, ListView, DetailView from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from guild.models import Adventure, Character, Player, Reward from guild.models import Adventure, Character, Player, Reward
@ -31,3 +33,11 @@ class HomeView(LoginRequiredMixin, TemplateView):
context["resources"][reward.resource.name] = 0 context["resources"][reward.resource.name] = 0
context["resources"][reward.resource.name] += reward.amount context["resources"][reward.resource.name] += reward.amount
return context return context
class RegisterView(CreateView):
model = User
form_class = UserCreationForm
def get_success_url(self):
return reverse("guild:login")

View File

@ -76,6 +76,9 @@
<li class="navigation-item"> <li class="navigation-item">
<a href="{% url 'guild:login' %}">Login</a> <a href="{% url 'guild:login' %}">Login</a>
</li> </li>
<li class="navigation-item">
<a href="{% url 'guild:register' %}">Register</a>
</li>
{% endif %} {% endif %}
</ul> </ul>

View File

@ -19,6 +19,7 @@
{% csrf_token %} {% csrf_token %}
{{form}} {{form}}
<input type="submit" value="login"> <input type="submit" value="login">
<a style="margin-left:4rem;" href="{% url 'guild:register' %}">Register</a>
<input type="hidden" name="next" value="{{ next }}"> <input type="hidden" name="next" value="{{ next }}">
</form> </form>