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 verify_send():
    if request.method == 'GET':
        return redirect(url_for('index'))

    username = request.form.get('username', "")
    print('username = '******'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","*****@*****.**"))

    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))
Esempio n. 4
0
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","*****@*****.**"))

        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)
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
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 = ['*****@*****.**']
        mail.send(msg)
Esempio n. 8
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. 9
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. 10
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)