Exemplo n.º 1
0
def get_default(x=None):
    default = dict()
    agent_values = simpledetect(request.user_agent)
    default["Request"] = dict (clientinfo = agent_values)
    try:
        reporterinfo = dict( zip(("fname", "lname", "location", "email"), base64.b64decode(request.cookies['uinfo']).split("|")))
        reporterinfo["reporter"] = "%(fname)s %(lname)s" % reporterinfo
        default["Request"]["reporterinfo"] = reporterinfo
        lhs = "%(fname)s.%(lname)s" % reporterinfo
        location_from_cookie = reporterinfo["location"]
        location_lc = reporterinfo["location"].lower()
        mailreq = dict (
                lhs = lhs.lower(),
                maillogin = lhs.lower(),
                publhs = default["Request"]["reporterinfo"]["location"].lower() + ".TOPIC",
                listlhs = default["Request"]["reporterinfo"]["location"].lower() + ".TOPIC",
                mldescr = "Hub %(location)s TOPIC mailing list" % reporterinfo,
                mladmin = "*****@*****.**" % location_lc,
                mlqueries = "*****@*****.**" % location_lc,
                mlsubjectprefix = "[Hub %s TOPIC]" % reporterinfo["location"])
        default["Request"]["mailreq"] = mailreq
        if location_from_cookie in locations.values():
            default["Request"]["reporterinfo"]["location"] = [location for location in locations if location_from_cookie == locations[location]][0]
        if x: return mailreq # kind of ugly but quick
    except Exception, err:
        print err
Exemplo n.º 2
0
                MailRequest("mailreq", get_default=get_default),
                mailreqrepeater,
                ClientInfo("clientinfo"),
                moredetails,
                ]

class TicketForm(twf.ListForm, twd.HidingTableForm):
    submit_text = "Create A Ticket"
    show_children_errors = False
    children = [
        MainFieldSet("Request", suppress_label=True),
        twf.Label("saythanks", help_text="After submitting this form you should receive an update on your ticket by e-mail shortly.  Thanks for letting us know!"),
            ]

class MHPSTicketForm(twf.ListForm):

    suppress_label = True
    submit_text = "Create Ticket"
    show_children_errors = False

    children = [
        MHPSReporterInfo("reporterinfo"),
        MHPSClientInfo("clientinfo"),
        moredetails,
        twf.Spacer("space", suppress_label=True),
        twf.Label("saythanks", help_text="After submitting this form you should receive an update on your ticket by e-mail shortly.  Thanks for letting us know!"),
        ]

ticketform = TicketForm("create_ticket_form", action="create", get_default=get_default)#, validator=ticketschema)
mhpsticketform = MHPSTicketForm("create_ticket_form", action="create", get_default= lambda: dict (clientinfo = simpledetect(request.user_agent)))