def write_form(self, username="", email="", usernameError="", passwordError="", verifyError="", emailError=""):
     self.response.write(form % {'username': utils.escape_html(username),
                                 'email': utils.escape_html(email),
                                 'usernameError': usernameError,
                                 'passwordError': passwordError,
                                 'verifyError': verifyError,
                                 'emailError': emailError
                                 })
예제 #2
0
파일: main_old.py 프로젝트: heekof/webapp
 def write_form(self, error="", month="", day="", year=""):
     self.response.write(
         form % {
             "error": error,
             "month": U.escape_html(month),
             "day": U.escape_html(day),
             "year": U.escape_html(year)
         })
예제 #3
0
 def write_form(self,uname="",pwd="",vpwd="",email=""):
     self.response.write(form_signup%
             {"uname":escape_html(uname),
              "pwd":escape_html(pwd),
              "vpwd":escape_html(vpwd),
              "email":escape_html(email)
              "error_uname":err_
             })
 def write_form(self, error="", month="", day="", year=""):
     self.response.write(
         form
         % {
             "error": error,
             "month": utils.escape_html(month),
             "day": utils.escape_html(day),
             "year": utils.escape_html(year),
         }
     )
예제 #5
0
파일: main.py 프로젝트: ertanuj96/mnlegV2
    def post(self):
        username = self.request.get("username")
        pasw = self.request.get("password")
        verify = self.request.get("verify")
        email = escape_html(self.request.get("email"))

        have_error, params = check_valid_signup(username, pasw, verify, email)

        if not have_error:
            u = User.by_name(username)
            if u:
                msg = 'That user already exists.'
                self.render(signup_page, user_error=msg)
            else:
                user_ip = self.request.remote_addr
                u = User.register(username, pasw, email, user_ip)
                u.put()
                # mail.send_mail(sender="*****@*****.**",
                # 				to="*****@*****.**",
                # 				subject=sign_up_subject,
                # 				body=render_signup_email_body(username,email,user_ip))
                self.login(u)
                self.redirect('/thankyou?n=' + username)
        else:
            self.render(signup_page, **params)
예제 #6
0
    def post(self):
        username=self.request.get("username")
        pasw=self.request.get("password")
        verify=self.request.get("verify")
        email=escape_html(self.request.get("email"))

        have_error,params=check_valid_signup(username,pasw,verify,email)

        if not have_error:
            u = User.by_name(username)
            if u:
                msg = 'That user already exists.'
                self.render(signup_page, user_error = msg)
            else:
                user_ip=self.request.remote_addr
                u = User.register(username, pasw, email, user_ip)
                u.put()
                # mail.send_mail(sender="*****@*****.**",
                # 				to="*****@*****.**",
                # 				subject=sign_up_subject,
                # 				body=render_signup_email_body(username,email,user_ip))
                self.login(u)
                self.redirect('/thankyou?n='+username)
        else:
            self.render(signup_page,**params)
예제 #7
0
def playlist_item_from_xml(playlist, xml_video_element, kodi_id=None,
                           kodi_type=None):
    """
    Returns a playlist element for the playqueue using the Plex xml

    xml_video_element: etree xml piece 1 level underneath <MediaContainer>
    """
    item = Playlist_Item()
    api = API(xml_video_element)
    item.plex_id = api.getRatingKey()
    item.plex_type = api.getType()
    try:
        item.id = xml_video_element.attrib['%sItemID' % playlist.kind]
    except KeyError:
        pass
    item.guid = xml_video_element.attrib.get('guid')
    if item.guid is not None:
        item.guid = escape_html(item.guid)
    if kodi_id is not None:
        item.kodi_id = kodi_id
        item.kodi_type = kodi_type
    elif item.plex_id is not None:
        with plexdb.Get_Plex_DB() as plex_db:
            db_element = plex_db.getItem_byId(item.plex_id)
        try:
            item.kodi_id, item.kodi_type = int(db_element[0]), db_element[4]
        except TypeError:
            pass
    item.xml = xml_video_element
    LOG.debug('Created new playlist item from xml: %s', item)
    return item
예제 #8
0
 def post(self):
     rot = self.request.get('rot')
     if not rot:
         self.write_form()
     else:
         flip_text = convert_rot(rot)
         print flip_text
         self.response.write(form % {"rot": escape_html(flip_text)})
예제 #9
0
 def post(self):
     rot = self.request.get('rot')
     if not rot:
         self.write_form()
     else:
         flip_text = convert_rot(rot)
         print flip_text
         self.response.write(form%
         {"rot":escape_html(flip_text)})
예제 #10
0
 def post(self):
     if not self.user:
         self.redirect("/blog/login")
         return
     
     subject = self.request.get("subject")
     content = utils.escape_html(self.request.get("content"))
     
     if subject and content:
         post = Post(subject=subject, content=content)
         post.put()
         top_posts(update=True)
         self.redirect("/blog/%i" % (post.key().id()))
     else:
         error = "we need both subject and content"
         self.render("blog_newpost.html", subject=subject, content=content, error=error)
예제 #11
0
 def send_confirmation(self, bot, cbq, bill_id, payment_id, trans):
     self.set_session(cbq.message.chat_id,
                      cbq.from_user,
                      self.action_type,
                      self.action_id,
                      0,
                      trans,
                      data={
                          const.JSON_BILL_ID: bill_id,
                          const.JSON_PAYMENT_ID: payment_id
                      })
     amt, fname, lname, uname = trans.get_payment(payment_id)
     cbq.answer()
     bot.sendMessage(chat_id=cbq.message.chat_id,
                     text=REQUEST_FORCE_PAY_CONFIRMATION.format(
                         utils.escape_html(
                             utils.format_name(uname, fname, lname)),
                         const.EMOJI_MONEY_BAG, amt),
                     parse_mode=ParseMode.HTML)
예제 #12
0
def playlist_item_from_xml(playlist, xml_video_element):
    """
    Returns a playlist element for the playqueue using the Plex xml
    """
    item = Playlist_Item()
    api = API(xml_video_element)
    item.plex_id = api.getRatingKey()
    item.plex_type = api.getType()
    item.ID = xml_video_element.attrib['%sItemID' % playlist.kind]
    item.guid = xml_video_element.attrib.get('guid')
    if item.guid is not None:
        item.guid = escape_html(item.guid)
    if item.plex_id:
        with plexdb.Get_Plex_DB() as plex_db:
            db_element = plex_db.getItem_byId(item.plex_id)
        try:
            item.kodi_id, item.kodi_type = int(db_element[0]), db_element[4]
        except TypeError:
            pass
    log.debug('Created new playlist item from xml: %s' % item)
    return item
예제 #13
0
 def post(self):
     uname = self.request.get('uname')
     pwd = self.request.get('pwd')
     vpwd = self.request.get('vpwd')
     email = self.request.get('email')
     valid_uname = valid_username(uname)
     valid_pwd = valid_pwd(pwd)
     valid_vpwd = False
     if vpwd == valid_pwd:
         valid_vpwd = True
     
     if not valid_uname:
         self.write_form(uname,"","","")
     elif not valid_pwd: 
         self.write_form(uname,"","","")
     elif not valid_vpwd:
         self.write_form(uname,"","","")
     else:
         # redirect it to "/unit2/welcome?username=piyush"
         self.response.write(form_%
             {"uname":escape_html(flip_text)})
예제 #14
0
def add_item_to_PMS_playlist(playlist, pos, plex_id=None, kodi_item=None):
    """
    Adds a new item to the playlist at position pos [int] only on the Plex
    side of things (e.g. because the user changed the Kodi side)

    WILL ALSO UPDATE OUR PLAYLISTS
    """
    if plex_id:
        try:
            item = playlist_item_from_plex(plex_id)
        except KeyError:
            log.error('Could not add new item to the PMS playlist')
            return
    else:
        item = playlist_item_from_kodi(kodi_item)
    url = "{server}/%ss/%s?uri=%s" % (playlist.kind, playlist.ID, item.uri)
    # Will always put the new item at the end of the Plex playlist
    xml = DU().downloadUrl(url, action_type="PUT")
    try:
        item.ID = xml[-1].attrib['%sItemID' % playlist.kind]
    except IndexError:
        log.info('Could not get playlist children. Adding a dummy')
    except (TypeError, AttributeError, KeyError):
        log.error('Could not add item %s to playlist %s' %
                  (kodi_item, playlist))
        return
    # Get the guid for this item
    for plex_item in xml:
        if plex_item.attrib['%sItemID' % playlist.kind] == item.ID:
            item.guid = escape_html(plex_item.attrib['guid'])
    playlist.items.append(item)
    if pos == len(playlist.items) - 1:
        # Item was added at the end
        _get_playListVersion_from_xml(playlist, xml)
    else:
        # Move the new item to the correct position
        move_playlist_item(playlist, len(playlist.items) - 1, pos)
    log.debug('Successfully added item on the Plex side: %s' % playlist)
예제 #15
0
def get_bill_text(bill_id, user_id, trans):
    try:
        bill = trans.get_bill_details(bill_id)
        if bill.get('title') is None or len(bill.get('title')) == 0:
            raise Exception('Bill does not exist')

        title_text = '<b>{}</b>'.format(utils.escape_html(bill['title']))

        bill_items = bill.get('items')
        items_text = []
        total = 0
        if bill_items is None or len(bill_items) < 1:
            items_text.append('<i>Currently no items</i>')
        else:
            for i, item in enumerate(bill_items):
                __, title, price = item
                total += price

                items_text.append(
                    str(i + 1) + '. ' + title + '  ' + const.EMOJI_MONEY_BAG +
                    '{:.2f}'.format(price))

        bill_taxes = bill.get('taxes')
        taxes_text = []
        if bill_taxes is not None:
            for __, title, tax in bill_taxes:
                total += (tax * total / 100)
                taxes_text.append(const.EMOJI_TAX + ' ' + title + ': ' +
                                  '{:.2f}'.format(tax) + '%')

        text = title_text + '\n\n' + '\n'.join(items_text)
        if len(taxes_text) > 0:
            text += '\n\n' + '\n'.join(taxes_text)

        text += '\n\n' + 'Total: ' + "{:.2f}".format(total)
        return text
    except Exception as e:
        logging.exception('get_bill_text')
예제 #16
0
 def post(self):
     text = self.request.get("text")        
     text = rot13_encryption(text)
     write_form(self, rot13_form, {"text":escape_html(text)})
예제 #17
0
 def write_form(self,rot=""):
     self.response.write(form%
         {"rot":escape_html(rot)})
예제 #18
0
파일: unit2.py 프로젝트: robotsarelame/aPie
 def post(self):
     user_text = self.request.get("text")
     converted_text = utils.rot13_converter(user_text)
     self.render(rot13_template, text=utils.escape_html(converted_text))
예제 #19
0
파일: main.py 프로젝트: ElieShalhoub/Rot13
 def write_form(self,text=""):
     self.response.write(form % {"text":escape_html(text)})
예제 #20
0
 def write_form(self, rot=""):
     self.response.write(form % {"rot": escape_html(rot)})
예제 #21
0
파일: ROT13.py 프로젝트: heekof/webapp
 def write_form(self, text=""):  #, month="", day="", year="" ):
     self.response.write(
         form % {"text": U.escape_html(U.ROT13(text))}
     )  #% { "error": error, "month": U.escape_html(month), "day": U.escape_html(day), "year": U.escape_html(year) })
 def write_form(self, text=""):
     self.response.write(form % {'text': utils.escape_html(text)})