Пример #1
0
    def reject(self, id, subject=None, body=None, token=None, silent=False):
        t = queue.Ticket.get(int(id))
        if t.state != "open":
            flash("This ticket's not open!")
            redirect("/ticket/%s" % id)
        if t.rtid is None:
            flash("This ticket has no RT ID!")
            redirect("/ticket/%s" % id)
        if (subject and body) or silent:
            if token != auth.token():
                flash("Invalid token!")
            else:
                # Send mail and records it as an event
                if not silent:
                    rt.call(
                        "ticket/%d/comment" % (t.rtid,), Action="correspond", Text=body
                    )
                    t.addEvent(
                        type=u"mail",
                        state=u"rejected",
                        target=u"user",
                        subject=subject,
                        body=body,
                    )
                    flash("Ticket rejected; mail sent to user.")
                else:
                    rt.call(
                        "ticket/%d/comment" % (t.rtid,),
                        Action="comment",
                        Text="Ticket rejected silently.\n\n" + body,
                    )
                    t.addEvent(
                        type=u"mail",
                        state=u"rejected",
                        target=u"rt",
                        subject=subject,
                        body=body,
                    )
                    flash("Ticket rejected silently.")
                redirect("/queue")
        return dict(
            tickets=[t],
            action=url("/reject/%s" % id),
            subject="Re: Request for hostname %s" % t.hostname,
            body="""Hello,

Unfortunately, the hostname %(hostname)s is not available.  You can go to https://pony.scripts.mit.edu/ to request a different one.

Sorry for the inconvenience,
-%(first)s

/set status=rejected
"""
            % dict(hostname=t.hostname, first=auth.first_name()),
            submit="Send to %s" % t.requestor,
            extra_buttons={"silent": "Send as Comment"},
        )
Пример #2
0
    def reject(self, id, subject=None, body=None, token=None, silent=False):
        t = queue.Ticket.get(int(id))
        if t.state != 'open':
            flash("This ticket's not open!")
            redirect('/ticket/%s' % id)
        if t.rtid is None:
            flash("This ticket has no RT ID!")
            redirect('/ticket/%s' % id)
        if (subject and body) or silent:
            if token != auth.token():
                flash("Invalid token!")
            else:
                # Send mail and records it as an event
                if not silent:
                    mail.send_correspondence(subject, body, t.rtid,
                                             auth.current_user())
                    t.addEvent(type=u'mail',
                               state=u'rejected',
                               target=u'user',
                               subject=subject,
                               body=body)
                    flash("Ticket rejected; mail sent to user.")
                else:
                    mail.send_comment(subject,
                                      "Ticket rejected silently.\n\n" + body,
                                      t.id, t.rtid, auth.current_user())
                    t.addEvent(type=u'mail',
                               state=u'rejected',
                               target=u'rt',
                               subject=subject,
                               body=body)
                    flash("Ticket rejected silently.")
                redirect('/queue')
        return dict(tickets=[t],
                    action=url('/reject/%s' % id),
                    subject="Re: Request for hostname %s" % t.hostname,
                    body="""Hello,

Unfortunately, the hostname %(hostname)s is not available.  You can go to http://pony.scripts.mit.edu/ to request a different one.

Sorry for the inconvenience,
-%(first)s

/set status=rejected
""" % dict(hostname=t.hostname, first=auth.first_name()),
                    submit='Send to %s' % t.requestor,
                    extra_buttons={'silent': 'Send as Comment'})
Пример #3
0
    def approve(self, id, subject=None, body=None, token=None, silent=False):
        t = queue.Ticket.get(int(id))
        if t.state != "open":
            flash("This ticket's not open!")
            redirect("/ticket/%s" % id)
        if t.rtid is None:
            flash("This ticket has no RT ID!")
            redirect("/ticket/%s" % id)
        if subject and body:
            if token != auth.token():
                flash("Invalid token!")
            else:
                try:
                    vhosts.actually_create_vhost(t.locker, t.hostname, t.path)
                except vhosts.UserError as e:
                    flash(e.message)
                else:
                    if not silent:
                        # Send mail and records it as an event
                        rt.call(
                            "ticket/%d/comment" % (t.rtid,),
                            Action="comment",
                            Text=body,
                            Cc="*****@*****.**",
                        )

                        t.addEvent(
                            type="mail",
                            state="moira",
                            target="accounts-internal",
                            subject=subject,
                            body=body,
                        )
                        flash("Ticket approved; mail sent to accounts-internal.")
                    else:
                        rt.call(
                            "ticket/%d/comment" % (t.rtid,),
                            Action="comment",
                            Text="Ticket approved silently.\n\n" + body,
                        )
                        t.addEvent(type="mail", state="dns", target="us")
                        flash("Ticket approved silently.")
                    redirect("/queue")
        short = t.hostname[: -len(".mit.edu")]
        assert t.hostname[0] != "-"
        stella = subprocess.Popen(
            ["/usr/bin/stella", t.hostname],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        out, err = stella.communicate()
        return dict(
            tickets=[t],
            action=url("/approve/%s" % id),
            subject="scripts-vhosts CNAME request: %s" % short,
            body="""Hi accounts-internal,

At your convenience, please make %(short)s an alias of scripts-vhosts.

stella scripts-vhosts -a %(short)s

Thanks!
-%(first)s
SIPB Scripts Team

/set status=stalled
"""
            % dict(short=short, first=auth.first_name()),
            help_text_html="<p>Make sure the host name is not being used:</p><pre>$ stella %s\n%s\n%s</pre><p>If it's DELETED, you need to forward explicit confirmation that it's OK to reuse (from owner/contact/billing contact, or rccsuper for dorms, or a FSILG's net contact, or similar).</p>"
            % (cgi.escape(t.hostname), cgi.escape(out), cgi.escape(err)),
            extra_buttons={"silent": "Approve without mailing accounts-internal"},
        )
Пример #4
0
        return dict(
            tickets=[t],
            action=url('/approve/%s' % id),
            subject="scripts-vhosts CNAME request: %s" % short,
            body="""Hi accounts-internal,

At your convenience, please make %(short)s an alias of scripts-vhosts.

stella scripts-vhosts -a %(short)s

Thanks!
-%(first)s
SIPB Scripts Team

/set status=stalled
""" % dict(short=short, first=auth.first_name()),
            help_text_html=
            "<p>Make sure the host name is not being used:</p><pre>$ stella %s\n%s\n%s</pre><p>If it's DELETED, you need to forward explicit confirmation that it's OK to reuse (from owner/contact/billing contact, or rccsuper for dorms, or a FSILG's net contact, or similar).</p>"
            % (cgi.escape(t.hostname), cgi.escape(out), cgi.escape(err)),
            extra_buttons={
                'silent': 'Approve without mailing accounts-internal'
            })

    @expose('scriptspony.templates.message')
    @scripts_team_only
    def reject(self, id, subject=None, body=None, token=None, silent=False):
        t = queue.Ticket.get(int(id))
        if t.state != 'open':
            flash("This ticket's not open!")
            redirect('/ticket/%s' % id)
        if t.rtid is None: