Commit a6357faf authored by colmoneill's avatar colmoneill

closes #6

parent 03393ec7
......@@ -4,6 +4,7 @@ content/images/illus-julie-17-18
content/images/shows
*.css.map
package-lock.json
settings.py
##################
# Python ignores #
......
......@@ -12,19 +12,14 @@ from flask_mail import Message
from flask_security.forms import RegisterForm, StringField
from wtforms.validators import DataRequired
import urllib.request as ur
import os
import glob
import copy
import json
import random
import urllib
import math
import os, glob, copy, json, random, urllib, math
from bson import ObjectId
from flask_admin import Admin
from flask_admin.form import rules
from flask_admin.contrib.mongoengine import ModelView, filters
from flask_admin.model.fields import InlineFormField, InlineFieldList
from settings import *
from flask_babelex import Babel, gettext
......@@ -35,7 +30,6 @@ LANGUAGES = {
}
# EVENTBRITE API
eventIdList = ['47017085368', '48022466490']
eventbrite_url_requete = "https://www.eventbriteapi.com/v3/events/search/?q=fablab&expand=organizer&token=AYO4PV2UJHXEBOLGXG74"
......@@ -86,37 +80,30 @@ def inject_conf_var():
request.accept_languages.best_match(app.config['LANGUAGES'].keys())))
# Flask Security settings
app.config['SECRET_KEY'] = 'super-secret'
app.config['SECRET_KEY'] = secret_key
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_CHANGEABLE'] = True
# app.config['SECURITY_TRACKABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = '$2a$16$PnnIgfMwkOjGX4SkHqSOPO'
app.config['MAIL_SERVER'] = 'mail.gandi.net'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'automatic@colm.be'
app.config['MAIL_PASSWORD'] = 'testing#123'
app.config['MAIL_DEFAULT_SENDER'] = 'automatic@colm.be'
app.config['SECURITY_PASSWORD_HASH'] = PASSWORD_HASH
app.config['SECURITY_PASSWORD_SALT'] = PASSWORD_SALT
app.config['MAIL_SERVER'] = MAIL_SERVER
app.config['MAIL_PORT'] = MAIL_PORT
app.config['MAIL_USE_SSL'] = MAIL_USE_SSL
app.config['MAIL_USERNAME'] = MAIL_USERNAME
app.config['MAIL_PASSWORD'] = MAIL_PASSWORD
app.config['MAIL_DEFAULT_SENDER'] = MAIL_DEFAULT_SENDER
mail = Mail(app)
# MongoDB Config
app.config['MONGODB_DB'] = 'mydatabase' # change me before prod!
app.config['MONGODB_HOST'] = 'localhost'
app.config['MONGODB_PORT'] = 27017
app.config['MONGODB_DB'] = MONGODB_DB
app.config['MONGODB_HOST'] = MONGODB_HOST
app.config['MONGODB_PORT'] = MONGODB_PORT
# Create database connection object
db = MongoEngine(app)
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
bdd = client.mydatabase
bddusers = bdd.users
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
......@@ -190,8 +177,6 @@ badges = [
}
]
# default_role = bdd.role.find({'name': 'user'})
class User(db.Document, UserMixin):
active = db.BooleanField(default=True)
first_name = db.StringField(max_length=255)
......@@ -324,15 +309,18 @@ def check_quiz(id):
if number_correct >= badge_ok:
#award badge
print('award badge ' + badge)
updateUser = User.objects.get(id= C_user)
dbbadge = Badge.objects(name=badge)
updateUser = User.objects.get(id=C_user)
dbbadge = Badge.objects.get(name=badge)
print(dbbadge)
dbbadge = str(dbbadge)
print(dbbadge)
dbbadge = dbbadge.to_json()
dbbadge = json.loads(dbbadge)
# dbbadge = json.loads(dbbadge)
print(dbbadge)
updateUser.badges = dbbadge
# updateUser.badges = dbbadge
# updateUser.update(push__badges=dbbadge)
updateUser.save(validate=False)
# print(updateUser)
# updateUser.save(validate=False)
print(updateUser)
success_message = gettext(" Felicitation vous avez le badge : ") + badge +"<i class='material-icons'>sentiment_satisfied</i>"
flash(success_message, 'alert-success')
else:
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask
import os
# Flask Security settings
secret_key = 'set-a-super-strong-pw'
DEBUG = True
FLATPAGES_AUTO_RELOAD = DEBUG
FLATPAGES_EXTENSION = '.md'
FLATPAGES_MARKDOWN_EXTENSIONS = ['markdown.extensions.extra', 'headerid']
app = Flask(__name__)
app.config['SECRET_KEY'] = 'w^c4t&fp@9T28p*Q$CrhYE'
app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_RECOVERABLE'] = True
app.config['SECURITY_CHANGEABLE'] = True
# app.config['SECURITY_TRACKABLE'] = True
app.config['SECURITY_PASSWORD_HASH'] = 'bcrypt'
app.config['SECURITY_PASSWORD_SALT'] = '$2a$16$PnnIgfMwkOjGX4SkHqSOPO'
app.config['MAIL_SERVER'] = 'mail.gandi.net'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'automatic@colm.be'
app.config['MAIL_PASSWORD'] = 'testing#123'
app.config['MAIL_DEFAULT_SENDER'] = 'automatic@colm.be'
PASSWORD_HASH = 'bcrypt'
PASSWORD_SALT = 'great_salt'
# mail server settings
MAIL_SERVER = 'mail.smth.net'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAIL_USERNAME = 'noreply@smth.net'
MAIL_PASSWORD = ''
MAIL_DEFAULT_SENDER = ''
# MongoDB Config
app.config['MONGODB_DB'] = 'mydatabase'
app.config['MONGODB_HOST'] = 'localhost'
app.config['MONGODB_PORT'] = 27017
# EVENTBRITE API
eventbrite_url_requete = "https://www.eventbriteapi.com/v3/events/search/?q=fablab&expand=organizer&token=AYO4PV2UJHXEBOLGXG74"
MONGODB_DB = 'bemaker'
MONGODB_HOST = 'localhost'
MONGODB_PORT = 27017
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