<commit_before># Author:       <NAME>
# Date:         April 16, 2016
# Name:         rest_api.py
# Description:  REST API for Office Lunch

from flask import Flask, jsonify, abort, make_response, request, url_for
from flask_cors import CORS
from flask_mongoengine import MongoEngine

import datetime

app = Flask(__name__)
CORS(app, resources=r'/api/*', headers='Content-Type')
# app.config['CORS_HEADERS'] = 'Content-Type'
app.config['MONGODB_SETTINGS'] = {'db': 'officelunch'}

db = MongoEngine(app)


class User(db.Document):
    name = db.StringField(max_length=255, required=True)
    email = db.EmailField(required=True)
    password = <PASSWORD>(max_length=255, required=True)
    phone = db.StringField() #Does this need to be required? This will need to be checked somewhere else in the application since there is no mongo field for phone numbers
    userid = db.StringField(max_length=255, required=True)
    member_of = db.ListField(db.StringField()) #list of lgids that the user belongs to


class Lgroup(db.Document):
    name = db.StringField(max_length=255, required=True)
    lgid = db.StringField(required=True)
    users = db.ListField(db.DictField(), required=True)
    origin = db.DictField(required=True) #This will be a python dictionary storing lat/long
    tags = db.ListField(db.StringField(max_length=255), required=True)
    dest_list = db.ListField(db.DictField()) #This is a list of dictionaries holding lat/long and # of votes
    final_dest = db.DictField() #dictionary with lat/long of voting winner
    admin = db.StringField(max_length=255, required=True) #id of the group admin
    start_time = db.DateTimeField(default=datetime.datetime.now, required=True)
    end_time = db.DateTimeField()#end date of the event


users = [
    {
        'id': 1,
        'name': '<NAME>',
        'username': 'clinton',
        'password': '<PASSWORD>'
    }
]


def get_user_id(username, password):
    user_id = '-1'
    for obj in users:
        if username == obj['username'] and password == obj['password']:
            user_id = obj['id']

    # print 'User ID: %s' % user_id
    return user_id


def get_user(usr_email, pwd):

    user = User.objects(email=usr_email, password=pwd)

    print type(user[0])
<commit_msg>Testing login<commit_after># Author:       <NAME>
# Date:         April 16, 2016
# Name:         rest_api.py
# Description:  REST API for Office Lunch

from flask import Flask, jsonify, abort, make_response, request, url_for
from flask_cors import CORS
from flask_mongoengine import MongoEngine

import datetime

app = Flask(__name__)
CORS(app, resources=r'/api/*', headers='Content-Type')
# app.config['CORS_HEADERS'] = 'Content-Type'
app.config['MONGODB_SETTINGS'] = {'db': 'officelunch'}

db = MongoEngine(app)


class User(db.Document):
    name = db.StringField(max_length=255, required=True)
    email = db.EmailField(required=True)
    password = db.StringField(max_length=255, required=True)
    phone = db.StringField() #Does this need to be required? This will need to be checked somewhere else in the application since there is no mongo field for phone numbers
    userid = db.StringField(max_length=255, required=True)
    member_of = db.ListField(db.StringField()) #list of lgids that the user belongs to


class Lgroup(db.Document):
    name = db.StringField(max_length=255, required=True)
    lgid = db.StringField(required=True)
    users = db.ListField(db.DictField(), required=True)
    origin = db.DictField(required=True) #This will be a python dictionary storing lat/long
    tags = db.ListField(db.StringField(max_length=255), required=True)
    dest_list = db.ListField(db.DictField()) #This is a list of dictionaries holding lat/long and # of votes
    final_dest = db.DictField() #dictionary with lat/long of voting winner
    admin = db.StringField(max_length=255, required=True) #id of the group admin
    start_time = db.DateTimeField(default=datetime.datetime.now, required=True)
    end_time = db.DateTimeField()#end date of the event


users = [
    {
        'id': 1,
        'name': '<NAME>',
        'username': 'clinton',
        'password': '<PASSWORD>'
    }
]


def get_user_id(username, password):
    user_id = '-1'
    for obj in users:
        if username == obj['username'] and password == obj['password']:
            user_id = obj['id']

    # print 'User ID: %s' % user_id
    return user_id


def get_user(usr_email, pwd):

    user = User.objects.get(email=usr_email, password=<PASSWORD>)

{'fraction_non_alphanumeric': 0.11819803746654772, 'fraction_numerical': 0.011819803746654773, 'mean_word_length': 3.901639344262295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '895831', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1406, 'n_words': 397}