Skip to content
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
5 changes: 4 additions & 1 deletion dudel.wsgi
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env python2
import sys, os, datetime

path = os.path.dirname(os.path.abspath(__file__))
# this file might be symlinked somewhere (e.g. apache2 needs .wsgi files
# in an accessible location like webroot), so we need to find the actual
# path for the rest of the code
path = os.path.dirname(os.path.realpath(__file__))

# Activate the virtual environment to load the library.
# TODO: change this if your virtual environment is not located at ./env
Expand Down
4 changes: 2 additions & 2 deletions dudel/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class User(Member):
id = db.Column(db.Integer, db.ForeignKey("member.id"), primary_key=True)
firstname = db.Column(db.String(80))
lastname = db.Column(db.String(80))
username = db.Column(db.String(80))
username = db.Column(db.String(80), unique=True)
password = db.Column(db.LargeBinary)
_displayname = db.Column(db.String(80))
email = db.Column(db.String(80))
email = db.Column(db.String(80), unique=True)
preferred_language = db.Column(db.String(80))
autowatch = db.Column(db.Boolean, default=False)
allow_invitation_mails = db.Column(db.Boolean, default=True)
Expand Down
3 changes: 3 additions & 0 deletions dudel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def register():
if form.validate_on_submit():
user = User()
form.populate_obj(user)
if get_user(user.username):
flash(gettext("Username already taken, sorry"), "error")
return redirect(url_for("register"))
user.set_password(form.password1.data)
db.session.add(user)
db.session.commit()
Expand Down
2 changes: 2 additions & 0 deletions migrations/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# the 'revision' command, regardless of autogenerate
# revision_environment = false

script_location = migrations


# Logging configuration
[loggers]
Expand Down
24 changes: 24 additions & 0 deletions migrations/versions/cd6add3ec469_add_some_unique_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""add some unique constraints

Revision ID: cd6add3ec469
Revises: 250e3d22d78e
Create Date: 2017-08-16 17:03:55.180080

"""

# revision identifiers, used by Alembic.
revision = 'cd6add3ec469'
down_revision = '250e3d22d78e'

from alembic import op
import sqlalchemy as sa


def upgrade():
op.create_unique_constraint("unique_user_name", "user",
["username"])
op.create_unique_constraint("unique_user_email", "user", ["email"])

def downgrade():
op.drop_constraint("unique_user_name")
op.drop_constraint("unique_user_email")