예제 #1
0
def index():
    user_id = session[SESSION_ID_KEY]
    user = user_service.get_by_id(user_id)
    categories = category_service.get_all()
    return render_template('index.html',
                           categories=categories,
                           user=user)
예제 #2
0
 def decorated_function(*args, **kwargs):
     if SESSION_ID_KEY in session and SESSION_EMAIL_KEY in session:
         session_id = session[SESSION_ID_KEY]
         session_email = session[SESSION_EMAIL_KEY]
         user = user_service.get_by_id(session_id)
         if user is not None:
             user_email = user.email
             user_email_hash = hashlib.md5(user_email.encode('utf')).hexdigest()
             if session_email == user_email_hash:
                 return f(*args, **kwargs)
     return redirect(url_for('login'))
예제 #3
0
def make_report():
    lat = escape(request.get_json()['lat'])
    lng = escape(request.get_json()['lng'])
    description = escape(request.get_json()['description'])
    category_id = escape(request.get_json()['category_id'])
    user_id = session[SESSION_ID_KEY]
    category = category_service.get_by_id(category_id)
    user = user_service.get_by_id(user_id)
    if user is not None and category is not None:
        report = report_service.make_report(lat, lng, description, round(time.time()*1000), user, category)
        return dumps(report_service.report_to_dict(report))
    else:
        return redirect(url_for('not_found'))