-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jackson Chadfield
committed
Jul 31, 2019
1 parent
a5d28e5
commit c394fb9
Showing
7 changed files
with
192 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,78 @@ | ||
{% extends "./layout.html" %} | ||
{% extends "./layout.html" %} | ||
|
||
{% set footer_color = "blue" %} | ||
|
||
{% block styles %} | ||
{{ super() }} | ||
<style> | ||
html, body { | ||
height: 100%; | ||
width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
{# I know. *sigh* #} /**/ | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
main { | ||
flex-grow: 2; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
#form-section { | ||
flex-grow: 2; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
#room-code-input, #form-container { | ||
max-width: 450px; | ||
width: 100%; | ||
margin: 0; | ||
} | ||
|
||
.siimple-footer-link { | ||
color: white; | ||
} | ||
|
||
.siimple-footer-link:hover { | ||
color: rgba(255, 255, 255, 0.4) !important; | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block main %} | ||
<div class="siimple-content--fluid siimple--bg-primary siimple--py-5" id="form-section"> | ||
<div id="form-container" class="siimple--display-inline-flex"> | ||
<div class="siimple-form siimple--bg-light siimple--py-5 siimple--px-5 siimple--rounded" | ||
id="room-code-form"> | ||
<div class="siimple-form-title">Sign In</div> | ||
<div class="siimple-form-detail">Don't have an account? <a href="{{ url_for("public.register") }}" | ||
class="siimple-link">Register Here</a></div> | ||
<div class="siimple-form-field"> | ||
{{ form.username.label(class_="siimple-form-field-label") }} | ||
{{ form.username(class_="siimple-input siimple-input--fluid siimple--bg-primary siimple--color-white", maxlength=25) }} | ||
</div> | ||
<div class="siimple-form-field"> | ||
{{ form.password.label(class_="siimple-form-field-label") }} | ||
{{ form.password(class_="siimple-input siimple-input--fluid siimple--bg-primary siimple--color-white") }} | ||
</div> | ||
<div class="siimple-form-field"> | ||
<input type="submit" | ||
class="siimple-btn siimple-btn--success siimple-btn--big siimple-btn--fluid" | ||
value="Sign In"/> | ||
</div> | ||
<div id="room-code-status" | ||
class="siimple-alert siimple-alert--error{% if form.errors|length == 0 %} siimple--display-none{% endif %}"> | ||
{{ form.errors.values()|first|first }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
from flask_wtf import FlaskForm | ||
from wtforms import StringField, PasswordField | ||
from wtforms.validators import Length, EqualTo, InputRequired | ||
|
||
|
||
class LoginForm(FlaskForm): | ||
username = StringField("Username", validators=[ | ||
InputRequired(message="You must enter your username"), | ||
Length(min=3, max=25, message="Username does not exist") | ||
]) | ||
password = PasswordField("Password", validators=[ | ||
InputRequired(message="You must enter your username") | ||
]) | ||
|
||
|
||
class RegisterForm(FlaskForm): | ||
username = StringField("Username", validators=[ | ||
InputRequired(), | ||
Length(min=3, max=25, message="Username must be between 3-25 characters") | ||
]) | ||
password = PasswordField("Password", validators=[ | ||
InputRequired(message="You must provide a password"), | ||
Length(min=6, message="Password must be at least 6 characters") | ||
]) | ||
confirm_password = PasswordField("Repeat Password", validators=[ | ||
EqualTo('password', message="Passwords must match") | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
from typing import Optional | ||
|
||
from flask_wtf import FlaskForm | ||
from wtforms import StringField | ||
from wtforms.validators import InputRequired, Length, Regexp | ||
|
||
from OpenLearn.database import Room | ||
|
||
|
||
class JoinRoomForm(FlaskForm): | ||
room_code = StringField("Room Code", validators=[ | ||
InputRequired(message="Malformed Room Code"), | ||
Length(min=9, max=9, message="Malformed Room Code"), | ||
Regexp("([A-Z0-9]){4}-([A-Z0-9]){4}", message="Malformed Room Code") | ||
]) | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Create instance.""" | ||
super().__init__(*args, **kwargs) | ||
self.room: Optional[Room] = None | ||
|
||
def validate(self): | ||
initial_validation = super().validate() | ||
if not initial_validation: | ||
return False | ||
|
||
# TODO: Room Logic | ||
self.room_code.errors.append("Invalid Code") | ||
return False |