Register form working now, but we need it inherited
@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class ApiConfig(AppConfig):
|
class Bloonsa_ApiConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'api'
|
name = 'bloonsa_api'
|
||||||
@ -1,6 +1,8 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from api.views import LoadLevel, RandomLevel, CompleteLevel, RateLevel
|
from bloonsa_api.views import LoadLevel, RandomLevel, CompleteLevel, RateLevel
|
||||||
|
|
||||||
|
app_name = "bloonsa_api"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("load_level", LoadLevel.as_view(), name="api-load_level"),
|
path("load_level", LoadLevel.as_view(), name="api-load_level"),
|
||||||
@ -9,7 +9,7 @@ import time
|
|||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
from game.models import Level
|
from bloonsa_game.models import Level
|
||||||
|
|
||||||
|
|
||||||
class CSRFexemptTemplateView(TemplateView):
|
class CSRFexemptTemplateView(TemplateView):
|
||||||
@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class GameConfig(AppConfig):
|
class Bloonsa_GameConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'game'
|
name = 'bloonsa_game'
|
||||||
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 137 B |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<meta name="title" content="Bloonsworld!"/>
|
<meta name="title" content="{% block title %}{% endblock title %}"/>
|
||||||
<meta name="robots" content="index, follow"/>
|
<meta name="robots" content="index, follow"/>
|
||||||
<meta name="description" content="Finally, the creators of Bloons bring you Bloonsworld!"/>
|
<meta name="description" content="Finally, the creators of Bloons bring you Bloonsworld!"/>
|
||||||
<meta name="keywords" content="flash, games, awesome"/>
|
<meta name="keywords" content="flash, games, awesome"/>
|
||||||
@ -12,31 +12,31 @@
|
|||||||
<!--[if IE6]>
|
<!--[if IE6]>
|
||||||
<style>
|
<style>
|
||||||
#wrapper {
|
#wrapper {
|
||||||
background: url({% static 'game/img/alpha.png' %});
|
background: url({% static 'bloonsa_game/img/alpha.png' %});
|
||||||
filter:alpha(opacity=75);
|
filter:alpha(opacity=75);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link rel="shortcut icon" href="{% static 'game/img/favicon.ico' %}"/>
|
<link rel="shortcut icon" href="{% static 'bloonsa_game/img/favicon.ico' %}"/>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="{% static 'game/css/main.css' %}"/>
|
<link rel="stylesheet" type="text/css" media="screen" href="{% static 'bloonsa_game/css/main.css' %}"/>
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="{% static 'game/css/append.css' %}"/>
|
<link rel="stylesheet" type="text/css" media="screen" href="{% static 'bloonsa_game/css/append.css' %}"/>
|
||||||
<script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script>
|
<script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script>
|
||||||
<script src="{% static 'game/misc/ruffle/ruffle.js' %}"></script>
|
<script src="{% static 'bloonsa_game/misc/ruffle/ruffle.js' %}"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="body">
|
<body id="body">
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="inner_wrapper">
|
<div id="inner_wrapper">
|
||||||
<div id="alpha"></div>
|
<div id="alpha"></div>
|
||||||
<a href="{% url 'index' %}" id="header"></a>
|
<a href="{% url 'bloonsa_game:index' %}" id="header"></a>
|
||||||
<div id="horizontal_header">
|
<div id="horizontal_header">
|
||||||
<div class="ad ad_720x90">
|
<div class="ad ad_720x90">
|
||||||
<div id="adslot1"></div>
|
<div id="adslot1"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="login_box">
|
<div id="login_box">
|
||||||
<form method="post" action="{% url 'login' %}"> <table>
|
<form method="post" action="{% url 'bloonsa_game:login' %}"> <table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="login_username">Name: </label></td>
|
<td><label for="login_username">Name: </label></td>
|
||||||
<td><input type="text" name="login_username" id="login_username" value=""/></td>
|
<td><input type="text" name="login_username" id="login_username" value=""/></td>
|
||||||
@ -53,7 +53,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table></form>
|
</table></form>
|
||||||
<h3><a href="/register">Register for free</a> <a href="/forgot_password">Forgot Password?</a></h3>
|
<h3><a href="/users/register">Register for free</a> <a href="/users/forgot_password">Forgot Password?</a></h3>
|
||||||
</div> </div>
|
</div> </div>
|
||||||
|
|
||||||
<div class="skyscraper">
|
<div class="skyscraper">
|
||||||
@ -67,20 +67,20 @@
|
|||||||
<div class="wide centered">
|
<div class="wide centered">
|
||||||
Copyright Kaiparasoft 2007, all rights reserved<br/>
|
Copyright Kaiparasoft 2007, all rights reserved<br/>
|
||||||
<a href="http://www.ninjakiwi.com">Ninjakiwi</a>
|
<a href="http://www.ninjakiwi.com">Ninjakiwi</a>
|
||||||
- <a href="{% url 'terms' %}">Terms of Use</a>
|
- <a href="{% url 'bloonsa_game:terms' %}">Terms of Use</a>
|
||||||
- <a href="{% url 'contact' %}">Contact Us</a> </div>
|
- <a href="{% url 'bloonsa_game:contact' %}">Contact Us</a> </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="skyscraper rhs">
|
<div class="skyscraper rhs">
|
||||||
<ul id="menu" class="light">
|
<ul id="menu" class="light">
|
||||||
|
|
||||||
<li><a href="/"><img src="{% static 'game/img/nav_home.gif' %}" alt="Nav_home"/></a></li>
|
<li><a href="/"><img src="{% static 'bloonsa_game/img/nav_home.gif' %}" alt="Nav_home"/></a></li>
|
||||||
<li><a href="/game"><img src="{% static 'game/img/nav_play.gif' %}" alt="Nav_play"/></a></li>
|
<li><a href="/game"><img src="{% static 'bloonsa_game/img/nav_play.gif' %}" alt="Nav_play"/></a></li>
|
||||||
<li><a href="/level_editor"><img src="{% static 'game/img/nav_build.gif' %}" alt="Nav_build"/></a></li>
|
<li><a href="/level_editor"><img src="{% static 'bloonsa_game/img/nav_build.gif' %}" alt="Nav_build"/></a></li>
|
||||||
<li><a href="/level/list"><img src="{% static 'game/img/nav_levels.gif' %}" alt="Nav_levels"/></a></li>
|
<li><a href="/level/list"><img src="{% static 'bloonsa_game/img/nav_levels.gif' %}" alt="Nav_levels"/></a></li>
|
||||||
<li><a href="/user/list"><img src="{% static 'game/img/nav_users.gif' %}" alt="Nav_users"/></a></li>
|
<li><a href="/user/list"><img src="{% static 'bloonsa_game/img/nav_users.gif' %}" alt="Nav_users"/></a></li>
|
||||||
<li><a href="http://www.ninjakiwi.com/"><img src="{% static 'game/img/nav_nk.gif' %}" alt="Nav_nk"/></a></li>
|
<li><a href="http://www.ninjakiwi.com/"><img src="{% static 'bloonsa_game/img/nav_nk.gif' %}" alt="Nav_nk"/></a></li>
|
||||||
<li><a href="http://ninjakiwi.com/Games/Tower-Defense/Bloons-Tower-Defense-5-Deluxe.html?predorder"><img src="{% static 'game/img/nav_buy.gif' %}" alt="Nav_buy"/></a></li>
|
<li><a href="http://ninjakiwi.com/Games/Tower-Defense/Bloons-Tower-Defense-5-Deluxe.html?predorder"><img src="{% static 'bloonsa_game/img/nav_buy.gif' %}" alt="Nav_buy"/></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="searchbox">
|
<div id="searchbox">
|
||||||
<form method="post" action="/level/list">
|
<form method="post" action="/level/list">
|
||||||
@ -1,12 +1,17 @@
|
|||||||
{% extends 'game/base.html' %}
|
{% extends 'bloonsa_game/base.html' %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ levelTitle }} by {{ levelAuthor }}
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
||||||
codebase="{% static 'game/misc/swflash.cab' %}#version=7,0,19,0"
|
codebase="{% static 'bloonsa_game/misc/swflash.cab' %}#version=7,0,19,0"
|
||||||
width="640" height="480" title="">
|
width="640" height="480" title="">
|
||||||
<param name="movie" value="{% static 'game/misc/bloons_unlimited.swf' %}">
|
<param name="movie" value="{% static 'bloonsa_game/misc/bloons_unlimited.swf' %}">
|
||||||
<param name="quality" value="high">
|
<param name="quality" value="high">
|
||||||
<embed src="{% static 'game/misc/bloons_unlimited.swf' %}"
|
<embed src="{% static 'bloonsa_game/misc/bloons_unlimited.swf' %}"
|
||||||
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
|
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
|
||||||
type="application/x-shockwave-flash"
|
type="application/x-shockwave-flash"
|
||||||
width="640" height="480">
|
width="640" height="480">
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends 'game/base.html' %}
|
{% extends 'bloonsa_game/base.html' %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -11,18 +11,18 @@
|
|||||||
If you like Bloons, you will LOVE THIS GAME.<br>
|
If you like Bloons, you will LOVE THIS GAME.<br>
|
||||||
Get Driller Bunny now for iPhone or iPod Touch.<br>
|
Get Driller Bunny now for iPhone or iPod Touch.<br>
|
||||||
<a href="http://newgam.es/drillbunny">
|
<a href="http://newgam.es/drillbunny">
|
||||||
<img src="{% static 'game/img/driller-bunny-300x250.jpg' %}"
|
<img src="{% static 'bloonsa_game/img/driller-bunny-300x250.jpg' %}"
|
||||||
alt="Driller Bunny"/></a><br>
|
alt="Driller Bunny"/></a><br>
|
||||||
</div>
|
</div>
|
||||||
<div class=" wide light">
|
<div class=" wide light">
|
||||||
<h2 class="centered">Welcome to Bloonsworld!</h2>
|
<h2 class="centered">Welcome to Bloonsworld!</h2>
|
||||||
<p class="centered"></p>
|
<p class="centered"></p>
|
||||||
<a class="homepage_button" href="{% url 'game' %}">
|
<a class="homepage_button" href="{% url 'game' %}">
|
||||||
<img src="{% static 'game/img/top_playnow.gif' %}"
|
<img src="{% static 'bloonsa_game/img/top_playnow.gif' %}"
|
||||||
alt="Top_playnow"/></a>
|
alt="Top_playnow"/></a>
|
||||||
<a class="homepage_button"
|
<a class="homepage_button"
|
||||||
href="/web/20140115060749/http://bloonsworld.com/level_editor">
|
href="/web/20140115060749/http://bloonsworld.com/level_editor">
|
||||||
<img src="{% static 'game/img/top_build.gif' %}"
|
<img src="{% static 'bloonsa_game/img/top_build.gif' %}"
|
||||||
alt="Top_build"/></a>
|
alt="Top_build"/></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends 'game/base.html' %}
|
{% extends 'bloonsa_game/base.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div class="wide">
|
<div class="wide">
|
||||||
@ -1,6 +1,8 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from game.views import IndexView, TermsView, GameView, WIPView
|
from bloonsa_game.views import IndexView, TermsView, GameView, WIPView
|
||||||
|
|
||||||
|
app_name = "bloonsa_game"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", IndexView.as_view(), name="index"),
|
path("", IndexView.as_view(), name="index"),
|
||||||
@ -2,18 +2,18 @@ from django.shortcuts import render
|
|||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
from game.models import Level
|
from bloonsa_game.models import Level
|
||||||
|
|
||||||
|
|
||||||
class IndexView(TemplateView):
|
class IndexView(TemplateView):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return render(request, "game/index.html", context={})
|
return render(request, "bloonsa_game/index.html", context={})
|
||||||
|
|
||||||
class TermsView(TemplateView):
|
class TermsView(TemplateView):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return render(request, "game/terms.html", context={})
|
return render(request, "bloonsa_game/terms.html", context={})
|
||||||
|
|
||||||
class GameView(TemplateView):
|
class GameView(TemplateView):
|
||||||
|
|
||||||
@ -21,16 +21,18 @@ class GameView(TemplateView):
|
|||||||
if type(kwargs.get("pk")) is int:
|
if type(kwargs.get("pk")) is int:
|
||||||
level = Level.objects.get(id=kwargs["pk"])
|
level = Level.objects.get(id=kwargs["pk"])
|
||||||
if level:
|
if level:
|
||||||
return render(request, "game/level.html", context={
|
return render(request, "bloonsa_game/level.html", context={
|
||||||
"flashVars": level.getFlashVars(seperator="&")
|
"flashVars": level.getFlashVars(seperator="&"),
|
||||||
|
"levelTitle": level.title,
|
||||||
|
"levelAuthor": level.author,
|
||||||
})
|
})
|
||||||
|
|
||||||
return render(request, "game/game.html", context={})
|
return render(request, "bloonsa_game/game.html", context={})
|
||||||
|
|
||||||
class WIPView(TemplateView):
|
class WIPView(TemplateView):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return render(request, "game/error.html", context={})
|
return render(request, "bloonsa_game/error.html", context={})
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
return render(request, "game/error.html", context={})
|
return render(request, "bloonsa_game/error.html", context={})
|
||||||
@ -38,9 +38,14 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
# Walter
|
# Global
|
||||||
"game",
|
"users",
|
||||||
"api",
|
|
||||||
|
# Bloons archive
|
||||||
|
"bloonsa_game",
|
||||||
|
"bloonsa_api",
|
||||||
|
|
||||||
|
# Bloons builder
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@ -18,6 +18,7 @@ from django.urls import path, include
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path("web_service/", include("api.urls")),
|
path("web_service/", include("bloonsa_api.urls", namespace="bloonsa_api")),
|
||||||
path("", include("game.urls")),
|
path("a/", include("bloonsa_game.urls", namespace="bloonsa_game")),
|
||||||
|
path("users/", include("users.urls", namespace="users"))
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class PlayersConfig(AppConfig):
|
class UsersConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'players'
|
name = 'users'
|
||||||
|
|||||||
33
app/users/forms.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
|
||||||
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from users.validators import usernameValidator
|
||||||
|
|
||||||
|
class UserRegisterForm(UserCreationForm):
|
||||||
|
field_order = ("username", "password1", "password2")
|
||||||
|
|
||||||
|
username = forms.CharField(min_length=3,
|
||||||
|
max_length=16,
|
||||||
|
label="Username",
|
||||||
|
required=True,
|
||||||
|
validators=[usernameValidator],
|
||||||
|
help_text="3-16 chars, alphanumeric and _- pls")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = [
|
||||||
|
"username",
|
||||||
|
"password1",
|
||||||
|
"password2",
|
||||||
|
]
|
||||||
|
|
||||||
|
class UserLoginForm(AuthenticationForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(UserLoginForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
username = forms.CharField(min_length=3,
|
||||||
|
max_length=16,
|
||||||
|
label="Username",
|
||||||
|
required=True,
|
||||||
|
validators=[usernameValidator])
|
||||||
@ -2,17 +2,15 @@ from django.db import models
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from game.models import Level
|
from bloonsa_game.models import Level
|
||||||
|
|
||||||
class CustomUser(User):
|
|
||||||
...
|
|
||||||
|
|
||||||
class Player(models.Model):
|
class Player(models.Model):
|
||||||
user = models.ForeignKey(CustomUser, on_delete=models.CASCADE, null=True, blank=True)
|
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
||||||
# Savedata
|
# Savedata
|
||||||
levelsPlayed = models.ManyToManyField(Level, blank=True)
|
levelsPlayed = models.ManyToManyField(Level, blank=True, related_name="levelsPlayed")
|
||||||
levelsBeaten = models.ManyToManyField(Level, blank=True)
|
levelsBeaten = models.ManyToManyField(Level, blank=True, related_name="levelsBeaten")
|
||||||
levelsRated = ...
|
# levelsRated = ...
|
||||||
# Logging
|
# Logging
|
||||||
creationIP = models.GenericIPAddressField()
|
creationIP = models.GenericIPAddressField()
|
||||||
latestIP = models.GenericIPAddressField()
|
latestIP = models.GenericIPAddressField()
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
{% extends "game/base.html" %}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
{% extends "game/base.html" %}
|
|
||||||
1
app/users/templates/users/login.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
{% extends "bloonsa_game/base.html" %}
|
||||||
14
app/users/templates/users/register.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends "bloonsa_game/base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Register
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Register!</h1>
|
||||||
|
<form class="form-with-validation" action="/users/register" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
<button class="form-submit">Create</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
10
app/users/urls.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
|
from users.views import LoginView, RegisterView
|
||||||
|
|
||||||
|
app_name = "users"
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("login", LoginView.as_view(), name="login"),
|
||||||
|
path("register", RegisterView.as_view(), name="register"),
|
||||||
|
]
|
||||||
@ -1,7 +1,17 @@
|
|||||||
|
import string
|
||||||
|
|
||||||
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from users.models import User, Player
|
from users.models import Player
|
||||||
|
|
||||||
def usernameValidator(username):
|
def usernameValidator(username):
|
||||||
if User.objects.filter(username__iexact=username).first() is not None:
|
if User.objects.filter(username__iexact=username).first() is not None:
|
||||||
raise ValidationError("Sorry, deze gebruikersnaam is al in gebruik")
|
raise ValidationError("Sorry, this username is already in use")
|
||||||
|
|
||||||
|
if 3 < len(username) < 17:
|
||||||
|
raise ValidationError("Username must be between 3-16 characters long")
|
||||||
|
|
||||||
|
charset = set(string.ascii_letters + string.digits + "_-")
|
||||||
|
if not all(x in charset for x in username):
|
||||||
|
raise ValidationError("Username may only contain normal letters, numbers and _-")
|
||||||
@ -1,10 +1,33 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.shortcuts import render, redirect
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
from users.forms import UserRegisterForm
|
||||||
|
|
||||||
|
|
||||||
|
class LoginView(TemplateView):
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
...
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
class
|
class RegisterView(TemplateView):
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
form = UserCreationForm()
|
||||||
|
return render(request=request, template_name="users/register.html", context={"form": form})
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
form = UserCreationForm(request.POST)
|
||||||
|
if not form.is_valid():
|
||||||
|
print("form invalid", form.error_messages, request.POST)
|
||||||
|
return render(request=request, template_name="users/register.html", context={"form": form})
|
||||||
|
# form.save()
|
||||||
|
return redirect("bloonsa_game:game")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||