当前位置: 首页>>代码示例>>Python>>正文


Python Message.recipients方法代码示例

本文整理汇总了Python中flaskext.mail.Message.recipients方法的典型用法代码示例。如果您正苦于以下问题:Python Message.recipients方法的具体用法?Python Message.recipients怎么用?Python Message.recipients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskext.mail.Message的用法示例。


在下文中一共展示了Message.recipients方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mark_complete

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def mark_complete():
    """
    Checks to see if a group exists in FAS for the given project and marks the
    project complete if it does. We do this this way so that we don't have to
    send FAS credentials to this app.
    """
    fas = fedora.client.AccountSystem(app.config['FAS_SERVER'],
                                      username=app.config['FAS_USERNAME'],
                                      password=app.config['FAS_PASSWORD'],
                                      insecure=app.config['FAS_INSECURE_SSL'])
    hosted_request = HostedRequest.query.filter_by(id=request.args.get('id'))
    if hosted_request.count() > 0:
        project = hosted_request[0]
        if project.completed:
            return jsonify(error="Request was already marked as completed.")

        group_name = project.scm + project.name
        try:
            group = fas.group_by_name(group_name)
        except:
            return jsonify(error="No such group: " + group_name)

        project.completed = datetime.now()
        db.session.commit()
        message = Message("Your Fedora Hosted request has been processed")
        message.body = """Hi there,

You're receiving this message because the Fedora Hosted project:
  %s
has been set up.

To access to your new repository, do the following:
  $ %s

If you've requested a Trac instance, you can visit it at:
  https://fedorahosted.org/%s

If you've requested any mailing lists, you should have received separate
emails which contain instructions on how to administrate them.

Sincerely,
Fedora Hosted""" % (
            project.name,
            scm_push_instructions(project),
            project.name)

        message.sender = \
            "Fedora Hosted <[email protected]>"

        if 'PROJECT_OWNER_EMAIL_OVERRIDE' in app.config:
            message.recipients = [app.config['PROJECT_OWNER_EMAIL_OVERRIDE']]
        else:
            message.recipients = ["%[email protected]" % project.owner]

        if not app.config['TESTING']:
            mail.send(message)

        return jsonify(success="Request marked as completed.")
    else:
        return jsonify(error="No hosted request with that ID could be found.")
开发者ID:relrod,项目名称:fedorahosted,代码行数:62,代码来源:main.py

示例2: verify_send

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def verify_send():
    if request.method == 'GET':
        return redirect(url_for('index'))

    username = request.form.get('username', "")
    print('username = ' + username)
    participant = Participant.query.filter_by(username = username).first_or_404()

    if participant.is_verified:
        flash("%s's account is already validated." % participant.username.capitalize())
        return redirect(url_for('index'))


    msg = Message("Welcome to Bacon Game Jam, " + username,
                  recipients=[participant.email],
                  sender=("bgj","[email protected]"))

    msg.html = render_template("emails/verification.html",
                               recipient=participant)

    msg.recipients = [participant.email]
    mail.send(msg)

    flash('Verification has been resent, check your email')
    return redirect(url_for('verify_status', username=username))
开发者ID:erik,项目名称:flamejam,代码行数:27,代码来源:views.py

示例3: register

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def register():
    if get_current_user():
        flash("You are already logged in.")
        return redirect(url_for("index"))

    error = None
    form = ParticipantRegistration()
    if form.validate_on_submit():
        username = form.username.data.strip()
        password = form.password.data
        email = form.email.data
        receive_emails = form.receive_emails.data
        new_participant = Participant(username,
                password,
                email,
                False, # no admin
                False,  # is verified
                receive_emails)

        msg = Message("Welcome to Bacon Game Jam, " + username,
            recipients=[email],
            sender=("bgj","[email protected]"))

        msg.html = render_template("emails/verification.html",
                                   recipient=new_participant)
        msg.recipients = [new_participant.email]
        mail.send(msg)

        db.session.add(new_participant)
        db.session.commit()

        flash("Your account has been created, confirm your email to verify.")
        return redirect(url_for('verify_status', username=username))

    return render_template('register.html', form=form, error=error)
开发者ID:erik,项目名称:flamejam,代码行数:37,代码来源:views.py

示例4: new_jam

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def new_jam():
    require_admin()

    form = NewJam()
    if form.validate_on_submit():
        title = form.title.data
        new_slug = get_slug(title)
        if Jam.query.filter_by(slug = new_slug).first():
            flash('A jam with a similar title already exists.')
        else:
            start_time = form.start_time.data
            new_jam = Jam(title, get_current_user(), start_time)
            new_jam.theme = form.theme.data
            new_jam.end_time = start_time + timedelta(hours = form.duration.data)
            new_jam.team_jam = form.team_jam.data
            db.session.add(new_jam)
            db.session.commit()
            flash('New jam added.')

            # Send out mails to all interested users.
            with mail.connect() as conn:
                participants = Participant.query.filter_by(receive_emails=True).all()
                for participant in participants:
                    msg = Message("BaconGameJam: Jam \"%s\" announced" % title)
                    msg.html = render_template("emails/jam_announced.html", jam = new_jam, recipient = participant)
                    msg.recipients = [participant.email]
                    conn.send(msg)
                flash("Email notifications have been sent.")

            #return render_template("emails/jam_announced.html", jam = new_jam, recipient = get_current_user())
            return redirect(new_jam.url())
    return render_template('new_jam.html', form = form)
开发者ID:erik,项目名称:flamejam,代码行数:34,代码来源:views.py

示例5: edit_jam

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def edit_jam(jam_slug):
    require_admin()
    jam = Jam.query.filter_by(slug = jam_slug).first_or_404()

    if not 0 <= jam.getStatus().code <= 1:
        # editing only during the jam and before
        flash("The jam is over, you cannot edit it anymore.")
        return redirect(jam.url())

    form = EditJam()
    if form.validate_on_submit():
        # remember what has changed
        changes = {}
        changes["theme"] = [jam.theme != form.theme.data, jam.theme]
        changes["title"] = [jam.title != form.title.data, jam.title]
        changes["start_time"] = [jam.start_time != form.start_time.data, jam.start_time]

        title_changed = jam.title != form.title.data
        start_time_changed = jam.start_time != form.start_time.data

        # change the options
        jam.theme = form.theme.data
        jam.title = form.title.data
        jam.start_time = form.start_time.data
        db.session.commit()

        changed = (changes["theme"][0] or
            changes["title"][0] or
            changes["start_time"][0])

        if not changed:
            flash("Nothing has changed. Keep moving!")
        else:
            # inform users about change
            if form.email.data:
                with mail.connect() as conn:
                    participants = Participant.query.filter_by(receive_emails=True).all()
                    for participant in participants:
                        msg = Message("BaconGameJam: Jam \"%s\" changed" % changes["title"][1])
                        msg.html = render_template("emails/jam_changed.html", jam = jam, changes = changes, recipient = participant)
                        msg.recipients = [participant.email]
                        conn.send(msg)
                    flash("Email notifications have been sent.")

            flash("The jam has been changed.")
        return redirect(jam.url())

    elif request.method != "POST":
        form.title.data = jam.title
        form.theme.data = jam.theme
        form.start_time.data = jam.start_time

    return render_template('edit_jam.html', jam = jam, form = form)
开发者ID:erik,项目名称:flamejam,代码行数:55,代码来源:views.py

示例6: sendmail

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def sendmail(mailtype, data=None):
    '''
    Mail dispatcher

    :param mailtype: can be 'error', 'rating' or 'mailreminder'
    :param data: data for mail-forming, depends on mailtype
    '''
    if data:
        if mailtype is 'mailreminder':
            msg = Message('[einfachJabber.de] Jabber-Konto Registrierung')
            msg.body = u'''
    einfachJabber.de

    Du hast eben über http://einfachjabber.de einen neuen
    Jabber-Account registriert.
    Die Benutzerdaten dazu lauten:

    Benutzername: %s
    Passwort: %s

    Auf http://einfachjabber.de findest du Anleitungen für
    verschiedene Client-Programme.
            ''' % (data[1], data[2])
            msg.recipients = [data[0]]

        if mailtype is 'rating':
            msg = Message('[einfachJabber.de] Tutorialbewertung')
            msg.body = u'''
    einfachJabber.de Tutorialbewertung

    Bewertung: %s
    Vorschlag: %s
    Tutorial: %s
            ''' % (data[0], data[1], data[2])
            msg.recipients = ['[email protected]']
        mail.send(msg)
开发者ID:einfachjabber,项目名称:einfachjabber.de,代码行数:38,代码来源:utils.py

示例7: send

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def send(file_id):
  recipient = request.form.get("recipient")
  f = get_file(file_id)

  msg = Message("File sent from Yaka")
  msg.sender = g.user.email
  msg.recipients = [recipient]
  msg.body = """The following file (%s) might be interesting to you.

  """ % f.name

  msg.attach(f.name, f.mime_type, f.data)

  mail.send(msg)
  flash("Email successfully sent", "success")

  return redirect(ROOT + "%d" % f.uid)
开发者ID:sfermigier,项目名称:yaka,代码行数:19,代码来源:dm.py

示例8: hello

# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import recipients [as 别名]
def hello():
    form = RequestForm()
    if form.validate_on_submit():
        # The hosted request itself (no mailing lists)
        hosted_request = HostedRequest(
            name=form.project_name.data,
            pretty_name=form.project_pretty_name.data,
            description=form.project_description.data,
            scm=form.project_scm.data,
            trac=form.project_trac.data,
            owner=form.project_owner.data,
            comments=form.comments.data)
        db.session.add(hosted_request)
        db.session.commit()

        # Mailing lists
        for entry in form.project_mailing_lists.entries:
            if entry.data:
                # The field wasn't left blank...
                list_name = entry.data

                # The person only entered the list name, not the full address.
                if not list_name.endswith("@lists.fedorahosted.org"):
                    list_name = list_name + "@lists.fedorahosted.org"

                mailing_list = MailingList.find_or_create_by_name(list_name)

                # The last step before storing the list is handling
                # commit lists -- lists that get commit messages -- which also
                # appear as regular lists.
                commit_list = False
                if list_name in form.project_commit_lists.entries:
                    del form.project_commit_lists.entries[list_name]
                    commit_list = True

                # Now we have a mailing list object (in mailing_list), we can
                # store the relationship using it.
                list_request = ListRequest(
                    mailing_list=mailing_list,
                    hosted_request=hosted_request,
                    commit_list=commit_list)
                db.session.add(list_request)
                db.session.commit()

        # Add the remaining commit list entries to the project.
        for entry in form.project_commit_lists.entries:
            if entry.data:
                mailing_list = MailingList.find_or_create_by_name(entry.data)
                list_request = ListRequest(
                    mailing_list=mailing_list,
                    hosted_request=hosted_request,
                    commit_list=True)
                db.session.add(list_request)
                db.session.commit()

        # Tell some people that the request has been made.
        message = Message("New Fedora Hosted project request")
        message.body = """Members of sysadmin-hosted,

A new Fedora Hosted request, id %s,  has been made.
To process this request, please do the following:

$ ssh fedorahosted.org
$ fedorahosted -n -p %s    # No-op. Review this and make sure the output looks
                          # sane.

$ sudo fedorahosted -p %s  # Actually process the request.

Thanks,
Fedora Hosted automation system""" % (hosted_request.id,
                                      hosted_request.id,
                                      hosted_request.id)
        message.recipients = [app.config['NOTIFY_ON_REQUEST']]
        message.sender = \
            "Fedora Hosted <[email protected]>"
        if not app.config['TESTING']:
            mail.send(message)

        return render_template('completed.html')

    # GET, not POST.
    return render_template('index.html', form=form)
开发者ID:relrod,项目名称:fedorahosted,代码行数:84,代码来源:main.py


注:本文中的flaskext.mail.Message.recipients方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。