Esempio n. 1
0
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 <*****@*****.**>"

        if 'PROJECT_OWNER_EMAIL_OVERRIDE' in app.config:
            message.recipients = [app.config['PROJECT_OWNER_EMAIL_OVERRIDE']]
        else:
            message.recipients = ["*****@*****.**" % 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.")
Esempio n. 2
0
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 <*****@*****.**>"

        if 'PROJECT_OWNER_EMAIL_OVERRIDE' in app.config:
            message.recipients = [app.config['PROJECT_OWNER_EMAIL_OVERRIDE']]
        else:
            message.recipients = ["*****@*****.**" % 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.")
Esempio n. 3
0
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)
Esempio n. 4
0
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 <*****@*****.**>"
        if not app.config['TESTING']:
            mail.send(message)

        return render_template('completed.html')

    # GET, not POST.
    return render_template('index.html', form=form)
Esempio n. 5
0
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 <*****@*****.**>"
        if not app.config['TESTING']:
            mail.send(message)

        return render_template('completed.html')

    # GET, not POST.
    return render_template('index.html', form=form)