Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask: Update Flask, use Poetry #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flask/notejam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.mail import Mail
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_mail import Mail
from notejam.config import (
Config,
DevelopmentConfig,
Expand All @@ -17,6 +17,7 @@
# @TODO use application factory approach
app = Flask(__name__)
app.config.from_object(from_env[os.environ.get('ENVIRONMENT', 'testing')])
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)


Expand Down
30 changes: 15 additions & 15 deletions flask/notejam/forms.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from flask.ext.wtf import (Form, TextField, PasswordField,
SelectField, TextAreaField)
from flask.ext.wtf import Required, Email, EqualTo, ValidationError
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SelectField, TextAreaField
from wtforms.validators import Required, Email, EqualTo, ValidationError

from notejam.models import User, Pad


class SigninForm(Form):
email = TextField('Email', validators=[Required(), Email()])
class SigninForm(FlaskForm):
email = StringField('Email', validators=[Required(), Email()])
password = PasswordField('Password', validators=[Required()])


class SignupForm(Form):
email = TextField('Email', validators=[Required(), Email()])
class SignupForm(FlaskForm):
email = StringField('Email', validators=[Required(), Email()])
password = PasswordField('Password', validators=[Required()])
repeat_password = PasswordField(
'Repeat Password',
Expand All @@ -29,8 +29,8 @@ def validate_email(self, field):
)


class NoteForm(Form):
name = TextField('Name', validators=[Required()])
class NoteForm(FlaskForm):
name = StringField('Name', validators=[Required()])
text = TextAreaField('Note', validators=[Required()])
pad = SelectField('Pad', choices=[], coerce=int)

Expand All @@ -42,16 +42,16 @@ def __init__(self, user=None, **kwargs):
]


class PadForm(Form):
name = TextField('Name', validators=[Required()])
class PadForm(FlaskForm):
name = StringField('Name', validators=[Required()])


# dummy form
class DeleteForm(Form):
class DeleteForm(FlaskForm):
pass


class ChangePasswordForm(Form):
class ChangePasswordForm(FlaskForm):
old_password = PasswordField('Old Password', validators=[Required()])
new_password = PasswordField('New Password', validators=[Required()])
repeat_new_password = PasswordField(
Expand All @@ -74,8 +74,8 @@ def validate_old_password(self, field):
)


class ForgotPasswordForm(Form):
email = TextField('Email', validators=[Required(), Email()])
class ForgotPasswordForm(FlaskForm):
email = StringField('Email', validators=[Required(), Email()])

def validate_email(self, field):
if not User.query.filter_by(email=field.data).count():
Expand Down
2 changes: 1 addition & 1 deletion flask/notejam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from werkzeug.security import (generate_password_hash,
check_password_hash)
from flask.ext.login import UserMixin
from flask_login import UserMixin

from notejam import db

Expand Down
2 changes: 1 addition & 1 deletion flask/notejam/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="container">
<div class="sixteen columns">
<div class="sign-in-out-block">
{% if current_user.is_authenticated() %}
{% if current_user.is_authenticated %}
{{ current_user.email}}:&nbsp; <a href="{{ url_for('account_settings') }}">Account settings</a>&nbsp;&nbsp;&nbsp;<a href="{{ url_for('signout') }}">Sign out</a>
{% else %}
<a href="{{ url_for('signup') }}">Sign up</a>&nbsp;&nbsp;&nbsp;<a href="{{ url_for('signin') }}">Sign in</a>
Expand Down
9 changes: 4 additions & 5 deletions flask/notejam/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import date
import md5
from hashlib import md5

from flask import render_template, flash, request, redirect, url_for, abort
from flask.ext.login import (login_user, login_required, logout_user,
current_user)
from flask.ext.mail import Message
from flask_login import (login_user, login_required, logout_user, current_user)
from flask_mail import Message

from notejam import app, db, login_manager, mail
from notejam.models import User, Note, Pad
Expand Down Expand Up @@ -211,7 +210,7 @@ def forgot_password():
@app.context_processor
def inject_user_pads():
''' inject list of user pads in template context '''
if not current_user.is_anonymous():
if not current_user.is_anonymous:
return dict(pads=current_user.pads.all())
return dict(pads=[])

Expand Down
Loading