def writeContent(self): wr = self.writeln catdict = get_rtc_categories() mapdict = get_rtc_name_map() wr('<h1>%s</h1>' % (self.title())) if catdict and mapdict: wr('<h2>Add a Training Resource</h2>') wr('<form action="Resource_Add" method="POST" enctype="multipart/form-data"><table>') catnames = mapdict.values() catnames.sort() wr('<tr><td>Category:<td>') wr(select('category', catnames)) wr('<td class="req">required') wr('<tr><td>Title:<td>') wr(text('title')) wr('<td class="req">required') wr('<tr><td colspan="3" class="req">You must either upload a file, or provide a web address for this resource.<br>You can do both.') wr('<tr><td>File Upload:<td><input type="file" name="datafile">') wr('<tr><td>Web Address:<td>%s' % (text('url'))) wr('<tr><td>Description:<td><textarea name="description"></textarea>') wr('<td class="req">optional') wr('<tr><td colspan="3">%s' % (submit('Add Resource'))) wr('</table></form>') else: wr('<P>There are currently no resource categories.</P>') wr('<P>You cannot add a resource without first creating a category for it.</P>') wr('<h2>Resource Categories</h2>') wr('<form action="Category_Add" method="POST">') wr('<b>Add Category</b>:') wr(text('new_category')) wr(submit('Add New Category')) wr('</form>') if catdict and mapdict: catguids = catdict.keys() wr('<P><table>') wr('<tr><th>Category<th>Count<th><th>') for guid in catguids: catname = mapdict.get(guid, '') # Guard against weird characters in URL querystring = urllib.urlencode({'cat':catname}) rezlist = catdict.get(guid, []) rezcount = len(rezlist) wr('<tr><td>%s' % (catname)) wr('<td>%s' % (rezcount)) wr('<td><a href="Category_Edit?%s" title="Edit"><i class="fa fa-pencil"></i></a>' % (querystring)) wr('<td>') if rezcount > 0: pass else: wr('<a href="Category_Delete?%s" title="Delete"><i class="fa fa-trash"></i><a>' % (querystring)) wr('</table></P>')
def writeContent(self): wr = self.writeln qs = self.request().fields() min_id = qs.get('id') wr('<h1>%s</h1>' % (self.title())) if not min_id: wr('<P>You have not selected minutes for a specific date to delete.</P>') else: if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() kill_minutes(form.get('id')) self.response().sendRedirect('Minutes') else: wr('<h3>Are you sure you want to delete the following?</h3>') meet_dict = get_minutes(min_id) M, D, Y = meet_dict.get('date') wr('<P><b>Date</b>:<br />%s %s, %s</P>' % (FMONTHS.get(int(M)), D, Y)) wr('<P><b>Summary</b>:<br /> %s</P>' % (meet_dict.get('summary'))) wr('<P><b>Document</b>:<br /> %s</P>' % (meet_dict.get('datafile'))) wr('<form method="POST" action="Min_Delete_Confirm">') wr(hidden('id', min_id)) wr(submit('Yes, delete.')) wr('<input type="button" value="No, leave everything as it is now." onClick="javascript:history.go(-1)">') wr('</form>')
def writeContent(self): wr = self.writeln qs = self.request().fields() min_id = qs.get('id') wr('<h1>%s</h1>' % (self.title())) if not min_id: wr('<P>You have not selected minutes for a specific date to delete.</P>' ) else: if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() kill_minutes(form.get('id')) self.response().sendRedirect('Minutes') else: wr('<h3>Are you sure you want to delete the following?</h3>') meet_dict = get_minutes(min_id) M, D, Y = meet_dict.get('date') wr('<P><b>Date</b>:<br />%s %s, %s</P>' % (FMONTHS.get(int(M)), D, Y)) wr('<P><b>Summary</b>:<br /> %s</P>' % (meet_dict.get('summary'))) wr('<P><b>Document</b>:<br /> %s</P>' % (meet_dict.get('datafile'))) wr('<form method="POST" action="Min_Delete_Confirm">') wr(hidden('id', min_id)) wr(submit('Yes, delete.')) wr('<input type="button" value="No, leave everything as it is now." onClick="javascript:history.go(-1)">' ) wr('</form>')
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() if form.get('new_name'): ERROR = edit_category(form.get('old_name'), form.get('new_name')) if ERROR: wr('<h1 class="error">That category name does not exist in the database.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: self.response().sendRedirect('Manage') else: wr('<h1 class="error">You must specify a new category name.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: qs = self.request().fields() catname = qs.get('cat') if catname: wr('<h1>Edit Category Name</h1>') wr('<form action="Category_Edit" method="POST">') wr('<P>Change category name from %s to:<br>' % (catname)) wr(hidden('old_name', catname)) wr(text('new_name')) wr('<br>') wr(submit('Edit category.')) wr('<input type="button" value="Never mind. Leave the category alone." onclick="javascript:history.go(-1)">') wr('</form>') else: wr('<h1 class="error">You must specify a category name to delete.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>')
def writeContent(self): wr = self.writeln qs = self.request().fields() if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() if form.get('rm_resource'): ERROR = delete_resource(form.get('rm_resource')) if ERROR: wr('<h1 class="error">That resource ID does not exist in the database.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: self.response().sendRedirect('Index') else: wr('<h1 class="error">You must specify a resource ID to delete.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: wr('<h1>%s</h1>' % (self.title())) qs = self.request().fields() rezid = qs.get('id') if rezid: pick = get_resource_by_id(rezid) wr('<P>Are you sure you want to delete the Resource named: %s?</P>' % (pick.get('title'))) wr('<form action="Resource_Delete" method="POST">') wr(hidden('rm_resource', rezid)) wr(submit('Yes. Delete it.')) wr('<input type="button" value="Never mind. Leave it alone." onclick="javascript:history.go(-1)">') wr('</form>') else: wr('<h1 class="error">You must specify a resource ID to delete.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>')
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() delete_job(form.get('jid')) self.response().sendRedirect('Index') else: qs = self.request().fields() jid = qs.get('jid') if jid: jd = get_job_info(jid) wr('<h1>%s</h1>' % (self.title())) wr('<form method="POST" action="Delete_Job">') wr(hidden('jid', jid)) wr('<p>Are you sure you want to delete this job?</p>') wr('<P>%s</P>' % (jd.get('job_title'))) wr('<input type="button" value="No, leave this job listing alone." onClick="javascript:history.go(-1)">') wr(submit('Yep.')) wr('</form>') else: 'Nothing to do.'
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() delete_job(form.get('jid')) self.response().sendRedirect('Index') else: qs = self.request().fields() jid = qs.get('jid') if jid: jd = get_job_info(jid) wr('<h1>%s</h1>' % (self.title())) wr('<form method="POST" action="Delete_Job">') wr(hidden('jid', jid)) wr('<p>Are you sure you want to delete this job?</p>') wr('<P>%s</P>' % (jd.get('job_title'))) wr('<input type="button" value="No, leave this job listing alone." onClick="javascript:history.go(-1)">' ) wr(submit('Yep.')) wr('</form>') else: 'Nothing to do.'
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() if form.get('rm_category'): ERROR = delete_category(form.get('rm_category')) if ERROR: wr('<h1 class="error">That category name does not exist in the database.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: self.response().sendRedirect('Manage') else: wr('<h1 class="error">You must specify a category name to delete.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: qs = self.request().fields() catname = qs.get('cat') if catname: CATGUID = get_guid_by_name(catname) catdict = get_rtc_categories() rezcount = len(catdict.get(CATGUID, [])) if rezcount > 0: wr('<h1 class="error">Sorry, you can only delete a category with zero Training Resources in it.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>') else: wr('<h1>%s</h1>' % (self.title())) wr('<P>Are you sure you want to delete the Resource Category named: %s?</P>' % (catname)) wr('<form action="Category_Delete" method="POST">') wr(hidden('rm_category', catname)) wr(submit('Yes. Delete it.')) wr('<input type="button" value="Never mind. Leave the categories alone." onclick="javascript:history.go(-1)">') wr('</form>') else: wr('<h1 class="error">You must specify a category name to delete.</h1>') wr('<P>Please <a href="javascript:history.go(-1)">go back</a> & try again.</P>')
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() ERROR, ERROR_TYPE = ck_job_info(form) if ERROR: self.render_form_error(ERROR_TYPE, ERROR) else: save_job(form) self.response().sendRedirect('Index?sv=1') else: qs = self.request().fields() IS_EDIT = JOB_ID = qs.get('jid') jp = {} if IS_EDIT: wr('<h1>Edit Job</h1>') jp = get_job_info(JOB_ID) else: wr('<h1>Add New Job</h1>') wr('<form method="POST" action="Job_Form">') if JOB_ID: wr(hidden('id', JOB_ID)) # ------------------------------------------------------ wr('<h2>Provide Details about the Job</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Category</b><br />') wr(select(name='category', opts=JOB_CATS, selected=jp.get('category'), clss='input')) wr('<span class="req">required</span>') wr('</div>') today = time.localtime(time.time()) tdyD, tdyM, tdyY = today.tm_mday, today.tm_mon, today.tm_year tdL = [tdyM, tdyD, tdyY] wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Expiration Date</b><br />') expm, expd, expy = int(jp.get('expires', tdL)[0]), int(jp.get('expires', tdL)[1]), int(jp.get('expires', tdL)[2]) self.render_date_picker(expy, expm, expd, dname="expires") wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Job Title</b><br />') wr(text('job_title', value=jp.get('job_title', ''), clss='input')) wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Institution/Organization</b><br />') wr(text('job_inst', value=jp.get('job_inst', ''), clss='input')) wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Department</b><br />') wr(text('job_dept', value=jp.get('job_dept', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Job Description</b> <span class="req">required</span><br />') wr('<textarea name="description" class="input" cols="72" rows="6">%s</textarea>' % (jp.get('description', ''))) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('Would you like to include a link to another website?') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Text to be Linked</b><br />') wr(text('web_link_text', value=jp.get('web_link_text', ''), clss='input')) wr('<small>e.g., visit our website for more information</small>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Link Address</b><br />') wr(text('web_link_url', value=jp.get('web_link_url', ''), clss='input')) wr('<small>e.g., http://www.example.com/job_listing</small>') wr('</div>') # ------------------------------------------------------ wr('<h2>C.V. Submission</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('Where and how should prospective job candidates submit their information for consideration?') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Instructions</b><br />') wr('<textarea name="cv_instructions" class="input" cols="72" rows="4">%s</textarea>' % (jp.get('cv_instructions', ''))) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Contact Name</b><br />') wr(text('cv_name', value=jp.get('cv_name', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Title</b><br />') wr(text('cv_title', value=jp.get('cv_title', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Address</b><br />') wr(text('cv_addr1', value=jp.get('cv_addr1', ''), clss='input')) wr('<br />') wr(text('cv_addr2', value=jp.get('cv_addr2', ''), clss='input')) wr('<br />') wr(text('cv_addr3', value=jp.get('cv_addr3', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>City, State, ZIP</b><br />') wr(text('cv_city', value=jp.get('cv_city', ''), clss='input')) wr(text('cv_state', value=jp.get('cv_state', ''), clss='input', size='3')) wr(text('cv_zip', value=jp.get('cv_zip', ''), clss='input', size='9')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Country</b><br />') wr(text('cv_country', value=jp.get('cv_country', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Email</b><br />') wr(text('cv_email', value=jp.get('cv_email', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Phone</b><br />') wr(text('cv_phone', value=jp.get('cv_phone', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Fax</b><br />') wr(text('cv_fax', value=jp.get('cv_fax', ''), clss='input')) wr('</div>') # ------------------------------------------------------ wr('<h2>Contacts (optional)</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<em>This is different from where candidates will send their CVs.</em> If the candidate has questions about this job listing, who should they contact and how?') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<table><tr><td>') wr('<table><tr><th colspan="2">Contact 1') wr('<tr><td>Name') wr('<td>%s' % (text('contact1_name', value=jp.get('contact1_name', ''), clss='input'))) wr('<tr><td>Email') wr('<td>%s' % (text('contact1_email', value=jp.get('contact1_email', ''), clss='input'))) wr('<tr><td>Phone') wr('<td>%s' % (text('contact1_phone', value=jp.get('contact1_phone', ''), clss='input'))) wr('</table>') wr('<td>') wr('<table><tr><th colspan="2">Contact 2') wr('<tr><td>Name') wr('<td>%s' % (text('contact2_name', value=jp.get('contact2_name', ''), clss='input'))) wr('<tr><td>Email') wr('<td>%s' % (text('contact2_email', value=jp.get('contact2_email', ''), clss='input'))) wr('<tr><td>Phone') wr('<td>%s' % (text('contact2_phone', value=jp.get('contact2_phone', ''), clss='input'))) wr('</table>') wr('</table></div>') # ------------------------------------------------------ wr('<div style="margin: 21px 0px 7px 0px;">') wr(submit('Save & Post Job Info')) wr('</div>') wr('</form>')
def writeContent(self): wr = self.writeln if self.request()._environ.get('REQUEST_METHOD') == 'POST': form = self.request().fields() ERROR, ERROR_TYPE = ck_job_info(form) if ERROR: self.render_form_error(ERROR_TYPE, ERROR) else: save_job(form) self.response().sendRedirect('Index?sv=1') else: qs = self.request().fields() IS_EDIT = JOB_ID = qs.get('jid') jp = {} if IS_EDIT: wr('<h1>Edit Job</h1>') jp = get_job_info(JOB_ID) else: wr('<h1>Add New Job</h1>') wr('<form method="POST" action="Job_Form">') if JOB_ID: wr(hidden('id', JOB_ID)) # ------------------------------------------------------ wr('<h2>Provide Details about the Job</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Category</b><br />') wr( select(name='category', opts=JOB_CATS, selected=jp.get('category'), clss='input')) wr('<span class="req">required</span>') wr('</div>') today = time.localtime(time.time()) tdyD, tdyM, tdyY = today.tm_mday, today.tm_mon, today.tm_year tdL = [tdyM, tdyD, tdyY] wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Expiration Date</b><br />') expm, expd, expy = int(jp.get('expires', tdL)[0]), int( jp.get('expires', tdL)[1]), int(jp.get('expires', tdL)[2]) self.render_date_picker(expy, expm, expd, dname="expires") wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Job Title</b><br />') wr(text('job_title', value=jp.get('job_title', ''), clss='input')) wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Institution/Organization</b><br />') wr(text('job_inst', value=jp.get('job_inst', ''), clss='input')) wr('<span class="req">required</span>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Department</b><br />') wr(text('job_dept', value=jp.get('job_dept', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Job Description</b> <span class="req">required</span><br />' ) wr('<textarea name="description" class="input" cols="72" rows="6">%s</textarea>' % (jp.get('description', ''))) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('Would you like to include a link to another website?') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Text to be Linked</b><br />') wr( text('web_link_text', value=jp.get('web_link_text', ''), clss='input')) wr('<small>e.g., visit our website for more information</small>') wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Link Address</b><br />') wr( text('web_link_url', value=jp.get('web_link_url', ''), clss='input')) wr('<small>e.g., http://www.example.com/job_listing</small>') wr('</div>') # ------------------------------------------------------ wr('<h2>C.V. Submission</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('Where and how should prospective job candidates submit their information for consideration?' ) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Instructions</b><br />') wr('<textarea name="cv_instructions" class="input" cols="72" rows="4">%s</textarea>' % (jp.get('cv_instructions', ''))) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Contact Name</b><br />') wr(text('cv_name', value=jp.get('cv_name', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Title</b><br />') wr(text('cv_title', value=jp.get('cv_title', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Address</b><br />') wr(text('cv_addr1', value=jp.get('cv_addr1', ''), clss='input')) wr('<br />') wr(text('cv_addr2', value=jp.get('cv_addr2', ''), clss='input')) wr('<br />') wr(text('cv_addr3', value=jp.get('cv_addr3', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>City, State, ZIP</b><br />') wr(text('cv_city', value=jp.get('cv_city', ''), clss='input')) wr( text('cv_state', value=jp.get('cv_state', ''), clss='input', size='3')) wr( text('cv_zip', value=jp.get('cv_zip', ''), clss='input', size='9')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Country</b><br />') wr(text('cv_country', value=jp.get('cv_country', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Email</b><br />') wr(text('cv_email', value=jp.get('cv_email', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Phone</b><br />') wr(text('cv_phone', value=jp.get('cv_phone', ''), clss='input')) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<b>Fax</b><br />') wr(text('cv_fax', value=jp.get('cv_fax', ''), clss='input')) wr('</div>') # ------------------------------------------------------ wr('<h2>Contacts (optional)</h2>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<em>This is different from where candidates will send their CVs.</em> If the candidate has questions about this job listing, who should they contact and how?' ) wr('</div>') wr('<div style="margin: 7px 0px 7px 0px;">') wr('<table><tr><td>') wr('<table><tr><th colspan="2">Contact 1') wr('<tr><td>Name') wr('<td>%s' % (text('contact1_name', value=jp.get('contact1_name', ''), clss='input'))) wr('<tr><td>Email') wr('<td>%s' % (text('contact1_email', value=jp.get('contact1_email', ''), clss='input'))) wr('<tr><td>Phone') wr('<td>%s' % (text('contact1_phone', value=jp.get('contact1_phone', ''), clss='input'))) wr('</table>') wr('<td>') wr('<table><tr><th colspan="2">Contact 2') wr('<tr><td>Name') wr('<td>%s' % (text('contact2_name', value=jp.get('contact2_name', ''), clss='input'))) wr('<tr><td>Email') wr('<td>%s' % (text('contact2_email', value=jp.get('contact2_email', ''), clss='input'))) wr('<tr><td>Phone') wr('<td>%s' % (text('contact2_phone', value=jp.get('contact2_phone', ''), clss='input'))) wr('</table>') wr('</table></div>') # ------------------------------------------------------ wr('<div style="margin: 21px 0px 7px 0px;">') wr(submit('Save & Post Job Info')) wr('</div>') wr('</form>')