Example #1
0
def index():
    e = bottle.request.POST.get('email')
    p1 = bottle.request.POST.get('password1')
    p2 = bottle.request.POST.get('password2')
        
    if e and p1 and p2:
        if p1 != p2:
            return bottle.template('register', error='The passwords do not match', email=e, password1=p1, password2=p2)
        else:
            u = User(_DBCON, email=e, password=p1)
            if u._id:
                return bottle.template('register', error='An account already exists for that email address', email=e, password1=p1, password2=p2)
            else:
                u.save()
                e = Email(recipient=e)
                e.send('Places accounts activation', '<a href="%s/activate/%s">Activate</a>' % (settings.BASEURL, u.token))
                return bottle.redirect('/success')
                
                
    else:
        vd = {
            #'date':datetime.datetime.now().strftime('%Y'),
            'baseurl':settings.BASEURL,
        }
        return bottle.template('register', error='Please complete the form', email=e or '', password1=p1 or '', password2=p2 or '', vd=vd)
Example #2
0
def download_email(message_id):
    raw_message = get_gmail_message(message_id)
    parsed_message = parse_message(raw_message)
    try:
        Email.get(Email.message_id == parsed_message['message_id'])
        print "Found email with id %s. Did not create" % parsed_message[
            'message_id']
    except DoesNotExist:
        e = Email.create(**parsed_message)
        sender_email_address = e.get_sender_email()
        # if '@' not in sender_email_address: import pdb; pdb.set_trace()
        s = SenderMetadata.get_or_create(
            email_address=sender_email_address,
            email_url=sender_email_address.split('@')[1])
        e.sender = s
        e.save()
Example #3
0
    def register_post(self):
        e = bottle.request.POST.get('email')
        p1 = bottle.request.POST.get('password1')
        p2 = bottle.request.POST.get('password2')

        if e and p1 and p2:
            if p1 != p2:
                self.viewdata.update({
                    'error': 'The passwords do not match',
                    'email': e,
                    'password1': p1,
                    'password2': p2,
                })
                return self._template('register')
            else:
                u = User(_DBCON, email=e, password=p1)
                if u._id:
                    self.viewdata.update({
                        'error':
                        'An account already exists for that email address',
                        'email': e,
                        'password1': p1,
                        'password2': p2,
                    })

                    return self._template('register')
                else:
                    u.save()
                    e = Email(recipient=e)
                    e.send(
                        'Places accounts activation',
                        '<a href="%s/activate/%s">Activate</a>' %
                        (settings.BASEURL, u.token))

                    return bottle.redirect('/success')

        else:
            self.viewdata.update({
                'error': 'Please complete the form',
                'email': e,
                'password1': p1,
                'password2': p2,
            })

            return self._template('register')
Example #4
0
def reset_database():
    # Delete 'emails.db' sqlite database
    if os.path.exists('emails.db'):
        os.remove('emails.db')
        logger.info("Deleted database 'emails.db'")

    # Re-create 'emails.db' sqlite database
    db = SqliteDatabase('emails.db')
    logger.info("Created database 'emails.db'")
    Email.create_table()
    SenderMetadata.create_table()
    Comment.create_table()
    Form.create_table()
    Category.create_table()

    Category(name="Meetings").save()
    Category(name="Opinions").save()
    Category(name="Question").save()
    Category(name="Action").save()
    Category(name="Thank You").save()
Example #5
0
    def register_post(self):
        e = bottle.request.POST.get("email")
        p1 = bottle.request.POST.get("password1")
        p2 = bottle.request.POST.get("password2")

        if e and p1 and p2:
            if p1 != p2:
                self.viewdata.update(
                    {"error": "The passwords do not match", "email": e, "password1": p1, "password2": p2}
                )
                return self._template("register")
            else:
                u = User(_DBCON, email=e, password=p1)
                if u._id:
                    self.viewdata.update(
                        {
                            "error": "An account already exists for that email address",
                            "email": e,
                            "password1": p1,
                            "password2": p2,
                        }
                    )

                    return self._template("register")
                else:
                    u.save()
                    e = Email(recipient=e)
                    e.send(
                        "Places accounts activation",
                        '<a href="%s/activate/%s">Activate</a>' % (settings.BASEURL, u.token),
                    )

                    return bottle.redirect("/success")

        else:
            self.viewdata.update({"error": "Please complete the form", "email": e, "password1": p1, "password2": p2})

            return self._template("register")
def main():
    html = """
    <h4>Dit is een titel</h4>
    <ul>
        <li>Bolleke 1</li>
        <li>Bolleke 2</li>
        <li>Bolleke 3</li>
    </ul>
    
    <img src="https://i.ebayimg.com/00/s/NTQ1WDcyOA==/z/TJUAAOSwYihc2YXa/$_86.JPG" alt="nen auto">
    """

    Email('*****@*****.**', '*****@*****.**',
          'testje met html', html)
Example #7
0
def main():
    interests = [
        'Snapchat',
        'Zoom',
        'Covid-19',
        'SQL',
        'Apple',
        'Tesla',
        'TSLA',
        'Docker',
        'AWS',
    ]

    articles = get_relevant_articles(interests)
    html = construct_email(articles)

    Email(
        '*****@*****.**',
        '*****@*****.**',
        'Daily Digest %s' % get_current_day(),
        html
    )
Example #8
0
# Scientific computing imports
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import networkx as nx
from scipy import sparse

# Import other files in package
from models.Comment import Comment
from models.Form import Form
from models.Email import Email

t = Terminal()

# Prepare Data into mutli-dimensional vectors
emails = Email.select()
texts = np.array([email.text for email in emails])
metadata = [email.id for email in emails]

# Convert a collection of text documents to a matrix of token counts
vectorizer = CountVectorizer(lowercase=True)
count_vectors = vectorizer.fit_transform(texts)

# Calculate cosine similarity vectors
cosine_vectors = [cosine_similarity(v, count_vectors) for v in count_vectors]
cosine_vectors = np.vstack(cosine_vectors)

# Add vertical and horizontal axes
metadata_vector_x = np.array([metadata])
metadata_vector_y = np.array([[' '] + metadata]).transpose()
final_array = np.vstack((metadata_vector_x, cosine_vectors))