Exemplo n.º 1
0
    def _getFollowingInfo(self):
        header = h3('Following')

        table = HtmlTable(class_='profileTable')
        data = []
        followings = []
        for f in self.user.following:

            # append (n) to duplicate Usernames
            fullname = f.fullname
            n = 2
            while fullname in followings:
                fullname = '%s (%s)' % (f.fullname, n)
                n += 1
            followings.append(fullname)

            # add follower info to data
            name_link = a(fullname,
                          href='//%s/profile.py?u=%s' %
                          (self.conf.baseurl, encrypt_int(f.id)))
            schools = span(br().join([s['school'] for s in f.schools]),
                           class_='smaller-text')
            table.addRow([name_link + br() + schools])

        return header + table.getTable()
Exemplo n.º 2
0
    def get(self):
        intro = p('Your address information')

        fields = [
            'Your Name', 'Business Name', 'Address', 'City', 'State', 'Zip',
            'Contact Name', 'Email Address', 'Confirm Email Address',
            'Phone Number'
        ]

        table = HtmlTable()
        for field in fields:
            name = field.lower().replace(' ', '_')
            description_name = '%s_text' % name
            description = span(field, id=description_name)
            table.addRow(
                [description,
                 input(type='textfield', name=name, size=50)])

        # next/prev
        next3 = span('Next>', id='next3', class_='textButton')
        prev3 = span('<Prev', id='prev3', class_='textButton')

        return div(''.join([intro,
                            table.getTable(), prev3 + ' | ' + next3]),
                   id='order_form3')
Exemplo n.º 3
0
    def get(self):
        intro = p('Your address information')

        fields = ['Your Name',
                  'Business Name',
                  'Address',
                  'City',
                  'State',
                  'Zip',
                  'Contact Name',
                  'Email Address',
                  'Confirm Email Address',
                  'Phone Number']

        table = HtmlTable()
        for field in fields:
            name=field.lower().replace(' ', '_')
            description_name = '%s_text' % name
            description = span(field, id=description_name)
            table.addRow([description, input(type='textfield', name=name, 
                                             size=50)])

        # next/prev
        next3 = span('Next>', id='next3', class_='textButton')
        prev3 = span('<Prev', id='prev3', class_='textButton')

        return div(''.join([intro,
                            table.getTable(),
                            prev3 + ' | ' + next3]),
                   
                   id='order_form3')
Exemplo n.º 4
0
    def _getPostStats(self):
        '''Return a table of Posting statistics as HTML'''

        table = HtmlTable(class_='profileTable')
        table.addHeader(
            ['Posts', 'Member</br>Reach', 'School<br/>Reach', 'Following'])

        # school reach
        school_reach = []
        for f in self.user.followers:
            for s in f.schools:
                school_reach.append(s['school'])
        school_reach = set(school_reach)

        table.addRow([
            str(self.feed.num_messages),
            str(len(self.user.followers)),
            str(len(school_reach)),
            str(len(self.user.following))
        ])
        table.setRowVAlign(1, 'bottom')
        table.setCellAlign(2, 1, 'center')
        table.setCellAlign(2, 2, 'center')
        table.setCellAlign(2, 3, 'center')
        table.setCellAlign(2, 4, 'center')

        return table.getTable()
Exemplo n.º 5
0
    def get(self):
        intro = p('What container types do you want?:', id='form2Intro')

        single_jar = input(type='textfield', name='single_jar', 
                           size=5, class_='numberField')
        single_jar_text = span('Single Jar', id='single_jar_text')

        multiple_jars = input(type='textfield', name='multiple_jars', 
                              size=5, class_='numberField')
        multiple_jars_text = span('Multiple Jars', id='multiple_jars_text')

        patient_scrap_mailer = input(type='textfield', 
                                     name='patient_scrap_mailer', size=5,
                                     class_='numberField')

        patient_scrap_mailer_text = span('Patient Scrap Mailer', 
                                         id='patient_scrap_mailer_text')

        table = HtmlTable()
        table.addRow(['Qty'               , 'Container type'])
        table.addRow([single_jar          , single_jar_text])
        table.addRow([multiple_jars       , multiple_jars_text])
        table.addRow([patient_scrap_mailer, patient_scrap_mailer_text])
                     
        # next/prev
        prev2 = span('&lt;Prev', id='prev2', class_='textButton')
        next2 = span('Next>', id='next2', class_='textButton')

        return div(''.join([intro,
                            table.getTable(),
                            prev2 + ' | ' + next2]),
                   
                   id='order_form2')
Exemplo n.º 6
0
    def _getControls(self):
        login_as_dlink = input(name='login',
                               type='submit',
                               value='Login as dlink')
        logout = input(name='logout', type='submit', value='Logout')

        table = HtmlTable()
        table.addRow([login_as_dlink, logout])
        return div(table.getTable(), style="margin: 30px")
Exemplo n.º 7
0
    def _getLoginForm(self):

        email = input(name='email', type='text')
        password = input(name='password', type='password')
        login_button = input(name='login_submit', type='submit', value='Login')
        table = HtmlTable()
        table.addRow(['Email', email])
        table.addRow(['Password', password])
        table.addRow(['', login_button])
        return div(table.getTable(), style="margin: 30px")
Exemplo n.º 8
0
    def _getTagsPanel(self):
        def mk_button(tag, class_=''):
            return input(value=tag, type='button',
                         class_='btn btn-default btn-xs',
                         onclick="javascript: search('%s')" % tag)

        def mk_mock_button(tag, class_=''):
            class_ += ' btn btn-default btn-xs'
            return input(value=tag, type='button',
                         class_='btn btn-default btn-xs disabled')

        tags = ['Music', 'SAT', 'Devices', 'Special Ed','Football','Math','Research',
                'Honors Class', 'AP', 'Art', 'Life Skills', 'DIY', 'Cub Scouts',
                'After School', 'Transportation', 'Open House', 'Back To School',
                'Social Media', 'Olympics', 'Health', 'Programming', 'Volunteer',
                'Soccer', 'Supplies', 'Meals', 'Futura', 'Health', 'Bullying',
                'Kindergarten', 'PTA', 'Library', 'Autism', 'Grit',
                'Science', 'Spectrum', 'AOS','Safety', 'Beach', 'Common Core',
                'Economics', 'Cafeteria', 'ESL', 'AP Latin','IB', 'Field Trip',
                'ACT', 'Movies', 'Parks', 'Technology', 'History', 'Geography',
                'Engineering', 'Economics', 'Literature', 'Drama',
                'Swimming', 'Lacrosse', 'Basketball', 'Softball', 'Drones', 'Halloween',
                'Camping', 'Internship', 'Weather', 'Culture', 'Projects', 'Space',
                'SnowDays', 'Teaching', 'Performance', 'Tennis', 'Aerobics', 'FLE',
                'SexEd', 'Leadership', 'White House', 'Character', 'Team', 'Books',
                'Moms', 'Recognition', 'Tweens' ]
        real_tags = ['Music', 'SAT', 'Devices', 'Special Ed','Football','Math','Research',
                'Honors Class', 'AP', 'Art', 'Life Skills', 'DIY', 'Cub Scouts',
                'After School', 'Transportation', 'Open House', 'Back To School',
                'Social Media', 'Olympics', 'Health', 'Programming', 'Volunteer',
                'Soccer', 'Supplies', 'Meals', 'Futura', 'Health', 'Bullying',
                'Kindergarten', 'PTA', 'Library', 'Autism', 'Grit',
                'Science', 'Spectrum', 'AOS','Safety', 'Beach', 'Common Core',
                'Economics', 'Cafeteria', 'ESL', 'AP Latin','IB', 'Field Trip',
                'ACT', 'Movies', 'Parks', 'Technology', 'History', 'Geography',
                'Engineering', 'Economics', 'Literature', 'Drama',
                'Swimming', 'Lacrosse', 'Basketball', 'Softball', 'Drones', 'Halloween',
                'Camping', 'Internship', 'Weather', 'Culture', 'Projects', 'Space',
                'SnowDays', 'Teaching', 'Performance', 'Tennis', 'Aerobics', 'FLE',
                'SexEd', 'Leadership', 'White House', 'Character', 'Team', 'Books',
                'Moms', 'Recognition', 'Tweens' ]

        tag_buttons = ''
        for tag in tags:
            if tag in real_tags:
                tag_buttons += mk_button(tag)
            else:
                tag_buttons += mk_mock_button(tag)

        table = HtmlTable(class_='table borderless')
        table.addHeader(['Trending Topics'])
        table.addRow([tag_buttons])
        return table.getTable()
Exemplo n.º 9
0
    def pictureArea(self):
        '''Picture area used inside DisplayArea'''
        if not self.page:
            return self.pageNotFound()

        num_pics = len(self.page.pics)
        num_rows = ((num_pics-1)/NUM_COLS)+1

        table = HtmlTable(id='displayTable')
        i = 0
        for r in range(0, num_rows):
            row = []
            for c in range(0, NUM_COLS):
                if i < num_pics:
                    row.append(self.pic_div(i))
                    i += 1
            table.addRow(row)
            table.setRowVAlign(table.rownum, 'top')

        return div(table.getTable(), id='pictureArea')
Exemplo n.º 10
0
    def _getUserData(self):
        '''Return User Data Fields as HTML'''
        header = h3('Profile')
        pic_src = getUserImage(self.user.id)
        image_ = div(img(width='150px', src=pic_src))

        if self.user.id == self.session.user.id:
            file = input(type='file',
                         name='filename',
                         accept='image/*',
                         onchange='upload_form.submit();')
            action_text = ''
            if pic_src == 'images/generic_icon.png':
                action_text = p('Click to upload your <br/>profile photo',
                                id='profile-pic-action-text')
            browse = div(image_ + action_text + file,
                         id='profile-pic',
                         class_='btn btn-file')
            image = form(browse,
                         enctype='multipart/form-data',
                         action='',
                         method='post',
                         name='upload_form')
        else:
            image = image_

        # build data
        data = [['Name:', self.user.fullname]]
        if self.user.id == self.session.user.id:
            data.append(['Email:', self.user.email])
        data.append([nobr('Member Since:'), format_date(self.user.created)])

        # build html table
        table = HtmlTable(class_='profileTable')
        for row in data:
            row_header = span(row[0], class_='profileRowHeader')
            value = row[1]
            table.addRow([row_header, value])
        table.setColVAlign(1, 'top')

        return header + image + table.getTable()
Exemplo n.º 11
0
    def getSqlPanel(self):
        title = div(b(i('Show SQL for %s' % self.params.report_title)),
                    id='sql_panel_title')

        table = HtmlTable(id='sql_panel_table')
        table.addRow([b('SQL'), b('Count SQL')])

        count_sql = self.sqlBuilder.getCountSQL()
        count_sql_pretty = div(pretty_sql(count_sql, html=True) + ';')
        
        sql  = self.sqlBuilder.getSQL()
        sql_pretty = div(pretty_sql(sql, html=True) + ';')

        table.addRow([sql_pretty, count_sql_pretty])
        table.setColWidth(1, '50%')
        table.setRowVAlign(2, 'top')
        
        show_sql = div(title + \
                       table.getTable(),
                       id='sql_panel')
        
        return show_sql
Exemplo n.º 12
0
    def getControls(self):
        title = div(b('Filters'), class_='report-controls-title')

        table = HtmlTable(class_='report-controls-table')
        filters = []
        for control in self.params.controls:
            ctitle = control.display
            if control.type in ('string', 'date', 'multiple'):
                cinput = self._getInput(control)
                if control.type == 'multiple':
                    ctitle += ' (multiple - space separated)'
            elif control.type == 'checkbox':
                cinput = self._getCheckbox(control)
            elif control.type == 'menu':
                cinput = self._getControlMenu(control)
            elif control.type == 'no_op':
                ctitle = ''
                cinput = ''
            else:
                raise Exception("ReportFilters: Unrecognized control.type: "
                                "%s" % (control.type))
            filters.append([ctitle, cinput])

        for filter in listToTable(filters):
            table.addRow(filter)

        reset_button = a('Reset Filters', id='reset-filters', class_='vbutton',
                         onclick='reset_filters()')
            
        table.setColClass(2, 'filter-field')
        table.setColClass(4, 'filter-field')

        report_controls = div(title + \
                              table.getTable() + \
                              reset_button,
                              id = 'filter-chooser',
                              class_ ='report-controls')
        return report_controls
Exemplo n.º 13
0
    def getControls(self):
        title = div(b('Summaries'), class_='report-controls-title')

        table = HtmlTable(class_='report-controls-table')
        for n in range(1, self.params.num_group_bys+1):
            if n == 1:
                row = ['Summarize by:', self._getGroupByMenu(n)]
            else:
                row = ['', self._getGroupByMenu(n)]
            table.addRow(row)

        reset_button = a('Reset Summary', id='reset-filters', class_='vbutton',
                         onclick='reset_summaries()')
            
        table.setColClass(1, 'filter-field')
        table.setColClass(2, 'filter-field')

        report_controls = div(title + \
                              table.getTable() + \
                              reset_button,
                              id = 'summary-chooser',
                              class_ ='report-controls')
        return report_controls
Exemplo n.º 14
0
    def get(self):
        intro = p('What container types do you want?:', id='form2Intro')

        single_jar = input(type='textfield',
                           name='single_jar',
                           size=5,
                           class_='numberField')
        single_jar_text = span('Single Jar', id='single_jar_text')

        multiple_jars = input(type='textfield',
                              name='multiple_jars',
                              size=5,
                              class_='numberField')
        multiple_jars_text = span('Multiple Jars', id='multiple_jars_text')

        patient_scrap_mailer = input(type='textfield',
                                     name='patient_scrap_mailer',
                                     size=5,
                                     class_='numberField')

        patient_scrap_mailer_text = span('Patient Scrap Mailer',
                                         id='patient_scrap_mailer_text')

        table = HtmlTable()
        table.addRow(['Qty', 'Container type'])
        table.addRow([single_jar, single_jar_text])
        table.addRow([multiple_jars, multiple_jars_text])
        table.addRow([patient_scrap_mailer, patient_scrap_mailer_text])

        # next/prev
        prev2 = span('&lt;Prev', id='prev2', class_='textButton')
        next2 = span('Next>', id='next2', class_='textButton')

        return div(''.join([intro,
                            table.getTable(), prev2 + ' | ' + next2]),
                   id='order_form2')
Exemplo n.º 15
0
    def getHtml(self, user):
        can_edit = user.id == self.session.user.id

        header = h3('School Information')
        #help = span(a('Why do I need to provide this information?'),
        #            class_='helpMsg',
        #            title='By knowing what school or schools you are '
        #            'interested in, we can provide you with conversations '
        #            'that are meaningful to you.')

        table = HtmlTable(class_='table')

        # header
        col_header = ['Role', 'School', 'Grade']
        if can_edit:
            col_header.append('&nbsp;')
        table.addHeader(col_header)

        # schools
        for s in user.schools:
            row = [s['relation'], s['school'], s['grade']]
            row[2] = Grades().table[row[2]]['name']
            if can_edit:
                school_info = '%s - %s - %s Grade' % tuple(row)
                row.append(
                    a('X',
                      class_='delete',
                      onclick="javascript:deleteSchool(%s, '%s');" %
                      (s['id'], js_arg(school_info))))
            table.addRow(row)
            table.setColClass(3, 'right-center')

        # add school row
        if self.add_school_row:
            table.addRow(self.schoolFields())

        # buttons
        buttons = ''
        if can_edit:

            # [add new school] button
            if not self.add_school_row:
                add_button = a('Add another school',
                               class_='btn btn-primary first-button',
                               onClick='javascript:addSchoolRow();')
                buttons += add_button

            # [save] + [cancel] buttons
            if self.add_school_row:
                save_button = a('Save',
                                class_='btn btn-success first-button',
                                onClick='javascript:saveNewSchool()')
                cancel_button = a('Cancel',
                                  class_='btn btn-warning',
                                  onclick="location.href='profile.py';")
                buttons += save_button + cancel_button

        # hidden fields
        hidden_fields = \
            input(type='hidden', name='add_school_row') + \
            input(type='hidden', name='save_new_school') + \
            input(type='hidden', name='delete_user_school')

        body = div(table.getTable() + buttons + hidden_fields, id='schoolInfo')
        return header + form(body, name='si_form', method='POST')
Exemplo n.º 16
0
Arquivo: oneup.py Projeto: dlink/vpics
 def navAndDisplayArea(self):
     table = HtmlTable()
     table.addRow([self.nav.nav(),
                   self.displayArea()])
     table.setRowVAlign(1,'top')
     return center(table.getTable())
Exemplo n.º 17
0
    def getGuts(self):
        # Table of column checkboxes NUM_COL's wide
        NUM_COL = 4
        table = HtmlTable(id='column-chooser-table',
                          class_='report-controls-table')
        num_separators = len([c for c in self.params.columns[1:]
                              if c.get('type') == 'separator'])
        num_checkboxes = len(self.params.columns) + num_separators
        remander = num_checkboxes % NUM_COL
        if remander:
            num_rows = (num_checkboxes/NUM_COL)+1
        else:
            num_rows = num_checkboxes/NUM_COL
        rows = [ [] for x in range(num_rows+1)]
        row_num = 0
        
        # checkboxs
        hidden = []
        skip_one = 0
        for i, column in enumerate(self.params.columns):

            if column.get('type') == 'separator':
                checkbox = b(column.display)
                if i != 0:
                    skip_one = 1

            elif self.disabled(column):
                
                # hidden fields
                style = 'color: lightgrey'
                h = input(type='hidden',
                          name='%s_column' % column.name,
                          value=column.get('selected', ''))
                mark = 'x' if column.get('selected') else '&nbsp;'
                display = span('[ %s ] %s' % (mark,column.display),style=style)
                checkbox = display + h
                
            else:
            
                # checkbox
                checkbox_params = {'type': 'checkbox',
                                   'name': '%s_column' % column.name}
                if column.get('selected'):
                    checkbox_params['checked'] = 'checked'
                if column.get('default'):
                    checkbox_params['class'] = 'default_column'
                if column.get('minor'):
                    display = span(column.display, class_='cc_minor')
                else:
                    display = span(column.display, class_='cc_major')
                                 
                checkbox = input(**checkbox_params) + display
            
            # build matrix of checkboxes, n x num_rows
            if skip_one:
                rows[row_num].append('')
                row_num += 1
                if row_num >= num_rows:
                    row_num = 0
                skip_one = 0

            rows[row_num].append(checkbox)
            row_num += 1
            if row_num >= num_rows:
                row_num = 0
                
        # build formated table:        
        for row in rows:
            table.addRow(row)
        table_of_columns = table.getTable()
        return table_of_columns
Exemplo n.º 18
0
#!/usr/bin/env python

import os

from vweb.htmltable import HtmlTable

print 'Content-Type: text/html\n'

table = HtmlTable()

keys = os.environ.keys()
for k in sorted(keys):
    table.addRow([k, os.environ[k]])

print table.getTable()