<commit_before>__author__ = 'tmaul'

from google.appengine.ext import ndb

import time
import webapp2_extras.appengine.auth.models

from webapp2_extras import security


class User(webapp2_extras.appengine.auth.models.User):

    def set_password(self, raw_password):
        """Sets the password for the current user

        :param raw_password:
            The raw password which will be hashed and stored
        """
        self.password = security.generate_password_hash(raw_password, length=22)

    @classmethod
    def get_by_auth_token(cls, user_id, token, subject='auth'):
        """Returns a user object based on a user ID and token

        :param user_id:
            The user_id of the requesting user.
        :param token:
            The token string to be verified.
        :return:
            A tuple ''(User, timestamp)'', with a user object and the token
            timestamp, or ''(None, None)'' if both were not found
        """
        token_key = cls.token_model.get_key(user_id, subject, token)
        user_key = ndb.Key(cls, user_id)
        # Use get_multi() to save a RPC call.
        valid_token, user = ndb.get_multi([token_key, user_key])
        if valid_token and user:
            timestamp = int(time.mktime(valid_token.created.timetuple()))
            return user, timestamp

        return None, None




class Group(ndb.Model):
    name = ndb.StringProperty()
    description = ndb.TextProperty()
    url = ndb.StringProperty()
    owners = ndb.KeyProperty(kind=User, repeated=True)

class Event(ndb.Model):
    name = ndb.StringProperty()
    description = ndb.TextProperty()
    location = ndb.StringProperty()
    geoLocation = ndb.GeoPtProperty()
    startDate = ndb.DateTimeProperty()
    endDate = ndb.DateTimeProperty()
<commit_msg>Added Message class for discussions within events<commit_after>__author__ = 'tmaul'

from google.appengine.ext import ndb

import time
import webapp2_extras.appengine.auth.models

from webapp2_extras import security


class User(webapp2_extras.appengine.auth.models.User):

    def set_password(self, raw_password):
        """Sets the password for the current user

        :param raw_password:
            The raw password which will be hashed and stored
        """
        self.password = security.generate_password_hash(raw_password, length=22)

    @classmethod
    def get_by_auth_token(cls, user_id, token, subject='auth'):
        """Returns a user object based on a user ID and token

        :param user_id:
            The user_id of the requesting user.
        :param token:
            The token string to be verified.
        :return:
            A tuple ''(User, timestamp)'', with a user object and the token
            timestamp, or ''(None, None)'' if both were not found
        """
        token_key = cls.token_model.get_key(user_id, subject, token)
        user_key = ndb.Key(cls, user_id)
        # Use get_multi() to save a RPC call.
        valid_token, user = ndb.get_multi([token_key, user_key])
        if valid_token and user:
            timestamp = int(time.mktime(valid_token.created.timetuple()))
            return user, timestamp

        return None, None


class Group(ndb.Model):
    name = ndb.StringProperty()
    description = ndb.TextProperty()
    url = ndb.StringProperty()
    owners = ndb.KeyProperty(kind=User, repeated=True)

class Event(ndb.Model):
    name = ndb.StringProperty()
    description = ndb.TextProperty()
    location = ndb.StringProperty()
    geoLocation = ndb.GeoPtProperty()
    startDate = ndb.DateTimeProperty()
    endDate = ndb.DateTimeProperty()

class Message(ndb.Model):
    user = ndb.UserProperty()
    created = ndb.DateTimeProperty(auto_now_add=True)
    text = ndb.TextProperty()
{'fraction_non_alphanumeric': 0.09263214095034704, 'fraction_numerical': 0.0026695141484249867, 'mean_word_length': 2.839139344262295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6161758', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1099, 'n_words': 312}