def getGrid(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() prevMo = getPrevMonth(Y, M) prevMoLWk = prevMo[-1] thisMo = getThisMonth(Y, M) nextMo = getNextMonth(Y, M) nextMoFWk = nextMo[0] DEX = 0 for day in thisMo[0]: # first week of the month if not day: thisMo[0][DEX] = prevMoLWk[DEX] DEX += 1 DEX = 0 for day in thisMo[-1]: # last week of the month if not day: thisMo[-1][DEX] = nextMoFWk[DEX] DEX += 1 return thisMo
def writeContent(self): wr = self.writeln IS_SITE_ADMIN = is_site_admin(self.request()) wr('<h1>%s</h1>' % (self.title())) if self.request()._environ.get('REQUEST_METHOD') == 'POST': ERROR = None form = self.request().fields() wr(form) fobj = form.get('datafile') try: filename = fobj.filename except: ERROR = 'You must select a file to upload.' if ERROR: self.render_form_error('Constitution Upload Error', ERROR) else: save_constitution(form) self.response().sendRedirect('Constitution') else: ci = get_constitution_info() if ci: # effdate = '/'.join(ci.get('date', [])) effdate = ci.get('date', '') filename = ci.get('datafile', '') msg = ci.get('message', '') fileurl = os.path.join(DOC_CONST_DIR.replace(BASEDIR, ''), filename) wr('<p>Here\'s where you\'ll find the latest version of the ACVAA Constitution and Bylaws. Please click the link below to download it to your computer.</p>') wr('<h3><a href="%s">%s</a></h3>' % (fileurl, filename)) wr('<p style="font-weight: bold;">Effective date: %s</p>' % (effdate)) if msg: wr('<p>%s</p>' % (msg)) else: wr('<p>There is no ACVAA Constitution document available at this time.</p>') if IS_SITE_ADMIN: wr('<hr>') wr('<h2>Upload Constitution Document</h2>') wr('<form name="chooseDateForm" id="chooseDateForm" action="Constitution" method="POST" enctype="multipart/form-data">') YR, MO, DY = getYMD() wr('<P>') wr('<b>Effective Date of Constitution</b>') wr('<br />') wr('Date: <input type="text" id="datepicker" name="date">') # self.render_date_picker (YR, MO, DY) wr('</P>') wr('<P>') wr('<b>Message</b> (optional)') wr('<br />') wr('<textarea name="message" rows="5" cols="40"></textarea>') wr('</P>') wr('<P>') wr('<b>Upload Document</b>') wr('<br />') wr('<input type="file" name="datafile">') wr('</P>') wr('<P>') wr('<input type="submit" value="Save & Upload Constitution">') wr('</P>') wr('</form>')
def writeContent(self): wr = self.writeln IS_SITE_ADMIN = is_site_admin(self.request()) wr('<h1>%s</h1>' % (self.title())) if self.request()._environ.get('REQUEST_METHOD') == 'POST': ERROR = None form = self.request().fields() wr(form) fobj = form.get('datafile') try: filename = fobj.filename except: ERROR = 'You must select a file to upload.' if ERROR: self.render_form_error('Constitution Upload Error', ERROR) else: save_constitution(form) self.response().sendRedirect('Constitution') else: ci = get_constitution_info() if ci: effdate = '/'.join(ci.get('date', [])) filename = ci.get('datafile', '') msg = ci.get('message', '') fileurl = os.path.join(DOC_CONST_DIR.replace(BASEDIR, ''), filename) wr('<p>Here\'s where you\'ll find the latest version of the ACVAA Constitution and Bylaws. Please click the link below to download it to your computer.</p>') wr('<h3><a href="%s">%s</a></h3>' % (fileurl, filename)) wr('<p style="font-weight: bold;">Effective date: %s</p>' % (effdate)) if msg: wr('<p>%s</p>' % (msg)) else: wr('<p>There is no ACVAA Constitution document available at this time.</p>') if IS_SITE_ADMIN: wr('<hr>') wr('<h2>Upload Constitution Document</h2>') wr('<form name="chooseDateForm" id="chooseDateForm" action="Constitution" method="POST" enctype="multipart/form-data">') YR, MO, DY = getYMD() wr('<P>') wr('<b>Effective Date of Constitution</b>') wr('<br />') wr('Date: <input type="text" id="datepicker" name="date">') # self.render_date_picker (YR, MO, DY) wr('</P>') wr('<P>') wr('<b>Message</b> (optional)') wr('<br />') wr('<textarea name="message" rows="5" cols="40"></textarea>') wr('</P>') wr('<P>') wr('<b>Upload Document</b>') wr('<br />') wr('<input type="file" name="datafile">') wr('</P>') wr('<P>') wr('<input type="submit" value="Save & Upload Constitution">') wr('</P>') wr('</form>')
def getNextMonth(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() nY, nM = Y, M + 1 if M == 12: nY, nM = Y + 1, 1 return convertGrid(nY, nM, calendar.monthcalendar(nY, nM))
def getThisMonth(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() return convertGrid(Y, M, calendar.monthcalendar(Y,M))
def getPrevMonth(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() lY, lM = Y, M - 1 if M == 1: lY, lM = Y-1, 12 return convertGrid(lY, lM, calendar.monthcalendar(lY, lM))
def getThisMonth(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() return convertGrid(Y, M, calendar.monthcalendar(Y, M))
def getPrevMonth(Y=None, M=None): if not Y or not M: Y, M, D = getYMD() lY, lM = Y, M - 1 if M == 1: lY, lM = Y - 1, 12 return convertGrid(lY, lM, calendar.monthcalendar(lY, lM))