def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get("method") certid = int(self.request.get("certid")) scid = int(self.request.get("id")) score = int(self.request.get("score")) sc = ElemScore.get_by_id(scid) sc.score = score sc.put() # TODO check to see if all the scores are passing and update cert.completed if so... c = Certification.get_by_id(certid) completed = True for s in c.scores: if s.score == 0: complete = False break if completed: if c.completed: # already completed pass else: c.completed = True c.put() ctkn = c.template.key().name() if ctkn == "KB1": level = 1 elif ctkn == "KB2": level = 2 elif ctkn == "KB3": level = 3 elif ctkn == "IK1": level = 4 elif ctkn == "IK2": level = 5 elif ctkn == "IK3": level = 6 else: level = 0 c.owner.level = level if c.put() and c.completed: # triggers an email to email c.owner.put() self.redirect("/examiner/certifications?certid=" + self.request.get("certid"))
def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get('method') certid = int(self.request.get('certid')) scid = int(self.request.get('id')) score =int(self.request.get('score')) sc = ElemScore.get_by_id(scid) sc.score = score sc.put() # TODO check to see if all the scores are passing and update cert.completed if so... cert = Certification.get_by_id(certid) complete = True for s in cert.scores: if s.score == 0: complete = False break if complete: cert.completed = True cert.put() self.redirect('/admin/certifications?certid='+self.request.get('certid'))
def post(self): method = self.request.get("method") if self.request.get("id"): cert_id = int(self.request.get("id")) email = self.request.get("recipient") fnam = self.request.get("fnam") lnam = self.request.get("lnam") if self.request.get("completed") == "1": completed = True else: completed = False templatekey = self.request.get("ctemp") if method == "update": # an edit c = Certification.get_by_id(cert_id) if completed: if c.completed: # already completed pass else: # update their level (member record) if templatekey == "KB1": level = 1 elif templatekey == "KB2": level = 2 elif templatekey == "KB3": level = 3 elif templatekey == "IK1": level = 4 elif templatekey == "IK2": level = 5 elif templatekey == "IK3": level = 6 elif templatekey == "EX1": level = 7 elif templatekey == "EX2": level = 8 elif templatekey == "M": level = 9 else: pass c.completed = True c.owner.level = level # updated Member's level using an algorithm to evaluate elements if c.put() and c.completed: # triggers an email to email pass self.redirect("/examiner/certifications") elif method == "delete": # delete the record and related scores c = Certification.get_by_id(cert_id) for s in c.scores: s.delete() # also delete the member if there are no other certs related and the member has no user mem = c.owner c.delete() if mem.user: pass else: memcs = Certification.all() memcs = Certification.gql("WHERE owner= :1", c.owner) if memcs.count(limit=2) > 0: pass else: # also check to see if this user is the creater of the record... if mem.createdBy == users.get_current_user(): mem.delete() self.redirect("/examiner/certifications") # TODO adjust level else: # a new post c = Certification() template = CertificationTemplate.get_by_key_name(templatekey) c.template = template mem = Member.get_by_key_name(email) if mem: # ... what if the fnam and lnam are different? an update? pass else: # create a new member mem = Member(key_name=email, fnam=fnam, lnam=lnam) mem.put() if completed: c.completed = True if templatekey == "KB1": level = 1 elif templatekey == "KB2": level = 2 elif templatekey == "KB3": level = 3 elif templatekey == "IK1": level = 4 elif templatekey == "IK2": level = 5 elif templatekey == "IK3": level = 6 elif templatekey == "EX1": level = 7 elif templatekey == "EX2": level = 8 elif templatekey == "M": level = 9 mem.level = level mem.put() c.owner = mem c.put() # Trigger email to certification recipient from google.appengine.api import mail message = mail.EmailMessage( sender="WorldKiteOrg-DoNotReply <*****@*****.**>", subject="Congratulations - your WorldKite Certification is completed", ) message.to = mem.key().name() message.body = "Congratulations" + mem.fnam + " " + mem.lnam message.body += """ """ message.body += c.template.key().name() + " " + c.template.short message.body += """ Visit http://worldkite.org and login with the email address you provided for your World Kite certification. We use Google's system for authentication so if you email account is not already registered with Google then you will be prompted to do so. Please let us know if you have any questions by dropping an email to: [email protected] Welcome to our team! World Kite Organization """ message.send() # now check the template and create new scores for each Element related to the CertTemp # first, get all CertificationTemplate.elements for el in template.elements: # now for each el, create a new ElemScore elsc = ElemScore() elsc.certtemp_elem = el elsc.certification = c if completed: elsc.score = 1 else: elsc.score = 0 elsc.put() self.redirect("/examiner/certifications?certid=" + str(c.key().id()))
def post(self): method = self.request.get('method') if self.request.get('id'): cert_id = int(self.request.get('id')) email = self.request.get('recipient') fnam = self.request.get('fnam') lnam = self.request.get('lnam') if self.request.get('completed') == '1': completed = True else: completed = False templatekey = self.request.get('ctemp') if method == "update": # an edit c = Certification.get_by_id(cert_id) if completed: if c.completed: #already completed pass else: #update their level (member record) if templatekey == 'KB1': level = 1 elif templatekey == 'KB2': level = 2 elif templatekey == 'KB3': level = 3 elif templatekey == 'IK1': level = 4 elif templatekey == 'IK2': level = 5 elif templatekey == 'IK3': level = 6 elif templatekey == 'EX1': level = 7 elif templatekey == 'EX2': level = 8 elif templatekey == 'M': level = 9 else: pass c.completed = True c.owner.level = level #updated Member's level using an algorithm to evaluate elements if c.put() and c.completed: #triggers an email to email pass self.redirect('/master/certifications') elif method == "delete": # delete the record and related scores c = Certification.get_by_id(cert_id) for s in c.scores: s.delete() #also delete the member if there are no other certs related and the member has no user mem = c.owner c.delete() if mem.user: pass else: memcs = Certification.all() memcs = Certification.gql("WHERE owner= :1", c.owner) if memcs.count(limit=2) > 0: pass else: # also check to see if this user is the creater of the record... if mem.createdBy == users.get_current_user(): mem.delete() self.redirect('/master/certifications') # TODO adjust level else: # a new post c = Certification() template = CertificationTemplate.get_by_key_name(templatekey) c.template = template mem = Member.get_by_key_name(email) if (mem): #... what if the fnam and lnam are different? an update? pass else: # create a new member mem = Member(key_name=email,fnam=fnam,lnam=lnam) mem.put() # TODO don't forget to send them an email to confirm membership!!! if completed: c.completed = True if templatekey == 'KB1': level = 1 elif templatekey == 'KB2': level = 2 elif templatekey == 'KB3': level = 3 elif templatekey == 'IK1': level = 4 elif templatekey == 'IK2': level = 5 elif templatekey == 'IK3': level = 6 elif templatekey == 'EX1': level = 7 elif templatekey == 'EX2': level = 8 elif templatekey == 'M': level = 9 mem.level = level mem.put() c.owner = mem c.put() # now check the template and create new scores for each Element related to the CertTemp # first, get all CertificationTemplate.elements for el in template.elements: # now for each el, create a new ElemScore elsc = ElemScore() elsc.certtemp_elem = el elsc.certification = c if completed: elsc.score = 1 else: elsc.score = 0 elsc.put() self.redirect('/master/certifications?certid=' + str(c.key().id()))
def post(self): # we need to be able to update scores for an uncompleted certification # passing (score) id, score, method (update) method = self.request.get('method') elemscoreid = int(self.request.get('elemscoreid')) tskscid = int(self.request.get('id')) score = None tsksc = TaskScore.get_by_id(tskscid) tsksc.completed = True if self.request.get('score'): score=int(self.request.get('score')) tsksc.score = score tsksc.put() # check to see if all the other scores are passing and update elemscore.completed if so... e = ElemScore.get_by_id(elemscoreid) completed = True tally = 0 count = 0 for es in e.taskscores: tally += es.score count += 1 if es.score < 1: completed = False break if completed: average = round(tally/count,0) e.score = int(average) e.put() c = e.certification for s in c.scores: if s.score < 1: completed = False break if completed: if c.completed: #already completed pass else: c.completed = True c.put() ctkn = c.template.key().name() if ctkn == 'KB1': level = 1 elif ctkn == 'KB2': level = 2 elif ctkn == 'KB3': level = 3 else: level = 0 c.owner.level = level if c.put() and c.completed: #triggers an email to email c.owner.put() # trigger an email to recipient of certification from google.appengine.api import mail message = mail.EmailMessage(sender="WorldKiteOrg-DoNotReply <*****@*****.**>",subject="Congratulations - your WorldKite Certification is completed") message.to = member.key().name() message.body = "Congratulations" + member.fnam + " " + member.lnam message.body += """ """ message.body += c.template.key().name() + " " + c.template.short message.body += """ Visit http://worldkite.org and login with the email address you provided for your World Kite certification. We use Google's system for authentication so if you email account is not already registered with Google then you will be prompted to do so. Please let us know if you have any questions by dropping an email to: [email protected] Welcome to our team! World Kite Organization """ message.send() self.response.out.write('/instructor/certifications?certid=' + str(c.key().id())) else: pass
def post(self): method = self.request.get('method') cert_id = None if self.request.get('id'): cert_id = int(self.request.get('id')) email = self.request.get('recipient') fnam = self.request.get('fnam') lnam = self.request.get('lnam') if self.request.get('completed') == '1': completed = True else: completed = False templatekey = self.request.get('ctemp') if method == "update": # an edit c = Certification.get_by_id(cert_id) if completed: if c.completed: #already completed pass else: #update their level (member record) if templatekey == 'KB1': level = 1 elif templatekey == 'KB2': level = 2 elif templatekey == 'KB3': level = 3 elif templatekey == 'IK1': level = 4 elif templatekey == 'IK2': level = 5 elif templatekey == 'IK3': level = 6 elif templatekey == 'EX1': level = 7 elif templatekey == 'EX2': level = 8 elif templatekey == 'M': level = 9 else: level = 0 c.completed = True c.owner.level = level #updated Member's level using an algorithm to evaluate elements if c.put() and c.completed: #triggers an email to email pass self.redirect('/admin/certifications') elif method == "delete": # delete the record and related scores c = Certification.get_by_id(cert_id) for s in c.scores: s.delete() c.delete() self.redirect('/admin/certifications') # todo : adjust level else: # a new post c = Certification() template = CertificationTemplate.get_by_key_name(templatekey) c.template = template mem = Member.get_by_key_name(email) # goddamit, email should be the keyname for a member!!! if mem: #... what if the fnam and lnam are different? an update? pass else: # create a new member mem = Member(key_name=email,fnam=fnam,lnam=lnam) mem.put() # todo : don't forget to send them an email to confirm membership!!! if completed: c.completed = True if templatekey == 'KB1': level = 1 elif templatekey == 'KB2': level = 2 elif templatekey == 'KB3': level = 3 elif templatekey == 'IK1': level = 4 elif templatekey == 'IK2': level = 5 elif templatekey == 'IK3': level = 6 elif templatekey == 'EX1': level = 7 elif templatekey == 'EX2': level = 8 elif templatekey == 'M': level = 9 else: level = 0 mem.level = level mem.put() c.owner = mem c.put() # now check the template and create new scores for each Element related to the CertTemp # first, get all CertificationTemplate.elements for el in template.elements: # now for each el, create a new ElemScore elsc = ElemScore() elsc.certtemp_elem = el elsc.certification = c if completed: elsc.score = 1 else: elsc.score = 0 elsc.put() self.redirect('/admin/members?memberkey=' + email)