Exemple #1
0
    def show_kws_mgt_specific_page(self, kws_info):
        
        action_url = url_for('teamboxes')
        c.kws_id = kws_info.kws_id
        c.action_url = action_url
        c.back_url = action_url + "?kws_mgt_reshow_kws=1"
        c.kws_ro_link = action_url + "?kws_id=%i&kwmo_redir=1" % ( kws_info.kws_id )
        c.kws_name = kws_info.name
        
        c.kws_creator = ""
        if len(kws_info.user_list): c.kws_creator += kws_info.user_list[0].email + " "
        if kws_info.org_name: c.kws_creator += "(" + kws_info.org_name + ")"

        c.kws_date = self.format_kws_date(kws_info.creation_date)
        
        tmp = ""
        for user in kws_info.user_list:
            if user.name: middle = user.name + " (" + user.email + ")"
            else: middle = user.email
            tmp += "    <tr><td>%s</td></tr>\n" % (kweb_lib.html_text_escape(middle))
        c.member_list = tmp
        
        c.kws_file_size = self.format_as_mb(kws_info.file_size, 2)
        c.kws_quota = self.format_as_mb(kws_info.file_quota, 0)
        
        return render('/teamboxes/specific.mako')
def get_html_escaped_string(strings,
                            key,
                            app=None,
                            none_if_missing=False,
                            allow_basic_html=False):
    kdebug.debug(1, "set_strings(key='%s', app='%s', none_if_missing='%s', allow_basic_html='%s'" % \
        ( key, str(app), str(none_if_missing), str(allow_basic_html) ), "kweb_getstrings" )

    # get the string
    tmpstr = kgetstrings.get_string(strings,
                                    key,
                                    app=app,
                                    none_if_missing=none_if_missing)
    if not tmpstr:
        return None

    # escape basic forbidden html characters (not entities)
    tmpstr = kweb_lib.html_text_escape(tmpstr)

    if allow_basic_html:
        # unescape some html tags that we allow in strings
        tmpstr = re.sub(
            '&lt;nbsp&gt;', "&nbsp;", tmpstr
        )  # special case -- convert <nbsp> (not a real tag) to &nbsp;
        tmpstr = re.sub(
            '&lt;(\/?)(p|b|i)&gt;', "<\\1\\2>",
            tmpstr)  # convert back <p>, </p>, <b>, </b>,  <i>, </i>

    return tmpstr
Exemple #3
0
 def show_kws_mgt_query_page(self):
    
     # Define the session variables, if required.
     if not web_session.has_key("kws_mgt_query_offset"):
         self.reset_kws_mgt_query()
     
     # Obtain the Teambox list.
     kws_list = self.get_kws_mgt_kws_list(web_session["kws_mgt_query_offset"], web_session["kws_mgt_query_limit"])
     
     # Obtain the information about the Teamboxes.
     kws_dict = odict()
     for kws_id in kws_list: kws_dict[kws_id] = self.get_kws_mgt_kws_info(kws_id)
     
     # Show the information.
     action_url = url_for('teamboxes')
     
     # Get the Teambox list content.
     s = ""
     for kws_info in kws_dict.values():
         kws_href = action_url + "?kws_mgt_specific_kws=%i" % (kws_info.kws_id)
         s += '    <tr>\n'
         s += '      <td><input type="checkbox" name="kws_mgt_kws_cb_%i"/></td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstableid">%i</td>\n' % (kws_info.kws_id)
         s += '      <td class="kwstablename"><a href="%s">%s</a></td>\n' % \
              (kws_href, kweb_lib.html_text_escape(kws_info.name))
         s += '      <td class="kwstablestats">%i</td>\n' % (len(kws_info.user_list))
         s += '      <td class="kwstablestats">%s MiB</td>\n' % (self.format_as_mb(kws_info.file_size, 2))
         s += '      <td class="kwstablestats">%s</td>\n' % (self.format_kws_date(kws_info.creation_date))
         s += '      <td class="kwstablestats">%s</td>\n' % (kweb_lib.html_text_escape(kws_info.org_name))
         s += '    </tr>\n'
     kws_table_body = s
    
     # Push variables to template.  
     c.action_url = action_url
     c.kws_table_body = kws_table_body
     c.kws_mgt_query_offset = web_session["kws_mgt_query_offset"] + 1
     c.kws_mgt_query_limit = web_session["kws_mgt_query_limit"]
     
     return render('/teamboxes/query.mako')
def get_html_escaped_string(strings, key, app=None, none_if_missing=False, allow_basic_html=False):
    kdebug.debug(1, "set_strings(key='%s', app='%s', none_if_missing='%s', allow_basic_html='%s'" % \
        ( key, str(app), str(none_if_missing), str(allow_basic_html) ), "kweb_getstrings" )

    # get the string
    tmpstr = kgetstrings.get_string(strings, key, app=app, none_if_missing=none_if_missing)
    if not tmpstr:
        return None

    # escape basic forbidden html characters (not entities)
    tmpstr = kweb_lib.html_text_escape(tmpstr)

    if allow_basic_html:
        # unescape some html tags that we allow in strings
        tmpstr = re.sub('&lt;nbsp&gt;', "&nbsp;", tmpstr) # special case -- convert <nbsp> (not a real tag) to &nbsp;
        tmpstr = re.sub('&lt;(\/?)(p|b|i)&gt;', "<\\1\\2>", tmpstr) # convert back <p>, </p>, <b>, </b>,  <i>, </i>

    return tmpstr