예제 #1
0
파일: fair.py 프로젝트: urnest/bckindycal
def adjustFairDetails(page):
    data=getFairDetails()
    page.find(pq.tagName('input')).filter(pq.hasClass('fair-date-and-time')).attr('value',str(data.date_and_time))
    page.find(pq.tagName('span')).filter(pq.hasClass('fair-date-and-time')).text(str(data.date_and_time))
    page.find(pq.tagName('input')).filter(pq.hasClass('fair-email')).attr('value',str(data.email))
    page.find(pq.tagName('a')).filter(pq.hasClass('fair-email')).text(str(data.email)).attr('href','mailto:'+str(data.email))
    page.find(pq.tagName('div')).filter(pq.hasClass('fair-message')).html(
        pq.parse(data.message))
    return page
예제 #2
0
 def __init__(self, server, staff_password):
     "login in to %(server)s/staff using password %(staff_password)s"
     try:
         self.c = httplib.HTTPConnection(server)
         self.c.set_debuglevel(1)
         self.c.request("GET", "/staff_login.html")
         r = self.c.getresponse()
         page = pq.parse(r.read())
         assert len(page.find(tagName("input")).filter(attrEquals("name", "password"))), (
             r,
             r.getheaders(),
             unicode(page),
         )
         params = urllib.urlencode({"password": staff_password})
         self.c.request("POST", "/staff_login.html", params)
         r = self.c.getresponse()
         assert r.status == 302, (r.status, r.read())
         content = r.read()
         self.session = getSession(r.getheader("Set-Cookie"))
         assert not self.session is None, self.getheaders()
         self.headers = {"Cookie": "kc-session=%s" % self.session}
         assert r.getheader("location") == "http://" + server + "/events.html", repr((r, r.getheaders(), content))
     except:
         raise inContext(l1(Staff.__init__.__doc__) % vars())
     pass
예제 #3
0
파일: fair.py 프로젝트: urnest/bckindycal
def cell(names,phones,emails,i,hour,stall_name):
    'get name phone and email of ith person in list of names'
    '- return '' if there are less than i names in list'
    if i < len(names):
        name=str(names[i])
        contact=[]
        if i < len(phones) and len(phones[i]): contact.append(str(phones[i]))
        if i < len(emails) and len(emails[i]): contact.append(str(emails[i]))
        if len(contact):
            contact=' ('+', '.join(contact)+')'
        else:
            contact=''
            pass
        
        result=pq.parse(non_empty_cell%vars())
        inputs=result.find(pq.tagName('input'))
        inputs.filter(pq.hasClass('helper-number')).attr('value',str(i))
        inputs.filter(pq.hasClass('hour')).attr('value',str(hour))
        inputs.filter(pq.hasClass('stall-name')).attr('value',stall_name)
        return unicode(result).encode('utf-8')
    return empty_cell