Example #1
0
def view_proposal_form(request):
    json_data = {}
    proposal = None
    error_message = False

    meeting_list = MeetingFrequency.get_published_objects()
    collection_list = CollectionProcess.get_published_objects()
    association_types = AssociationType.get_published_objects()
    common_properties = CommonProperty.get_published_objects()

    # HANDLE PROPOSAL FORM
    if request.POST:
        form = ProposalForm(prefix='proposal_form', data=request.POST, meeting_list=meeting_list, collection_list=collection_list,
                            association_list=association_types, property_list=common_properties)

        if form.is_valid():

            cleaned_data = form.cleaned_data

            proposal = create_new_proposal(request, cleaned_data)

            # SEND EMAIL
            try:
                send_email(proposal)

            except Exception, e:
                logging.error(e)

            form = ProposalForm(prefix='proposal_form', meeting_list=meeting_list, collection_list=collection_list,
                                association_list=association_types, property_list=common_properties)

        else:
            error_message = True
Example #2
0
def view_contact_form(request):
    json_data = {}

    # HANDLE CONTACT FORM
    error_message = None
    contact = None

    if request.POST:
        form = ContactForm(prefix='contact_form', data=request.POST)

        if form.is_valid():
            cleaned_data = form.cleaned_data
            contact = create_new_contact(cleaned_data)

            # SEND EMAIL
            try:
                send_email(contact)

            except Exception, e:
                logging.error(e)

            form = ContactForm(prefix='contact_form')

        else:
            error_message = True
Example #3
0
def main():
    # load the stock data
    global st_list
    logging.info('loading the sotck data...')

    with open('./data/code.txt') as f:
        for c in f.readlines():
            st_list.append(Stock(c.strip()))

    # filter out the stock
    # sort the stock
    # print(st_list)

    # filter out the stocks
    st_list = [
        s for s in st_list
        if s.data.iloc[-1].volume * s.data.iloc[-1]['adj close'] >= 5000000
    ]

    logging.info('STOCK NUM: {}'.format(len(st_list)))

    logging.info('sorting the stock...')

    st_list.sort(key=rating, reverse=True)

    # only preserve the max ratings
    # st_list = [s for s in st_list if s.rating == st_list[0].rating]
    send_email(summary())
Example #4
0
def main():
    # load the stock data
    global st_list
    logging.info('loading the sotck data...')

    with open('./data/code.txt') as f:
        for c in f.readlines():
            st_list.append(Stock(c.strip()))


    # filter out the stock
    # sort the stock
    # print(st_list)

    # filter out the stocks
    st_list = [s for s in st_list if s.data.iloc[-1].volume * s.data.iloc[-1]['adj close'] >= 5000000]

    logging.info('STOCK NUM: {}'.format(len(st_list)))

    logging.info('sorting the stock...')

    st_list.sort(key=rating, reverse=True)

    # only preserve the max ratings
    # st_list = [s for s in st_list if s.rating == st_list[0].rating]
    send_email(summary())
Example #5
0
def auth_passwordreset_request(email):
    '''Generate a five-digit random number as reset
    code then send a email to the user email'''
    sample_numbers = '1234567890'
    reset_code = ''.join((random.choice(sample_numbers) for i in range(5)))
    user = data_email_search(email)
    data_reset_code_renew(user['u_id'], reset_code)
    send_email(email, reset_code)

    return {}
Example #6
0
def inform_user(user):
    """
    Collects information about next episode of each tv series requested by user and
    Sends Email
    :param user: Dictionary with email and requested tvshows
    :return:
    """
    imdb = IMDB_API()
    template = "Tv series name: {}\nStatus:{}\n\n"
    email_body = ""
    for series in user.get("tvseries"):
        series = series.strip()
        email_body += template.format(series, imdb.getnextepisode(series))
    send_email(user.get("email"), email_body)
        series_item = {'name': series_info['name'], 'data': series_data}
        series.append(series_item)
    return series

images = {}

def export_chart(chart_name, chart_data):
    global images
    chart_setting_path = os.path.join(TEMP_DIR, "%s.json" % chart_name)
    with open(chart_setting_path, 'w') as chart_setting_file:
        chart_setting_file.write(json.dumps(chart_data))
    chart_path = os.path.join(TEMP_DIR, '%s.jpg' % chart_name)
    export_cmd = 'export.cmd %s %s' % (chart_setting_path, chart_path)
    os.system(export_cmd)
    images[chart_name] = chart_path


helper = sql_helper.SqlHelper(CONNECTION_STR, args.report, REPORT_MAPPING['data'])
report_data = helper.fetch_all_data()
report_template = utility.get_template('report_template', REPORT_DIR, 'html')
report = report_template.render(**report_data)

for chart_name, chart in REPORT_MAPPING['charts'].iteritems():
    generate_x_data(chart)
    chart["series"] = generate_y_data(chart)
    export_chart(chart_name, chart)

utility.send_email(SMTP, USER, PWD, REPORT_NAME, FROM_EMAIL, TO_EMAIL, report, images)
print "Done"