Commit 2bf1b7d2 authored by colmoneill's avatar colmoneill

a demo of writing to the db when route is accessed

parent fc8bea5f
......@@ -3,7 +3,7 @@ from flask_flatpages import FlatPages
import markdown
import os
import glob
from flask_mongoengine import MongoEngine
from flask_mongoengine import *
from flask_security import Security, MongoEngineUserDatastore, UserMixin, RoleMixin, login_required, current_user
from flask_mail import Mail
......@@ -110,6 +110,7 @@ class User(db.Document, UserMixin):
confirmed_at = db.DateTimeField()
roles = db.ListField(db.ReferenceField(Role), default=[])
badge = db.BooleanField(default=True)
login_count = db.StringField(max_length=3)
# Setup Flask-Security
user_datastore = MongoEngineUserDatastore(db, User, Role)
......@@ -126,7 +127,9 @@ security = Security(app, user_datastore)
@login_required
def dashboard():
user = current_user.get_id()
print(current_user.get_id())
#user = str(user)
print('user: ' + user)
db_user = User.objects.get(id=user).update(icr__login_count=1, upsert=True)
message = 'Welcome to your dashboard ' + current_user.get_id()
flash(message)
return render_template('dashboard.html', user=user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment