Ejemplo n.º 1
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
def makeRosterContent(stall_name):
    print 'prefs'
    prefs=getPrefs(stall_name)
    helpers_required=fromJson(prefs.helpers_required)
    result=stall_page_head
    helpers_by_hour=[(hour,int(helpers_required.get(str(hour),default_helpers_required(hour)))) for hour in range(8,21)]
    table_cols=2+max([_[1] for _ in helpers_by_hour])
    while len(helpers_by_hour) and helpers_by_hour[-1][1]==0:
        helpers_by_hour=helpers_by_hour[0:-1]
        pass
    for hour, max_helpers in helpers_by_hour:
        # get OneHourOfHelp object for specified hour from datastore
        entry_query = OneHourOfHelp.query(OneHourOfHelp.hour == hour, ancestor=stall_key(stall_name))
        entries = entry_query.fetch(1)
        names=[]
        phones=[]
        emails=[]
        if len(entries):
            names=entries[0].names
            phones=entries[0].phones
            emails=entries[0].emails
            pass
        if max_helpers>0:
            result=result+makeRow(table_cols,
                                  stall_name,
                                  hour, 
                                  names,
                                  phones,
                                  emails,
                                  max_helpers,
                                  prefs.ask_for_email,
                                  prefs.ask_for_phone)
            pass
        pass
    result=result+stall_page_tail    
    content=pq.parse(result,'StallPage')
    #lop off empty table columns
    helper_table=content.find(hasClass('helper_table'))
    helper_table.find(hasClass("top-spacer"))\
                .attr('colspan',str(table_cols))
    ths=helper_table.find(hasClass('helper-th'))
    ths[table_cols-2:].remove()
    #suppress roster table and heading etc if there are no rows
    if len(helpers_by_hour)==0:
        content.find(hasClass('kindycal-py-roster-el')).remove()
    else:
        content.find(hasClass('kindycal-py-noroster-el')).addClass('kc-display-none')
        pass
    content.find(hasClass('stall_name')).text(getStalls()[stall_name]['name'])
    content.find(hasClass('stall_image')).attr('src','fair_images/roster-%(stall_name)s.jpg'%vars())
    content.find(hasClass('roster_instructions')).text(
        prefs.roster_instructions)
    return content
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def errorPage(msg):
    result=headerror+\
        ('''ERROR: %s<br/><br/>(Use browser Back button to return to page)</td></tr></div>'''%encodeEntities(msg))+\
        tailerror
    page=pq.parse(result,'errorPage')
    return str(page)