def GET(self, cid): if logged(): cname = model.get_item(alltable['class'], int(cid))['cname'] render = create_render(session.privilege) return render.approve(cid, cname) else: raise web.seeother('/')
def GET(self, cid, pid): teachers = model.get_items(alltable['teacher']) classrooms = list(model.get_items(alltable['classroom'])) table = alltable['class'] item = model.get_item(table, int(cid)) render = create_render(session.privilege) return render.copy_class(teachers, item, pid, classrooms)
def get(self, url=None): sitename = get_item(name='sitename', value='wmallcn') import oldsitedefault as config config.SITE = 'http://phpven.com'#'http://www.%s.com' % sitename.value config.REPLACE = (('/pic/', 'http://littlefox010.appspot.com/pic/',),) config.funcs = [] config.REDIRECTURL = None self.copy_get(url, config)
def GET(self, tablename, itemid): if logged(): table = alltable[tablename] item = model.get_item(table, int(itemid)) render = create_render(session.privilege) return render.edit_item(table, talbe_c_name, item) else: raise web.seeother('/')
def get(self, url=None): item = get_item(name='type') if item.value == 'default': url = get_url(self.request) return self._redirect(url) elif item.value == 'piccache': self.cachePic(url) elif item.value == 'site': sitename = get_item(name='sitename', value='wmallcn') import oldsitedefault as config config.SITE = 'http://www.%s.com' % sitename.value #config.REPLACE = (('/pic/', 'http://littlefox010.appspot.com/pic/',),) config.funcs = [] self.copy_get(url, config) else: config = __import__(item.value) self.copy_get(url, config)
def GET(self, item_id): if not session.admin: authorization_error() item = model.get_item(int(item_id)) post = model.get_post(item.helpRequestId) if not model.authorized_user(session.userId, post.contactId): authorization_error() return render.deleteitem(post, item)
def GET(self): if model.current_id(): table = alltable['user'] user = model.get_item(table, model.current_id()) return render.index(user, datetime.datetime.now().strftime('%Y-%m')) else: return render.login()
def GET(self, pid): if logged(): table = alltable['project'] project = model.get_item(table, int(pid)) render = create_render(session.privilege) return render.edit_project(project) else: raise web.seeother('/')
def POST(self, item_id): if not session.admin: authorization_error() item_data = model.get_item(int(item_id)) post = model.get_post(item_data.helpRequestId) if not model.authorized_user(session.userId, post.contactId): authorization_error() post_id = model.del_help_item(int(item_id)) raise web.seeother('/view/%d' % item_data.helpRequestId)
def GET(self, item_id=None): if item_id is None: raise web.seeother('/') self.bid.d.itemID = item_id item = model.get_item(int(item_id)) if item is None: raise web.seeother('/') web.setcookie('item_id', item.id) return render.bid(item, self.bid)
def GET(self, cid, pid): if logged(): teachers = model.get_items(alltable['teacher']) classrooms = list(model.get_items(alltable['classroom'])) item = model.get_item(alltable['class'], int(cid)) render = create_render(session.privilege) return render.edit_class(teachers, item, pid, classrooms) else: raise web.seeother('/')
def GET(self, id): if not session.admin: authorization_error() item = model.get_item(int(id)) post = model.get_post(item.helpRequestId) if not model.authorized_user(session.userId, post.contactId): authorization_error() form = self.form() form.fill(item) return render.edititem(post, item, form)
def POST(self, cid): if logged(): form = web.input() form['mid'] = session.uid model.update_class_approve(form['cid'], form['mid'], form['approve']) date = model.get_item(alltable['class'], int(cid))['begindate'] raise web.seeother('/approve_class/' + date.strftime('%Y-%m')) else: raise web.seeother('/')
def GET(self, id): item = model.get_item(int(id)) #TODO: should error checking like this be done elsewhere? if not item: # Requested item doesn't exist raise web.seeother('/') if item.helpName: # Someone has already signed up for this item raise web.seeother('/error/item_help_provided?req_id=%d' % int(item.helpRequestId)) post = model.get_post(item.helpRequestId) form = self.form() return render.helpsignup(post, item, form)
def GET(self,cid): c = model.get_item(alltable['class'],cid) begin = c['begindate'].day+1/2*c['begintime'] end = c['enddate'].day+1/2*c['endtime'] year = c['begindate'].year month = c['begindate'].month whl = 'where (DAYOFMONTH(begindate)+1/2*begintime between '+str(begin)+' and '+str(end)+\ ' or DAYOFMONTH(enddate)+1/2*begintime between '+str(begin)+' and '+str(end)+\ ') and MONTH(begindate)='+str(month)+' and YEAR(begindate)='+str(year)+' and approve=\'未审批\'' classes = model.get_classes(whl) return render.conflict_class(classes)
def get(self, url=None): sitename = get_item(name='sitename', value='wmallcn') import oldsitedefault as config config.SITE = 'http://phpven.com' #'http://www.%s.com' % sitename.value config.REPLACE = (( '/pic/', 'http://littlefox010.appspot.com/pic/', ), ) config.funcs = [] config.REDIRECTURL = None self.copy_get(url, config)
def get(self): item = get_item('type') if item.value == 'site': from oldsitedefault import NOURL, NOTREPLACEEXT, REDIRECTURL else: try: config = __import__(item.value) except ImportError: msg = 'not a site' s = str(globals()) + str(locals()) self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(s)
def copy_get(self, url, config): if url == 'flushcache': memcache.flush_all() self.response.out.write('cache clear') return if url.endswith('.html'): for k, v in VERIFI_DICT.items(): if url.startswith(k): key = getIn(url, k, '.html') res = v.replace('{key}', key) self.response.out.write(res) return if hasattr(config, 'NOTURL') and url in config.NOTURL: gourl = config.SITE else: gourl = '%s/%s' % (config.SITE, url) if self.request.query_string: gourl = '%s?%s' % (gourl, self.request.query_string) REDIRECTURL = getattr(config, 'REDIRECTURL', None) if url and REDIRECTURL and (url in REDIRECTURL or (REDIRECTURL == '*' and url[-4:] in ( '.php', '.asp', 'html', ))): self.set_status(301) self.response.headers['Location'] = str(gourl) return item = get_item(name='open_post', value='0') if item.value == '1': origPostData = self.request.body else: origPostData = None page = memcache.get(gourl) if page is None or origPostData is not None: page = self.fetchurl(gourl, origPostData) ext = url.rsplit('\\.', 1)[-1].lower() if ext not in ['gif', 'jpg', 'png', 'bmp']: for k, v in config.REPLACE: page.content = page.content.replace(k, v) for func in config.funcs: if callable(func): page.content = func(page.content) if len(page.content) < 500000 and origPostData is None: memcache.set(gourl, page, 864000) self.set_status(page.status_code) self.setHeader(page) self.response.out.write(page.content)
def sendConfirmationEmail(item_id): # don't even attempt if email config info has not been provided if not web.config.smtp_username: print("WARNING: email user/password not configured. Ignoring attempt to send confirmation email.") return item = model.get_item(int(item_id)) # Get contact info for the help item post_data = model.get_post(int(item.helpRequestId)) contact_data = model.get_contact_data(post_data.contactId) item.contactName = contact_data.name item.contactEmail = contact_data.email item.contactPhone = contact_data.phone item.url = "%s/view/%s" % (config.SITE_BASE, item.helpRequestId) item.date = utils.convert_date(item.date) if item.helpEmail: f = web.config.smtp_username to = item.helpEmail cc = item.contactEmail subject = 'Confirmation: you signed up to help on %(date)s' % item msg = """Thanks for you willingness to help. This email is to confirm that you signed up to help on %(date)s for the item "%(description)s". More details can be found here: %(url)s If you have any questions don't reply to this email. Instead contact %(contactName)s email: %(contactEmail)s phone: %(contactPhone)s Thanks!""" % item #print f, to, subject, msg web.sendmail(f,to,subject,msg,cc=cc) else: # The person did not provide an email. Instead an email will be sent # to the contact person informing them of the situation. f = web.config.smtp_username to = item.contactEmail subject = 'Confirmation: Helper with no email' msg = """%(helpName)s signed up to help on %(date)s for item "%(description)s" but did not provide an email address. Since no email is present, the website will be unable to provide them an automatic reminder. Details can be found here: %(url)s """ % item #print f, to, subject, msg web.sendmail(f,to,subject,msg)
def sendConfirmationEmail(item_id): # don't even attempt if email config info has not been provided if not web.config.smtp_username: print "WARNING: email user/password not configured. Ignoring attempt to send confirmation email." return item = model.get_item(int(item_id)) # Get contact info for the help item post_data = model.get_post(int(item.helpRequestId)) contact_data = model.get_contact_data(post_data.contactId) item.contactName = contact_data.name item.contactEmail = contact_data.email item.contactPhone = contact_data.phone item.url = "%s/view/%s" % (config.SITE_BASE, item.helpRequestId) item.date = utils.convert_date(item.date) if item.helpEmail: f = web.config.smtp_username to = item.helpEmail cc = item.contactEmail subject = 'Confirmation: you signed up to help on %(date)s' % item msg = """Thanks for you willingness to help. This email is to confirm that you signed up to help on %(date)s for the item "%(description)s". More details can be found here: %(url)s If you have any questions don't reply to this email. Instead contact %(contactName)s email: %(contactEmail)s phone: %(contactPhone)s Thanks!""" % item #print f, to, subject, msg web.sendmail(f,to,subject,msg,cc=cc) else: # The person did not provide an email. Instead an email will be sent # to the contact person informing them of the situation. f = web.config.smtp_username to = item.contactEmail subject = 'Confirmation: Helper with no email' msg = """%(helpName)s signed up to help on %(date)s for item "%(description)s" but did not provide an email address. Since no email is present, the website will be unable to provide them an automatic reminder. Details can be found here: %(url)s """ % item #print f, to, subject, msg web.sendmail(f,to,subject,msg)
def POST(self, id): form = self.form() item = model.get_item(int(id)) if not item: # Requested item doesn't exist raise web.seeother('/') if item.helpName: # Someone has already signed up for this item raise web.seeother('/error/item_help_provided?req_id=%d' % int(item.helpRequestId)) if not form.validates(): post = model.get_post(item.helpRequestId) return render.helpsignup(post, item, form) model.update_help_item(int(id), item.date, item.description, form.d.helpName, form.d.helpEmail, form.d.helpPhone) emailconfirm.sendConfirmationEmail(int(id)) raise web.seeother('/helpconfirm/%d' % item.id)
def POST(self, cid, pid): if logged(): c = model.get_item(alltable['class'], int(cid)) if c['approve'] == u'未审批': model.del_item(alltable['class'], int(cid)) if pid == '': raise web.seeother('/index_class/') else: raise web.seeother('/index_class_project/' + pid) else: render = create_render(0) return render.error('细项已审批,不能删除!') else: raise web.seeother('/')
def POST(self, id): if not session.admin: authorization_error() #TODO: take care of display issue with details (textarea data) form = self.form() item = model.get_item(int(id)) post = model.get_post(item.helpRequestId) if not model.authorized_user(session.userId, post.contactId): authorization_error() if not form.validates(): return render.edititem(post, item, form) model.update_help_item(int(id), utils.standardize_date(form.d.date), form.d.description, form.d.helpName, form.d.helpEmail, form.d.helpPhone) raise web.seeother('/view/%d' % item.helpRequestId)
def copy_get(self, url, config): if url == 'flushcache': memcache.flush_all() self.response.out.write('cache clear') return if url.endswith('.html'): for k, v in VERIFI_DICT.items(): if url.startswith(k): key = getIn(url, k, '.html') res = v.replace('{key}', key) self.response.out.write(res) return if hasattr(config, 'NOTURL') and url in config.NOTURL: gourl = config.SITE else: gourl = '%s/%s' % (config.SITE, url) if self.request.query_string: gourl = '%s?%s' % (gourl, self.request.query_string) REDIRECTURL = getattr(config, 'REDIRECTURL', None) if url and REDIRECTURL and (url in REDIRECTURL or (REDIRECTURL == '*' and url[-4:] in ('.php', '.asp', 'html',))): self.set_status(301) self.response.headers['Location'] = str(gourl) return item = get_item(name='open_post', value='0') if item.value == '1': origPostData = self.request.body else: origPostData = None page = memcache.get(gourl) if page is None or origPostData is not None: page = self.fetchurl(gourl, origPostData) ext = url.rsplit('\\.', 1)[-1].lower() if ext not in ['gif', 'jpg', 'png', 'bmp']: for k,v in config.REPLACE: page.content = page.content.replace(k,v) for func in config.funcs: if callable(func): page.content = func(page.content) if len(page.content) < 500000 and origPostData is None: memcache.set(gourl, page, 864000) self.set_status(page.status_code) self.setHeader(page) self.response.out.write(page.content)
def get(self, url=None): item = get_item('clickbank', '0') item.value = str(int(item.value) + 1) item.put() target_url = 'http://%s.hop.clickbank.net/' % url res = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Yisec-One Second To Eary Money</title> </head> <body style="margin:0px;background-color:#fff;" bgcolor="#ffffff"> %s <iframe id="iF" src="%s" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" frameborder="0" height="100%%" scrolling="yes" width="100%%" style="overflow:auto;background-color:#fff"></iframe> </body> </html> """ % (google_analytics, target_url) self.response.out.write(res)
def GET(self, cid): c = model.get_classes('where cid=' + cid)[0] begin = c['begindate'].day + 1 / 2 * c['begintime'] end = c['enddate'].day + 1 / 2 * c['endtime'] year = c['begindate'].year month = c['begindate'].month place = c['place'] classroom = c['classroom'] wh = 'where (DAYOFMONTH(begindate)+1/2*begintime between '+str(begin)+' and '+str(end)\ +' or DAYOFMONTH(enddate)+1/2*endtime between '+str(begin)+' and '+str(end)\ +' or (DAYOFMONTH(begindate)+1/2*begintime<'+str(begin)+' and DAYOFMONTH(enddate)+1/2*endtime>'+str(end)+'))'\ +' and MONTH(begindate)='+str(month)+' and YEAR(begindate)='+str(year)\ +' and classroom.place=\''+place+'\''+' and classroom.classroom=\''+classroom+'\''\ +' and approve!=\''+'不通过'.decode('utf-8')+'\''+' order by begindate' classes = list(model.get_classes(wh)) date = classes[0]['begindate'].strftime('%Y-%m') uid = int(model.current_id()) user_type = model.get_item(alltable['user'], uid)['usertype'] return render.conflict_class(classes, date, cid, user_type)
def POST(self): item_id = web.cookies().get('item_id') item = model.get_item(int(item_id)) if item.open == 0: raise web.seeother('/view/' + item_id) highest_bid = model.get_highest_bid(item_id) buy_price = item.price if highest_bid is not None: self.bid.validators.append( form.Validator("Price must be higher than highest bid (" + str(highest_bid.price) + " by " + highest_bid.buyer + ")", lambda i: float(i.price) > highest_bid.price)) self.bid.validators.append( form.Validator("Price higher than item's buy price (" + str(buy_price) + ")", lambda i: float(i.price) <= buy_price)) if not self.bid.validates(): return render.bid(item, self.bid) else: model.new_bid(item_id, self.bid.d.buyer, self.bid.d.price) raise web.seeother('/view/' + item_id)
def get_url(request): if len(DOMAIN_SITE) == 0: return None host = request.environ['SERVER_NAME'] for k, v in DOMAIN_SITE.items(): if host.endswith(k): return v if host.endswith('appspot.com'): for k, v in DOMAIN_SITE.items(): if host.startswith(k): return v allurls = get_item('allurls') if allurls.value == 'default': allurls = DOMAIN_SITE.values() else: allurls = allurls.value.split(';') allurls = list(set(allurls)) url = allurls[randint(0, len(allurls)-1)] return url
def get_url(request): if len(DOMAIN_SITE) == 0: return None host = request.environ['SERVER_NAME'] for k, v in DOMAIN_SITE.items(): if host.endswith(k): return v if host.endswith('appspot.com'): for k, v in DOMAIN_SITE.items(): if host.startswith(k): return v allurls = get_item('allurls') if allurls.value == 'default': allurls = DOMAIN_SITE.values() else: allurls = allurls.value.split(';') allurls = list(set(allurls)) url = allurls[randint(0, len(allurls) - 1)] return url
def GET(self,cid,pid): managers = model.get_items(alltable['manager']) cname=model.get_item(alltable['class'],int(cid))['cname'] return render.approve(managers,cid,cname,pid)
def GET(self, id): item = model.get_item(int(id)) if item is not None: return render.view(item) else: raise web.seeother('/')
def GET(self,cid): table=alltable['class'] item = model.get_item(table,int(cid)) return render.view_class(table,item)
def GET(self,cid,pid): teachers = model.get_items(alltable['teacher']) classrooms = list(model.get_items(alltable['classroom'])) table=alltable['class'] item = model.get_item(table,int(cid)) return render.edit_class(table,teachers,item,pid,classrooms)
def GET(self,pid): table=alltable['project'] item = model.get_item(table,int(pid)) return render.view_project(table,item)
def GET(self,pid): organizers = model.get_items(alltable['organizer']) table=alltable['project'] item = model.get_item(table,int(pid)) return render.edit_project(table,item,organizers)
def GET(self, pid): organizers = model.get_items(alltable['organizer']) project = model.get_item(alltable['project'], int(pid)) pname = project['pname'] return render.apply(organizers, pid, pname)
def save_config(self, config_json): item = model.get_item('config_json') item.value = config_json item.put()
def get_config_url(self): item = model.get_item('config_url', default_config_url) return item.value
def get_config_json(self): item = model.get_item('config_json') return json.loads(item.value)
def GET(self,tablename,itemid): table=alltable[tablename] """ View single item """ item = model.get_item(table,int(itemid)) return render.view(table,item)
def GET(self,tablename,itemid): table=alltable[tablename] item = model.get_item(table,int(itemid)) return render.edit(table,item)
def GET(self, id): item = model.get_item(int(id)) if not item: # Requested item doesn't exist raise web.seeother('/') return render.helpconfirm(item)