-
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
Showing
19 changed files
with
250 additions
and
3 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
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,23 @@ | ||
from flask.ext.wtf import Form | ||
from wtforms import StringField, PasswordField, BooleanField, SubmitField, \ | ||
DateField, IntegerField | ||
from wtforms.validators import Required, Length, Regexp, EqualTo | ||
from wtforms import ValidationError | ||
from .models import Wizard | ||
|
||
|
||
class LoginForm(Form): | ||
wizard_name = StringField('Wizard Name', | ||
validators=[Required(), Length(1, 32)]) | ||
password = PasswordField('Password', validators=[Required(), | ||
Length(1, 32)]) | ||
|
||
def validate(self): | ||
if not Form.validate(self): | ||
return False | ||
user = Wizard.query.filter_by(wizard_name=self. | ||
wizard_name.data).first() | ||
if user is not None and not user.verify_password(self.password.data): | ||
self.password.errors.append('Incorrect password.') | ||
return False | ||
return True |
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,33 @@ | ||
from flask.ext.login import UserMixin | ||
from werkzeug.security import generate_password_hash, check_password_hash | ||
|
||
from . import db | ||
|
||
|
||
class Wizard(UserMixin, db.Model): | ||
""" | ||
Represents a wizard who can access special parts of the application. | ||
""" | ||
__tablename__ = 'wizards' | ||
id = db.Column(db.Integer, primary_key=True) | ||
wizard_name = db.Column(db.String(64), unique=True, index=True) | ||
password_hash = db.Column(db.String(128)) | ||
|
||
def __init__(self, wizard_name, password): | ||
self.wizard_name = wizard_name | ||
self.password = password | ||
|
||
@property | ||
def password(self): | ||
raise AttributeError('password is not readable') | ||
|
||
@password.setter | ||
def password(self, password): | ||
self.password_hash = generate_password_hash(password) | ||
|
||
def verify_password(self, password): | ||
return check_password_hash(self.password_hash, password) | ||
|
||
def __repr__(self): | ||
return '<Wizard %r>' % self.wizard_name | ||
|
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,48 @@ | ||
/* Sticky footer styles | ||
-------------------------------------------------- */ | ||
html { | ||
position: relative; | ||
min-height: 100%; | ||
} | ||
body { | ||
/* Margin bottom by footer height */ | ||
margin-bottom: 60px; | ||
} | ||
.footer { | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
/* Set the fixed height of the footer here */ | ||
height: 60px; | ||
background-color: rgba(0,0,0,0.3); | ||
} | ||
|
||
|
||
/* Custom page CSS | ||
-------------------------------------------------- */ | ||
/* Not required for template or sticky footer method. */ | ||
|
||
.container { | ||
width: auto; | ||
max-width: 680px; | ||
padding: 0 15px; | ||
} | ||
.container .text-muted { | ||
margin: 20px 0; | ||
} | ||
|
||
|
||
.wizard-bg { | ||
background: url("/static/img/magic.jpg") no-repeat center center fixed; | ||
-webkit-background-size: cover; | ||
background-size: cover; | ||
} | ||
|
||
.container.sign-in { | ||
background: rgba(0,0,0,0.8); | ||
border-radius: 5px; | ||
margin-top: 20px; | ||
padding-bottom: 20px; | ||
color: #fff; | ||
} | ||
|
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,7 @@ | ||
.btn-top-margin { | ||
margin-top: 25px; | ||
} | ||
.admin-field { | ||
text-align: left; | ||
margin-top: 15px; | ||
} |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content=""> | ||
<meta name="author" content="Matt Makai"> | ||
<title>{% block title %}{% endblock %}CYOA Presentations</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="/static/css/wizard.css"> | ||
{% block css_head %}{% endblock %} | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"> | ||
</script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"> | ||
</script> | ||
<![endif]--> | ||
</head> | ||
<body{% block body_class %}{% endblock %}> | ||
{% block nav %}{% endblock %} | ||
{% block content %}{% endblock %} | ||
{% block js_body %}{% endblock %} | ||
</body> | ||
</html> |
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,12 @@ | ||
{% macro render_field(field) %} | ||
<dt style="text-align: left;" class="admin-field">{{ field.label }} | ||
{% if field.errors %} | ||
<ul class="errors"> | ||
{% for error in field.errors %} | ||
<li style="color: red;">{{ error }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
<dd>{{ field(class_="form-control", **kwargs)|safe }} | ||
</dd> | ||
{% endmacro %} |
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,12 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-10"> | ||
<h1>Wizards Only Stuff Here</h1> | ||
<a href="{{ url_for('sign_out') }}">Sign out</a> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block css_head %} | ||
<link href="/static/css/signin.css" rel="stylesheet"> | ||
{% endblock %} | ||
|
||
{% block body_class %} class="wizard-bg" {% endblock %} | ||
|
||
{% block content %} | ||
<div class="container sign-in"> | ||
<div class="col-md-12"> | ||
<div id="login"> | ||
<h1>Wizards Only!</h1> | ||
{% from "partials/_formhelpers.html" import render_field %} | ||
<form method="post" action="{{ url_for('sign_in') }}" | ||
id="login-form"> | ||
{{ form.csrf_token }} | ||
{{ render_field(form.wizard_name, required=True) }} | ||
<br> | ||
{{ render_field(form.password, required=True) }} | ||
<div style="margin-top: 10px; text-align: right;"> | ||
<input class="btn btn-primary" | ||
type="submit" value="Sign in" /> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
<footer class="footer"> | ||
<div class="container"> | ||
<p class="text-muted pull-right"> | ||
Photo by <a href="http://photos.jdhancock.com/photo/2012-04-16-000233-a-spot-of-magic.html">JD Hancock</a> | ||
</p> | ||
</div> | ||
</footer> | ||
{% 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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
Flask==0.10.1 | ||
Flask-Script==2.0.5 | ||
Flask-SocketIO==0.4.1 | ||
Flask-Login==0.2.11 | ||
Flask-SQLAlchemy==2.0 | ||
Flask-WTF==0.10.3 | ||
|
||
gunicorn==19.1.1 | ||
|
||
redis==2.10.3 | ||
|
||
twilio==3.6.8 | ||
|
||
psycopg2==2.5.4 |