Register form working now, but we need it inherited

This commit is contained in:
Walter 2025-02-07 04:03:23 +01:00
parent 5d835e9c60
commit 5f149f76b4
72 changed files with 168 additions and 62 deletions

View File

@ -1,6 +1,6 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
class Bloonsa_ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
name = 'bloonsa_api'

View File

@ -1,6 +1,8 @@
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 = [
path("load_level", LoadLevel.as_view(), name="api-load_level"),

View File

@ -9,7 +9,7 @@ import time
# Create your views here.
from game.models import Level
from bloonsa_game.models import Level
class CSRFexemptTemplateView(TemplateView):

View File

@ -1,6 +1,6 @@
from django.apps import AppConfig
class GameConfig(AppConfig):
class Bloonsa_GameConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'game'
name = 'bloonsa_game'

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -2,7 +2,7 @@
<!DOCTYPE html>
<head>
<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="description" content="Finally, the creators of Bloons bring you Bloonsworld!"/>
<meta name="keywords" content="flash, games, awesome"/>
@ -12,31 +12,31 @@
<!--[if IE6]>
<style>
#wrapper {
background: url({% static 'game/img/alpha.png' %});
background: url({% static 'bloonsa_game/img/alpha.png' %});
filter:alpha(opacity=75);
}
</style>
<![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 'game/css/append.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 'bloonsa_game/css/append.css' %}"/>
<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>
<body id="body">
<div id="wrapper">
<div id="inner_wrapper">
<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 class="ad ad_720x90">
<div id="adslot1"></div>
</div>
<div id="login_box">
<form method="post" action="{% url 'login' %}"> <table>
<form method="post" action="{% url 'bloonsa_game:login' %}"> <table>
<tr>
<td><label for="login_username">Name: </label></td>
<td><input type="text" name="login_username" id="login_username" value=""/></td>
@ -53,7 +53,7 @@
</tr>
</table></form>
<h3><a href="/register">Register for free</a>&nbsp;&nbsp;<a href="/forgot_password">Forgot Password?</a></h3>
<h3><a href="/users/register">Register for free</a>&nbsp;&nbsp;<a href="/users/forgot_password">Forgot Password?</a></h3>
</div> </div>
<div class="skyscraper">
@ -67,20 +67,20 @@
<div class="wide centered">
Copyright Kaiparasoft 2007, all rights reserved<br/>
<a href="http://www.ninjakiwi.com">Ninjakiwi</a>
- <a href="{% url 'terms' %}">Terms of Use</a>
- <a href="{% url 'contact' %}">Contact Us</a> </div>
- <a href="{% url 'bloonsa_game:terms' %}">Terms of Use</a>
- <a href="{% url 'bloonsa_game:contact' %}">Contact Us</a> </div>
</div>
<div class="skyscraper rhs">
<ul id="menu" class="light">
<li><a href="/"><img src="{% static '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="/level_editor"><img src="{% static '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="/user/list"><img src="{% static '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://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="/"><img src="{% static 'bloonsa_game/img/nav_home.gif' %}" alt="Nav_home"/></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 'bloonsa_game/img/nav_build.gif' %}" alt="Nav_build"/></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 'bloonsa_game/img/nav_users.gif' %}" alt="Nav_users"/></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 'bloonsa_game/img/nav_buy.gif' %}" alt="Nav_buy"/></a></li>
</ul>
<div id="searchbox">
<form method="post" action="/level/list">

View File

@ -1,12 +1,17 @@
{% extends 'game/base.html' %}
{% extends 'bloonsa_game/base.html' %}
{% load static %}
{% block title %}
{{ levelTitle }} by {{ levelAuthor }}
{% endblock title %}
{% block content %}
<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="">
<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">
<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"
type="application/x-shockwave-flash"
width="640" height="480">

View File

@ -1,4 +1,4 @@
{% extends 'game/base.html' %}
{% extends 'bloonsa_game/base.html' %}
{% load static %}
{% block content %}
@ -11,18 +11,18 @@
If you like Bloons, you will LOVE THIS GAME.<br>
Get Driller Bunny now for iPhone or iPod Touch.<br>
<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>
</div>
<div class=" wide light">
<h2 class="centered">Welcome to Bloonsworld!</h2>
<p class="centered"></p>
<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>
<a class="homepage_button"
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>
</div>
<div class="left">

View File

@ -1,4 +1,4 @@
{% extends 'game/base.html' %}
{% extends 'bloonsa_game/base.html' %}
{% block content %}
<div id="content">
<div class="wide">

View File

@ -1,6 +1,8 @@
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 = [
path("", IndexView.as_view(), name="index"),

View File

@ -2,18 +2,18 @@ from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
from game.models import Level
from bloonsa_game.models import Level
class IndexView(TemplateView):
def get(self, request, *args, **kwargs):
return render(request, "game/index.html", context={})
return render(request, "bloonsa_game/index.html", context={})
class TermsView(TemplateView):
def get(self, request, *args, **kwargs):
return render(request, "game/terms.html", context={})
return render(request, "bloonsa_game/terms.html", context={})
class GameView(TemplateView):
@ -21,16 +21,18 @@ class GameView(TemplateView):
if type(kwargs.get("pk")) is int:
level = Level.objects.get(id=kwargs["pk"])
if level:
return render(request, "game/level.html", context={
"flashVars": level.getFlashVars(seperator="&amp;")
return render(request, "bloonsa_game/level.html", context={
"flashVars": level.getFlashVars(seperator="&amp;"),
"levelTitle": level.title,
"levelAuthor": level.author,
})
return render(request, "game/game.html", context={})
return render(request, "bloonsa_game/game.html", context={})
class WIPView(TemplateView):
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):
return render(request, "game/error.html", context={})
return render(request, "bloonsa_game/error.html", context={})

View File

@ -38,9 +38,14 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
# Walter
"game",
"api",
# Global
"users",
# Bloons archive
"bloonsa_game",
"bloonsa_api",
# Bloons builder
]
MIDDLEWARE = [

View File

@ -18,6 +18,7 @@ from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path("web_service/", include("api.urls")),
path("", include("game.urls")),
path("web_service/", include("bloonsa_api.urls", namespace="bloonsa_api")),
path("a/", include("bloonsa_game.urls", namespace="bloonsa_game")),
path("users/", include("users.urls", namespace="users"))
]

View File

@ -1,6 +1,6 @@
from django.apps import AppConfig
class PlayersConfig(AppConfig):
class UsersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'players'
name = 'users'

33
app/users/forms.py Normal file
View 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])

View File

@ -2,17 +2,15 @@ from django.db import models
from django.utils import timezone
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):
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
levelsPlayed = models.ManyToManyField(Level, blank=True)
levelsBeaten = models.ManyToManyField(Level, blank=True)
levelsRated = ...
levelsPlayed = models.ManyToManyField(Level, blank=True, related_name="levelsPlayed")
levelsBeaten = models.ManyToManyField(Level, blank=True, related_name="levelsBeaten")
# levelsRated = ...
# Logging
creationIP = models.GenericIPAddressField()
latestIP = models.GenericIPAddressField()

View File

@ -1 +0,0 @@
{% extends "game/base.html" %}

View File

@ -1 +0,0 @@
{% extends "game/base.html" %}

View File

@ -0,0 +1 @@
{% extends "bloonsa_game/base.html" %}

View 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
View 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"),
]

View File

@ -1,7 +1,17 @@
import string
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from users.models import User, Player
from users.models import Player
def usernameValidator(username):
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 _-")

View File

@ -1,10 +1,33 @@
from django.shortcuts import render
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")

2
readme.md Normal file
View File

@ -0,0 +1,2 @@
# Bloonsworld archive
yes finally.