Example #1
0
  def post(self):
    text=""
    recipient=""
    case_number=cgi.escape(self.request.get('case_number'))
    content="""<html>
      <head></head>
      <body>"""
    content+=cgi.escape(self.request.get('form_results'))
    content+="""</body></html> """

    
    text+= "me"
    user=str(users.get_current_user())
    text+= case_number
    text+= content
    q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", users.get_current_user())
    if q.get():
      user_setting=q.get()
      recipient=user_setting.recipient_email
    else:
      self.redirect("/setup")
    message = mail.EmailMessage(sender=users.get_current_user().email(),
                                subject=case_number)
    text+= recipient

    message.to = recipient
    message.html = content
    
    text+="ERROR="
    text+= str(message.check_initialized())
    text+=str(message.__dict__)
    text+=dir(message)
    message.send()
    self.response.out.write(web_publish(text))
Example #2
0
    def get(self):
        form_title = cgi.escape(self.request.get("form_title"))
        if YamlValidator().failure(form_title):  # ERROR!!!!
            self.response.out.write(YamlValidator().failure(form_title))
        else:
            yaml_form = yaml.load(get_form_content(form_title))
            form_links = get_form_links(yaml_form)
            yaml_form = form_translator(yaml_form)

            # print yaml_form
            # ['TEST', ['PCR FOR
            # IMMUNOGLOBULIN AND T CELL
            # RECEPTOR GENE REARRANGEMENTS
            # WAS PERFORMED ON', 'PCR FOR
            # IMMUNOGLO

            # [('TEST', ['PCR FOR IMMUNOGLOBULIN\AND T CELL RECEPTOR GENE REARRANGEMENTS WAS PERFORMED ON',
            #'PCR FOR IMMUNOGLOBULIN AND T
            try:
                self.response.out.write(
                    web_publish(
                        self.template.render(
                            yaml_form=yaml_form,
                            form_links=form_links,
                            disable_unicode=True,
                            input_encoding="utf-8",
                            encoding_errors="replace",
                        )
                        % (form_title, form_title)
                    )
                )
            except:
                print get_form_content(form_title)
Example #3
0
 def get(self):
     user = users.get_current_user()
     if user:
         # self.response.headers['Content-Type'] = 'text/plain'
         template_path = localize("main_page_template.html")
         titles = [i.title for i in Form.all()]
         titles.sort()
         forms_titles = {"forms_titles": titles}
         text = template.render(template_path, forms_titles)
         self.response.out.write(web_publish(text))
         # self.response.out.write('Hello, ' + user.nickname())
     else:
         self.redirect(users.create_login_url(self.request.uri))
Example #4
0
 def get(self):
   template_path = localize("setup.html")
   user = users.get_current_user()
   q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", user)
   #print q
   #userprefs = q.get()
  #  q=Settings.all().filter("user="******"entered":"",
                                           "email":user_setting.recipient_email,
                                           "header":user_setting.header,
                                           "line_start":user_setting.line_start})
   else:
     text=template.render(template_path, {"entered":"","email":"", "header":"","line_start":""})
   self.response.out.write(web_publish(text))
Example #5
0
 def get(self):
     new_file_name = cgi.escape(self.request.get("new_file_name"))
     old_form_choice = cgi.escape(self.request.get("old_form_choice"))
     personal_form_name = cgi.escape(self.request.get("personal_form_name"))
     shared_form_name = cgi.escape(self.request.get("shared_form_name"))
     edit_form_choice = cgi.escape(self.request.get("edit_form_choice"))
     if new_file_name:
         form = self.form % ("", new_file_name)
         # cherrypy.session['fileName'] =os.path.join(FORMS_DIR,(new_file_name+GLOBBY))
         text = "<h1>%s</h1>" % new_file_name
         text += form
         self.response.out.write(web_publish(text))
     else:
         if old_form_choice:
             self.redirect("/renderform?form_title=%s" % old_form_choice)
         if edit_form_choice:
             self.redirect("/editform?new_form_name=%s" % edit_form_choice)
Example #6
0
 def get(self):
   user = users.get_current_user()
   recipient_email=cgi.escape(self.request.get('recipient_email'))
   header=cgi.escape(self.request.get('header'))
   line_start=cgi.escape(self.request.get('line_start'))
   q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", user)
   if q.get():
     user_setting=q.get()
   else:
     user_setting=Settings()
   user_setting.recipient_email=recipient_email
   user_setting.line_start=line_start
   user_setting.header=header
   user_setting.put()
   template_path = localize("setup.html")
   text=template.render(template_path, {"entered":"OK",
                                         "email":user_setting.recipient_email,
                                         "header":user_setting.header,
                                         "line_start":user_setting.line_start})
   self.response.out.write(web_publish(text))
   q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", user)
Example #7
0
 def get(self):
     form_title = cgi.escape(self.request.get("new_form_name"))
     # print form_title
     content = get_form_content(form_title)
     form_start = self.form % (content, form_title)
     self.response.out.write(web_publish(form_start))
Example #8
0
    def post(self):
        check_box_lines = make_ints(self.request.get("check_box_line", allow_multiple=True))
        multiple_choices = self.request.get("get_multiple_choices", allow_multiple=True)
        line_choices = make_ints(self.request.get("line_index_selection", allow_multiple=True))
        input_entries = self.request.get("get_input_entry", allow_multiple=True)
        line_index_input = make_ints(self.request.get("line_index_imput", allow_multiple=True))
        form_title = self.request.get("new_form_name")
        # print check_box_lines, "CHECKBOXLINES"
        # print multiple_choices, "MULTIPLE CHOICES"
        # print line_choices, "LINE CHOICES"
        # print input_entries, "INPUT ENTRIES"
        # print line_index_input, "LINE INDEX INPUT"
        # print "CHECKBOXLINES"
        Entry = ValidatedEntry()
        Entry.multiple_choices = zip(line_choices, multiple_choices)
        Entry.input_choices = zip(line_index_input, input_entries)
        Entry.check_box_lines = check_box_lines
        # print Entry.__dict__, "YEAH...."

        # print self.request
        # print self.request.POST.items()
        # print "BEING CALLED"

        """keys contains the chosen lines numbers+ a list with all the selected multiple choises"""
        # for debugging
        # yield strope(keys)

        choices = []
        t = get_form_key(yaml.load(get_form_content(form_title)))
        # t=yaml.load(file(cherrypy.session["fileName"]).read()) #['TEST', ['PCR FOR IMMUNOGLOBULIN AND T CELL RECEPTOR GENE REARRANGEMENTS WAS PERFORMED ON', 'PCR FOR IMMUNOGLO
        [choices.extend(i) for i in (t[i + 1] for i in range(0, len(t), 2))]  # ['HER-2/neu gene', ....
        # yield strope(choices)
        # print choices, "CHOICES"

        user = users.get_current_user()
        q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", user)
        if q.get():
            user_setting = q.get()
            header = user_setting.header
            line_start = user_setting.line_start
        else:
            header = ""
            line_start = ""

        text = header + "<br>"

        index = 0
        for chosen_check_box_line_index in Entry.check_box_lines:
            line = choices[chosen_check_box_line_index] + " "
            # print "RAW", line

            for multiple_choice in Entry.multiple_choices:  # (14, 'decreased')
                # yield strope(multiple_choice)+strope(chosen_check_box_line_index)
                if multiple_choice[0] == chosen_check_box_line_index and multiple_choice[1] != "default":
                    # continue
                    # yield "CHOICES MATCH"

                    match = self.MultipleSelect.parse(line)
                    if match:
                        match = match[0]
                        # yield strope(match)
                        line = line.replace(match, multiple_choice[1], 1)
                if multiple_choice[0] == chosen_check_box_line_index and multiple_choice[1] == "default":
                    # continue
                    # yield "CHOICES MATCH"
                    # yield strope(line)
                    ##print line
                    match = self.MultipleSelect.parse(line)
                    ##print match
                    # yield strope(match)
                    if match:

                        match = match[0]
                        # yield strope(match)
                        line = line.replace(match, "", 1)
            # print "NOT RAW", line
            for input_choice in Entry.input_choices:
                # print input_choice

                if input_choice[0] == chosen_check_box_line_index:

                    # yield "INPUT MATCH"
                    match = self.Input.parse(line)[0]
                    # print match, "MATCH", type(match)
                    # print line, type(line), match, type(match), input_choice[1], type(input_choice[1])
                    # continue
                    # yield strope(match)
                    line = line_start + line.replace(match, input_choice[1], 1)
                    # continue

            text += line
            text += "<BR>"
            # if index==0 or index==1:
            #     #continue
            #     text+="<BR>"
            index += 1
        # rendering engine
        # print text

        # print text, "HERE I AM"
        self.response.out.write(web_publish(template.render(self.template_path, {"form_results": text})))