예제 #1
0
def index():
    posts = Post.query.order_by(Post.timestamp.desc()).limit(3)
    req = RequestInviteForm()

    if req.validate_on_submit():
        subject = "Invitation Code Request by {}<{}>".format(
            req.first_name.data, req.email.data)

        send_mail(subject,
                  current_app.config['ADMIN_EMAIL'],
                  current_app.config['ADMIN_EMAIL'],
                  text_body=render_template('email/invite_req.txt',
                                            name=req.first_name.data,
                                            email=req.email.data),
                  html_body=render_template('email/invite_req.html',
                                            name=req.first_name.data,
                                            email=req.email.data))
        send_mail("Thank you for your interest in Saves-All-Comics",
                  current_app.config['ADMIN_EMAIL'],
                  req.email.data,
                  text_body=render_template('email/thankyou_req.txt',
                                            name=req.first_name.data),
                  html_body=render_template('email/thankyou_req.html',
                                            name=req.first_name.data))
        time.sleep(2)
        msg = Markup(
            '<div class="alert alert-info alert-dismissible mb-4 py-3 text-center" role="alert"><h4>Thank You</h4><p><i class="fa fa-check-circle-o"></i> Moderators were alerted to your request. An email was sent to {} for confirmation.</p> <hr> <p class="text-danger"><small>Please keep in mind that this tool is not intended for use by the general public and no guarantees are made that access will be granted.</small></p><button role="button" class="close" data-dismiss="alert" type="button">&times;</button></div>'
            .format(req.email.data))
        flash(msg, category='public')
        return redirect(url_for('main.blog'))

    return render_template('brizzledev3/index.html', posts=posts, req=req)
예제 #2
0
def post(permalink):
    post = Post.query.filter_by(permalink=permalink).first_or_404()
    posts = Post.query.all()
    req = RequestInviteForm()
    tags = Tag.query.order_by(Tag.timestamp.desc()).limit(10)
    categories = PostCategory.query.order_by(
        PostCategory.timestamp.desc()).limit(10)
    tags = Tag.query.order_by(Tag.timestamp.desc()).limit(10)
    categories = PostCategory.query.order_by(
        PostCategory.timestamp.desc()).limit(10)
    latest_posts = Post.query.order_by(Post.timestamp.desc()).limit(4)
    prev_id = post.id - 1
    next_id = post.id + 1
    if prev_id > 0:
        prev = Post.query.filter_by(id=(prev_id)).first()
    else:
        prev = None

    if next_id > 0:
        _next = Post.query.filter_by(id=next_id).first()
    else:
        _next = None

    if req.validate_on_submit():
        subject = "Invitation Code Request by {}<{}>".format(
            req.first_name.data, req.email.data)

        send_mail(subject,
                  current_app.config['ADMIN_EMAIL'],
                  current_app.config['ADMIN_EMAIL'],
                  text_body=render_template('email/invite_req.txt',
                                            name=req.first_name.data,
                                            email=req.email.data),
                  html_body=render_template('email/invite_req.html',
                                            name=req.first_name.data,
                                            email=req.email.data))
        send_mail("Thank you for your interest in Saves-All-Comics",
                  current_app.config['ADMIN_EMAIL'],
                  req.email.data,
                  text_body=render_template('email/thankyou_req.txt',
                                            name=req.first_name.data),
                  html_body=render_template('email/thankyou_req.html',
                                            name=req.first_name.data))
        time.sleep(2)
        msg = Markup(
            '<div class="alert alert-info alert-dismissible mb-4 py-3 text-center" role="alert"><h4>Thank You</h4><p><i class="fa fa-check-circle-o"></i> Moderators were alerted to your request. An email was sent to {} for confirmation.</p> <hr> <p class="text-danger"><small>Please keep in mind that this tool is not intended for use by the general public and no guarantees are made that access will be granted.</small></p><button role="button" class="close" data-dismiss="alert" type="button">&times;</button></div>'
            .format(req.email.data))
        flash(msg, category='public')
        return redirect(url_for('main.blog'))

    return render_template('brizzledev3/single-blog.html',
                           post=post,
                           posts=posts,
                           req=req,
                           categories=categories,
                           tags=tags,
                           prev=prev,
                           _next=_next,
                           latest_posts=latest_posts)
예제 #3
0
def create_student(username=None, password=None):
    student = Student(verified=False, username=username, password=password)
    db.session.add(student)
    db.session.commit()
    if bool(check_student_by_username(username)):
        token = generate_signup_token(username)
        send_mail(recipients=student.username, token=token)
        return check_student_by_username(username)
    return None
예제 #4
0
def tag(name):
    tag = Tag.query.filter_by(name=name).first_or_404()
    tags = Tag.query.order_by(Tag.timestamp.desc()).limit(10)
    categories = PostCategory.query.order_by(
        PostCategory.timestamp.desc()).limit(10)
    latest_posts = Post.query.order_by(Post.timestamp.desc()).limit(4)
    page = request.args.get('page', 1, type=int)
    pagination = Post.query.filter(Post.tags.any(
        Tag.name == tag.name)).order_by(Post.timestamp.desc()).paginate(
            page,
            per_page=current_app.config['ENTRIES_PER_PAGE'],
            error_out=False)
    req = RequestInviteForm()
    posts = pagination.items

    if req.validate_on_submit():
        subject = "Invitation Code Request by {}<{}>".format(
            req.first_name.data, req.email.data)

        send_mail(subject,
                  current_app.config['ADMIN_EMAIL'],
                  current_app.config['ADMIN_EMAIL'],
                  text_body=render_template('email/invite_req.txt',
                                            name=req.first_name.data,
                                            email=req.email.data),
                  html_body=render_template('email/invite_req.html',
                                            name=req.first_name.data,
                                            email=req.email.data))
        send_mail("Thank you for your interest in Saves-All-Comics",
                  current_app.config['ADMIN_EMAIL'],
                  req.email.data,
                  text_body=render_template('email/thankyou_req.txt',
                                            name=req.first_name.data),
                  html_body=render_template('email/thankyou_req.html',
                                            name=req.first_name.data))
        time.sleep(2)
        msg = Markup(
            '<div class="alert alert-info alert-dismissible mb-4 py-3 text-center" role="alert"><h4>Thank You</h4><p><i class="fa fa-check-circle-o"></i> Moderators were alerted to your request. An email was sent to {} for confirmation.</p> <hr> <p class="text-danger"><small>Please keep in mind that this tool is not intended for use by the general public and no guarantees are made that access will be granted.</small></p><button role="button" class="close" data-dismiss="alert" type="button">&times;</button></div>'
            .format(req.email.data))
        flash(msg, category='public')
        return redirect(url_for('main.blog'))
    return render_template('brizzledev3/tag.html',
                           posts=posts,
                           pagination=pagination,
                           page=page,
                           name=tag.name,
                           req=req,
                           tags=tags,
                           categories=categories,
                           latest_posts=latest_posts)
예제 #5
0
def register(code):
    invitation = Invitation.query.filter_by(invitation_code=code).first()
    if invitation is None:
        return redirect(url_for('main.invalid'))
    invite = InviteForm()

    if invite.validate_on_submit():
        referer = User.query.filter_by(
            username=invitation.invited_by.username).first()
        user = User()
        user.username = invite.username.data
        user.email = invite.email.data
        if not (check_invite_code(invite.email.data, code)):
            return redirect(url_for('main.invalid'))
        user.first_name = invite.first_name.data
        user.last_name = invite.last_name.data
        user.password = invite.password.data

        the_file = upload_file('avatar')

        if the_file:
            post.featured_image = the_file

        send_mail("Thank you for registering with Save All Comics",
                  current_app.config['ADMIN_EMAIL'],
                  invitation.email,
                  text_body=render_template('email/thankyou_req.txt',
                                            invitation=invitation),
                  html_body=render_template('email/thankyou_req.html',
                                            invitation=invitation))
        msg = "Email Confirmation Sent! Please login."

        db.session.add(user)
        db.session.delete(invitation)
        db.session.commit()

        user = User.query.filter_by(username=invite.username.data).first()
        # user.referer = referer

        db.session.add(user)
        db.session.commit()
        flash(msg, category='public')
        return redirect(url_for('main.savecomic'))
    return render_template('admin/register.html',
                           invite=invite,
                           invitation=invitation)
예제 #6
0
def invite():
    form = SendInviteForm()

    page = request.args.get('page', 1, type=int)

    pagination = Invitation.query.order_by(
        Invitation.timestamp.desc()).paginate(
            page,
            per_page=current_app.config['ENTRIES_PER_PAGE'],
            error_out=False)
    invitations = pagination.items

    if form.validate_on_submit():
        comic = Comic.query.get(randint(1, Comic.query.count()))
        invitation = Invitation()
        invitation.first_name = form.first_name.data
        invitation.last_name = form.last_name.data
        invitation.email = form.email.data
        invitation.referer_id = current_user.id
        invitation.invitation_code = generate_invite_code(form.email.data)
        subject = "{} {} has invited you to Save All Comics".format(
            current_user.first_name, current_user.last_name)
        send_mail(subject,
                  '*****@*****.**',
                  invitation.email,
                  text_body=render_template('email/invitation.txt',
                                            invitation=invitation,
                                            comic=comic),
                  html_body=render_template('email/invitation.html',
                                            invitation=invitation,
                                            comic=comic))
        if current_user.role.name != "Administrator":
            current_user.invite_limit -= 1
        db.session.add(current_user)
        db.session.add(invitation)
        db.session.commit()
        msg = Markup(
            '<div class="alert alert-light alert-dismissible mb-4 py-3 border-left-success">Invitation was sent to {}<button role="button" class="close" data-dismiss="alert" type="button">&times;</button></div>'
        )
        flash(msg.format(invitation.email))
        return redirect(url_for('account.invite'))
    return render_template('admin/invite.html',
                           form=form,
                           invitations=invitations,
                           pagination=pagination)
예제 #7
0
def contact():
    form = ContactForm()
    req = RequestInviteForm()
    posts = Post.query.all()

    if req.request.data and req.validate_on_submit():
        subject = "Invitation Code Request by {}<{}>".format(
            req.first_name.data, req.email.data)

        send_mail(subject,
                  current_app.config['ADMIN_EMAIL'],
                  current_app.config['ADMIN_EMAIL'],
                  text_body=render_template('email/invite_req.txt',
                                            name=req.first_name.data,
                                            email=req.email.data),
                  html_body=render_template('email/invite_req.html',
                                            name=req.first_name.data,
                                            email=req.email.data))
        send_mail("Thank you for your interest in Saves-All-Comics",
                  current_app.config['ADMIN_EMAIL'],
                  req.email.data,
                  text_body=render_template('email/thankyou_req.txt',
                                            name=req.first_name.data),
                  html_body=render_template('email/thankyou_req.html',
                                            name=req.first_name.data))
        time.sleep(2)
        msg = Markup(
            '<div class="alert alert-info alert-dismissible mb-4 py-3 text-center" role="alert"><h4>Thank You</h4><p><i class="fa fa-check-circle-o"></i> Moderators were alerted to your request. An email was sent to {} for confirmation.</p> <hr> <p class="text-danger"><small>Please keep in mind that this tool is not intended for use by the general public and no guarantees are made that access will be granted.</small></p><button role="button" class="close" data-dismiss="alert" type="button">&times;</button></div>'
            .format(req.email.data))
        flash(msg, category='public')
        return redirect(url_for('main.blog'))

    if form.contact.data and form.validate_on_submit():
        contact = Contact()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.subject = form.subject.data
        contact.message = form.message.data

        subject = "Development Inquiry from {}<{}>".format(
            contact.name, contact.email)

        send_mail(subject,
                  current_app.config['ADMIN_EMAIL'],
                  current_app.config['ADMIN_EMAIL'],
                  text_body=render_template('email/contact_send.txt',
                                            name=contact.name,
                                            email=contact.email,
                                            msg=contact.message),
                  html_body=render_template('email/contact_send.html',
                                            name=contact.name,
                                            email=contact.email,
                                            msg=contact.message))
        send_mail("Thank you for your interest in Saves-All-Comics",
                  current_app.config['ADMIN_EMAIL'],
                  contact.email,
                  text_body=render_template('email/contact_req.txt',
                                            name=contact.name),
                  html_body=render_template('email/contact_req.html',
                                            name=contact.name))
        time.sleep(2)

        db.session.add(contact)
        db.session.commit()
        msg = Markup('Email sent! Someone will reach out within 24 hours.')
        flash(msg, category='public')
        return redirect(url_for('main.index'))

    return render_template('brizzledev3/contact.html',
                           form=form,
                           req=req,
                           posts=posts)
예제 #8
0
파일: Barry.py 프로젝트: gowerc/Barry
    set_logger()
    root = os.path.dirname(os.path.realpath(__file__))
    secrets = core.get_secrets(root)
    arg = sys.argv[1]
    try:
        assert core.is_hdd_reachable("hdd") and core.is_hdd_reachable("hdd2")
        module = importlib.import_module("core." + arg)
        results = module.main(secrets)
    except Exception as e:
        results = core.result(log=str(e), success=False, subject=arg)

    result_string = "Success" if results.success else "Failure"

    if results.log:
        tf = tempfile.NamedTemporaryFile(suffix='.txt')
        tf.write(results.log)
        tf.seek(0)
        FILES = [tf.name]
    else:
        FILES = []

    core.send_mail(send_to=[secrets["emailAddressTo"]],
                   send_from=secrets["emailAddressFrom"],
                   pwd=secrets["emailPassword"],
                   subject=results.subject + " - " + result_string,
                   text="Please see attachements for details",
                   files=FILES)

    if results.log:
        tf.close()