Example #1
0
 def html(self, you_said, bot_says):
     doc, tag, text = Doc().tagtext()
     with tag('html'):
         with tag('head'):
             with tag('title'):
                 text('Chat with a Video Game NPC')
             with tag('script'):
                 text("onload = function() {\n")
                 text(
                     f"var msg = new SpeechSynthesisUtterance('{bot_says}');\n"
                 )
                 text('window.speechSynthesis.speak(msg);')
                 text('}')
         with tag('body', id='chat'):
             with tag('h1'):
                 text('Chat with Video Game NPC')
             with tag('h3'):
                 if len(you_said) > 0:
                     text(f'You said: {you_said}')
                     doc.stag('br')
                 text(f'Bot says: {bot_says}')
             with tag('form',
                      action='/chat',
                      method='post',
                      enctype='application/json'):
                 doc.input(name='query', id='query', type='text', value='')
                 doc.stag('br')
                 doc.stag(
                     'input',
                     type='submit',
                     value='Say it!',
                     style=
                     '-webkit-appearance: button; height:50px; width:300px; font-size:20px'
                 )
     return doc.getvalue()
Example #2
0
 def test_input_no_slash(self):
     doc = Doc(stag_end = '>')
     doc.input('passw', type="password")
     self.assertTrue(
         doc.getvalue() in (
             '<input name="passw" type="password">',
             '<input type="password" name="passw">'
         )
     )
    def on_get(self, req, resp):
        self._run_config = load_run_config_from_s3(self._project_parameters,
                                                   self._aws_parameters)

        resp.status = falcon.HTTP_200
        resp.content_type = 'text/html'

        doc, tag, text = Doc().tagtext()
        with tag('html'):
            with tag('head'):
                with tag('title'):
                    text('Happy Hour config')
            with tag('body', id='config'):
                with tag('h1'):
                    text('Happy Hour Config')
                with tag('form', action='/config', method='post'):
                    with tag('h2'):
                        text('Default config:')
                    doc.stag('br')
                    with tag('table', border=1):
                        for key, value in self._run_config[
                                'DEFAULT_CONFIG'].items():
                            with tag('tr'):
                                with tag('td', style='align:left'):
                                    text(f'{key}:\t')
                                with tag('td', style='align:left'):
                                    doc.input(name=f'default:{key}',
                                              type='text',
                                              value=f'{value}')
                    with tag('h2'):
                        text('Country specific config:')
                    for country_key, country_dict in self._run_config[
                            'COUNTRY_CONFIG'].items():
                        with tag('h3'):
                            text(f'Country {country_key}:')
                        with tag('table', border=1):
                            for key, value in country_dict.items():
                                with tag('tr'):
                                    with tag('td', style='align:left'):
                                        text(f'{key}:\t')
                                    with tag('td'):
                                        doc.input(
                                            name=f'country:{country_key}:{key}',
                                            type='text',
                                            value=f'{value}')
                    doc.stag('br')
                    doc.stag('br')
                    doc.stag(
                        'input',
                        type='submit',
                        value='Update config',
                        style=
                        '-webkit-appearance: button; height:50px; width:300px; font-size:20px'
                    )

        resp.body = (doc.getvalue())
def checkbox_field(data):
    checkbox_doc, checkbox_tag, checkbox_text, checkbox_line = Doc().ttl()
    with checkbox_tag('div', klass="form-group"):
        checkbox_line('label', data['name'])
        for check in range(data['checkLength']):
            checkbox_doc.input(('v-model', data['vmodel']),
                               name=data['name'],
                               type='checkbox',
                               value=data['values'][check])
            checkbox_text(data['label'][check])
    return checkbox_doc.getvalue()
Example #5
0
 def test_input_text(self):
     doc, tag, text = Doc(defaults={
         'color': 'yellow'
     },
                          errors={
                              'color': 'yellow not available'
                          }).tagtext()
     with tag('body'):
         doc.input('color', ('data-stuff', 'stuff'), type='text')
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(root[1].attrib['value'], 'yellow')
     self.assertEqual(root[1].attrib['data-stuff'], 'stuff')
     self.assertTrue('error' in root[1].attrib['class'])
def radio_field(data):
    radio_doc, radio_tag, radio_text, radio_line = Doc().ttl()
    with radio_tag('div', klass="form-group"):
        radio_line('label', data['name'])
        for rad in range(data['radioLength']):
            radio_doc.input(('v-model', data['vmodel']),
                            name=data['name'],
                            type='radio',
                            value=data['values'][rad])
            radio_text(data['label'][rad])
        print(radio_doc.getvalue())
        input()
    return radio_doc.getvalue()
Example #7
0
 def test_input_radio(self):
     doc, tag, text = Doc(defaults={'color': 'red'}).tagtext()
     with tag('body'):
         for color in ('blue', 'red', 'pink', 'yellow', 'ugly-yellow'):
             doc.input(('type', 'radio'),
                       id='color-input',
                       name="color",
                       value=color)
             text(color)
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(root[2].attrib['name'], 'color')
     self.assertEqual(root[3].attrib['type'], 'radio')
     self.assertEqual(root[1].attrib['checked'], 'checked')
     self.assertRaises(KeyError, lambda: root[0].attrib['checked'])
Example #8
0
    def demoForm(self):
        defaults = self.defaults.copy()
        errors = {}
        request = self.request()
        if request.hasField('message'):
            subject = self.request().field('subject')
            defaults['subject'] = subject
            if not subject:
                errors['subject'] = 'Please add the subject of your message.'
            elif self.isSpam(subject):
                errors['subject'] = 'Your subject looks like spam!'
            message = self.request().field('message')
            defaults['message'] = message
            if not message:
                errors['message'] = 'You did not enter a message!'
            elif self.isSpam(message):
                errors['message'] = 'Your message looks like spam!'
        else:
            subject = message = None

        doc = Doc(defaults=defaults, errors=errors)
        tag, text = doc.tag, doc.text

        if message and not errors:

            with tag('p', klass='success'):
                text('Congratulations! You have sent the following message:')
            with tag('div', klass='output'):
                with tag('p'):
                    with tag('strong'):
                        text(subject)
                with tag('p'):
                    text(message)
            with tag('a', href='YattagDemo'):
                text('Try sending another message.')

        else:

            with tag('h2'):
                text('Demo contact form')

            with tag('form', action="YattagDemo"):
                doc.input(name='subject', type='text', size=80)
                with doc.textarea(name='message', cols=80, rows=8):
                    pass
                doc.stag('input', type='submit', value='Send my message')

        return doc.getvalue()
def email_field(data):
    email_doc, email_tag, email_text = Doc(defaults={
        data['name']: ''
    },
                                           errors={
                                               data['name']: ''
                                           }).tagtext()
    with email_tag('div', klass="form-group"):
        with email_tag('label', ('for', data['id'])):
            email_text(modeler(data))
        email_doc.input(('v-model', data['vmodel']),
                        name=data['name'],
                        type='email',
                        placeholder=data['placeholder'],
                        id=data['id'],
                        klass='form-control')
    return email_doc.getvalue()
def file_field(data):
    file_doc, file_tag, file_text = Doc(defaults={
        data['name']: ''
    },
                                        errors={
                                            data['name']: ''
                                        }).tagtext()
    rdnl = 'readonly' if data['readonly'] == 'y' else 'test'
    with file_tag('div', klass="form-group"):
        with file_tag('label', ('for', data['id'])):
            file_text(modeler(data))
        file_doc.input(('v-model', data['vmodel']), (rdnl, ''),
                       name=data['name'],
                       type='file',
                       id=data['id'],
                       klass='form-control')
    return file_doc.getvalue()
def password_field(data):
    password_doc, password_tag, password_text = Doc(defaults={
        data['name']: ''
    },
                                                    errors={
                                                        data['name']:
                                                        'Compulsury'
                                                    }).tagtext()
    with password_tag('div', klass="form-group"):
        with password_tag('label', ('for', data['id'])):
            password_text(modeler(data))
        password_doc.input(('v-model', data['vmodel']),
                           name=data['name'],
                           type='password',
                           placeholder=data['placeholder'],
                           id=data['id'],
                           klass='form-control')
    return password_doc.getvalue()
Example #12
0
    def test_input_checkbox(self):
        doc, tag, text = Doc(defaults={'gift-wrap': 'yes'}).tagtext()
        with tag('body'):
            doc.input('gift-wrap', type='checkbox', value="yes")
        root = ET.fromstring(doc.getvalue())
        self.assertEqual(root[0].attrib['checked'], 'checked')

        doc, tag, text = Doc(defaults={
            'extras': ['fast-shipping', 'gift-wrap']
        }).tagtext()
        with tag('body'):
            for extra in ('fast-shipping', 'extension-of-warranty',
                          'gift-wrap'):
                doc.input('extras', type="checkbox", value=extra)
        root = ET.fromstring(doc.getvalue())
        self.assertEqual(root[0].attrib['checked'], 'checked')
        self.assertRaises(KeyError, lambda: root[1].attrib['checked'])
        self.assertEqual(root[2].attrib['checked'], 'checked')
def textbox_field(data):
    textbox_doc, textbox_tag, textbox_text = Doc(defaults={
        data['name']: ''
    },
                                                 errors={
                                                     data['name']: ''
                                                 }).tagtext()
    rdnl = 'readonly' if data['readonly'] == 'y' else 'test'
    with textbox_tag('div', klass="form-group"):
        with textbox_tag('label', ('for', data['id']), ('style', 'color:red')):
            textbox_text(modeler(data))
        textbox_doc.input(('v-model', data['vmodel']), (rdnl, ''),
                          name=data['name'],
                          type='text',
                          placeholder=data['placeholder'],
                          id=data['id'],
                          klass='form-control',
                          style='color:blue;font-family: sans-serif;')
    return textbox_doc.getvalue()
def range_field(data):
    number_doc, number_tag, number_text = Doc(defaults={
        data['name']: ''
    },
                                              errors={
                                                  data['name']: ''
                                              }).tagtext()
    rdnl = 'readonly' if data['readonly'] == 'y' else 'test'
    with number_tag('div', klass="form-group"):
        with number_tag('label', ('for', data['id'])):
            number_text(modeler(data))
        number_doc.input(('v-model', data['vmodel']), (rdnl, ''),
                         name=data['name'],
                         type='range',
                         min=data['min'],
                         max=data['max'],
                         id=data['id'],
                         klass='form-control')
    return number_doc.getvalue()
Example #15
0
 def test_input_radio(self):
     doc, tag, text = Doc(defaults = {'color': 'red'}).tagtext()
     with tag('body'):
         for color in ('blue', 'red', 'pink', 'yellow', 'ugly-yellow'):
             doc.input(('type', 'radio'), id = 'color-input', name = "color", value = color)
             text(color)
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(
         root[2].attrib['name'], 'color'
     )
     self.assertEqual(
         root[3].attrib['type'], 'radio'
     )
     self.assertEqual(
         root[1].attrib['checked'], 'checked'
     )
     self.assertRaises(
         KeyError, lambda: root[0].attrib['checked']
     )
Example #16
0
 def test_input_text(self):
     doc, tag, text = Doc(
         defaults = {'color': 'yellow'},
         errors = {'color': 'yellow not available'}
     ).tagtext()
     with tag('body'):
         doc.input('color', ('data-stuff', 'stuff'), type = 'text')
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(
         root[1].attrib['value'],
         'yellow'
     )
     self.assertEqual(
         root[1].attrib['data-stuff'],
         'stuff'
     )
     self.assertTrue(
         'error' in root[1].attrib['class']
     )
def page(S = None):
    doc, tag, text = Doc().tagtext()
    Data = readForm(Blank = True)
    if S:
        with tag('div',klass='wrapper'):
            with tag('div', id='content'):
                with tag('div', klass='container-fluid'):
                    with tag('div', klass='row'):
                        if 'modify' in Data and (P := PersonPageView(S, Data['EID'])): ## Récupération de l'objet à modifier
                            for Key in Data:
                                if 'txt_' in Key: P.Set(Key[4:], Data[Key]) ## Création de l'objet modifié
                            P.Save() ## Enregistrement dans la DB
                            goTo('index.py')
                        elif (P := PersonPageView(S, S.Get('eID'))): ## S = Utilisateur connecté et demande. P = la personne à gérer.
                            '''__file__.split('\\')[-1] = le nom de ce fichier comme thisFileName qui est dans tools.'''
                            with tag('form', action=thisFileName(), method="post", name="formSaisie", enctype="multipart/form-data"):
                                for Key in P.Fields(): doc, tag, text = showField(doc, tag, text, P.Show(Key)) ## Affichage de tous les champs à modifier
                                doc.stag('br')
                                doc.input(type="hidden", id='EID', name='EID', value=P.Get('eid'))
                                doc.stag('input', type="submit", id='modify', name='modify', value="Mettre à jour", style="width:150px")
Example #18
0
async def autofill_cksum(req):
    endpoint = 'https://www2.monroecounty.gov/elections-absentee-form'
    contact = await Contact.find_by_id(req.match_info['hash'])
    if contact is None:
        raise web.HTTPFound(location=endpoint)
    asyncio.create_task(tag_contact_with(contact, 'vote4robin_absentee'))
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('head'):
        with tag('title'):
            text(f"{contact.forename}'s Mail-in Ballot Application")
        with tag('script', type='text/javascript'):
            text('''
                 window.onload = function() {
                    document.getElementById('abs-ballot-app').submit()
                 }
                 ''')
        with tag('form', method='post', action=endpoint, id='abs-ballot-app'):
            for key, val in contact.form_data():
                doc.input(type='hidden', value=val, name=key)

    return web.Response(text=doc.getvalue(), content_type='text/html')
Example #19
0
def display_article(data):

    doc, tag, text, line = Doc(defaults=data['form_defaults'],
                               errors=data['form_errors']).ttl()

    doc.asis('<!DOCTYPE html>')

    with tag('html'):

        with tag('body'):

            line('h1', data['article']['title'])

            with tag('div', klass='description'):
                text(data['article']['description'])

            with tag('form', action='/add-to-cart'):
                doc.input(name='article_id', type='hidden')
                doc.input(name='quantity', type='text')

                doc.stag('input', type='submit', value='Add to cart')

    return doc.getvalue()
Example #20
0
 def test_input_checkbox(self):
     doc, tag, text = Doc(defaults = {'gift-wrap': 'yes'}).tagtext()
     with tag('body'):
         doc.input('gift-wrap', type='checkbox', value = "yes")
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(
         root[0].attrib['checked'], 'checked'
     )
     
     doc, tag, text = Doc(defaults = {'extras': ['fast-shipping', 'gift-wrap']}).tagtext()
     with tag('body'):
         for extra in ('fast-shipping', 'extension-of-warranty', 'gift-wrap'):
             doc.input('extras', type="checkbox", value = extra)
     root = ET.fromstring(doc.getvalue())
     self.assertEqual(
         root[0].attrib['checked'], 'checked'
     )
     self.assertRaises(
         KeyError, lambda: root[1].attrib['checked']
     )
     self.assertEqual(
         root[2].attrib['checked'], 'checked'
     )
Example #21
0
async def register(req):
    endpoint = 'https://voterreg.dmv.ny.gov/MotorVoter'
    contact = await Contact.find_by_id(req.match_info['hash'])
    if contact is None:
        raise web.HTTPFound(location=endpoint)
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('head'):
        with tag('title'):
            text('Voter Registration')
        with tag('script', type='text/javascript'):
            text('''
                window.onload = function() {
                    document.getElementById('rtv').submit();
                }
                ''')
        with tag('form', method='post', action=endpoint, id='rtv'):
            keys = ('DOB', 'email', 'sEmail', 'zip', 'terms')
            vals = (contact.dob.strftime('%m/%d/%Y'), contact.email,
                    contact.email, contact.zipcode, 'on')
            for key, val in zip(keys, vals):
                doc.input(type='hidden', value=val, name=key)
    return web.Response(text=doc.getvalue(), content_type='text/html')
Example #22
0
class MyHtml(HtmlCreator):
    def initDocTagText(self):
        self.doc, self.tag, self.text = Doc(
            defaults={
                'title': 'Untitled',
                'contact_message': 'You just won the lottery!'
            }
        ).tagtext()

    def design_header(self):
        with self.tag('head'):
            with self.tag('title'):
                self.text('A title.')

    def design_body(self):
        with self.tag('body'):
            with self.tag('h1'):
                self.text('Contact form')
            with self.tag('form', action=""):
                self.doc.input(name='title', type='text')
                with self.doc.textarea(name='contact_message'):
                    pass
                self.doc.stag('input', type='submit', value='Send my message')
Example #23
0
async def regstat(req):
    endpoint = 'https://www.monroecounty.gov/etc/voter/'
    contact = await Contact.find_by_id(req.match_info['hash'])
    if contact is None:
        raise web.HTTPFound(location=endpoint)
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('head'):
        with tag('title'):
            text('Absentee Ballot Status')
        with tag('script', type='text/javascript'):
            text('''
                 window.onload = function() {
                    document.getElementById('regstat').submit()
                 }
                 ''')
        with tag('form', method='post', action=endpoint, id='regstat'):
            keys = ('lname', 'dobm', 'dobd', 'doby', 'no', 'sname', 'zip')
            vals = (contact.surname, contact.dob.month, contact.dob.day,
                    contact.dob.year, contact.house, contact.street,
                    contact.zipcode)
            for key, val in zip(keys, vals):
                doc.input(type='hidden', value=val, name=f'v[{key}]')
    return web.Response(text=doc.getvalue(), content_type='text/html')
Example #24
0
def inputUser():
    """
    Ecran de saisie des coordonnées eID et mot de passe de l'utilisateur
    """
    doc, tag, text = Doc().tagtext()
    with tag('div', klass='container'):
        with tag('div', klass='row'):
            with tag('div', klass='modal-body col-md-4'):
                pass
            with tag('div', klass='modal-body col-md-4'):
                with tag('form',
                         klass='form center-block',
                         action='login.py',
                         method='post'):
                    with tag('div', klass='form-group'):
                        doc.input('eID',
                                  type='text',
                                  klass="form-control input-lg",
                                  placeholder="Eid",
                                  id='eID',
                                  name='eID')
                    with tag('div', klass='form-group'):
                        doc.input('password',
                                  type='password',
                                  klass="form-control input-lg",
                                  placeholder="Password",
                                  id='password',
                                  name='password')
                    with tag('div', klass='form-group'):
                        doc.stag('input',
                                 type='submit',
                                 id='btn_login',
                                 name='btn_login',
                                 value='Se connecter',
                                 klass='btn btn-primary btn-lg btn-block')
    webPage(doc)
Example #25
0
def login():
    doc, tag, text = Doc().tagtext()

    # Form starts
    with tag('form', action='/npccard', method='post'):
        with tag('table'):
            # Name and accent
            for attr in ["name", "accent"]:
                with tag('tr'):
                    with tag('td'):
                        with tag('label'):
                            text('{}: '.format(attr.capitalize()))
                    with tag('td'):
                        doc.input(name=attr, type='text')
            # Core stats
            for attr, val in zip(["st", "dx", "iq", "ht"], dem_four_stats()):
                with tag('tr'):
                    with tag('td'):
                        with tag('label'):
                            text('{}: '.format(attr.upper()))
                    with tag('td'):
                        doc.input(name=attr, type='number', value=val)
            # Attack and attack value
            with tag('tr'):
                with tag('td'):
                    with tag('label'):
                        text('Primary attack value (to hit): ')
                with tag('td'):
                    doc.input(name="attack-to-hit", type='number', value=10)
            with tag('tr'):
                with tag('td'):
                    with tag('label'):
                        text('Primary attack damage (e.g. "2d-1"): ')
                with tag('td'):
                    doc.input(name="attack-dmg", type='text', value="1d+3")

        doc.stag('input', type='submit', value='Submit')

    return doc.getvalue()
Example #26
0
def lambda_handler(event, context):

    answers = [
        "It is certain", "It is decidedly so", "Without a doubt",
        "Yes definitely", "You may rely on it", "As I see it, yes",
        "Most likely", "Outlook good", "Yes", "Signs point to yes",
        "Reply hazy try again", "Ask again later", "Better not tell you now",
        "Cannot predict now", "Think and ask again", "Don't count on it",
        "My reply is no", "My sources say no", "Outlook not so good",
        "Very doubtful"
    ]

    shake = ""
    if "queryStringParameters" in event:
        if event["queryStringParameters"] is not None:
            if "shake" in event["queryStringParameters"]:
                shake = event["queryStringParameters"]["shake"]

    doc, tag, text = Doc().tagtext()

    with tag('html'):
        with tag('body'):
            with tag('form', action="magic8ball"):
                with tag('div', name='center', style="margin-top: 150"):
                    with tag(
                            'div',
                            name='circle',
                            style=
                            "background: #black; border-radius: 50%; height:300px; width:300px; position: relative; box-shadow: 0 0 0 120px black; margin: auto;"
                    ):
                        with tag(
                                'div',
                                name='text',
                                style=
                                "position: relative; float: left; top: 50%; left: 50%; transform: translate(-50%, -50%);"
                        ):

                            if shake == "":
                                doc.stag(
                                    'font',
                                    style=
                                    "font-weight: bold; font-size: 110px; font-family: verdana; "
                                )
                                text("8")
                            else:
                                with tag(
                                        'div',
                                        name='triangle',
                                        style=
                                        "width: 0; height: 0; border-style: solid; margin-top: -60px; border-width: 0 120px 210px 120px; border-color: transparent transparent #007bff transparent;"
                                ):
                                    with tag(
                                            'div',
                                            style=
                                            "width: 120px; text-align: center;  margin-left: -60px; bottom: 0;"
                                    ):
                                        doc.stag(
                                            'font',
                                            style=
                                            "color: white; font-weight: bold; font-size: 22px; font-family: verdana; text-align: center"
                                        )
                                        doc.stag('br')
                                        doc.stag('br')
                                        doc.stag('br')
                                        doc.stag('br')
                                        text(random.choice(answers))

                    with tag(
                            'div',
                            name='text',
                            style=
                            "position: relative; float: left; top: 50%; left: 50%; transform: translate(-50%, -50%);"
                    ):

                        doc.input(name="shake", type='hidden', value="true")
                        doc.stag(
                            'input',
                            type="submit",
                            value="Shake!",
                            style=
                            "width: 200px; margin-top: 350px; background-color: black; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; display: flex; justify-content: center; cursor: pointer;"
                        )

    htmlResult = doc.getvalue()

    return {
        'statusCode': "200",
        'body': htmlResult,
        'headers': {
            'Content-Type': 'text/html',
        }
    }
Example #27
0
from yattag import Doc
from yattag import indent

doc, tag, text, line = Doc(defaults={
    'title': 'Untitled',
    'contact_message': 'You just won the lottery!'
},
                           errors={
                               'contact_message':
                               'Your message looks like spam.'
                           }).ttl()

line('h1', 'Contact form')
with tag('form', action=""):
    doc.input(name='title', type='text')
    with doc.textarea(name='contact_message'):
        pass
    doc.stag('input', type='submit', value='Send my message')

result = indent(doc.getvalue(),
                indentation='    ',
                newline='\r\n',
                indent_text=True)
print(result)
    def add_table_selector(self, position, type, type_name, header_list,
                           body_list, footer_list):
        """
        add_table_selector_to_form('left', 'checkbox', 'table-box',
                                    ['H1', 'H2', 'H3'],
                                    [["A1", "B1", "C1"],["A2", "B2", "C2"], ["A3", "B3", "C3"]],
                                    ["F1","F2","F3"])

        -->  <table>
              <thead>
                <tr>
                  <td>
                    <input type="checkbox" name="table-header" />
                  </td>
                  <td>H1</td>
                  <td>H2</td>
                  <td>H3</td>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>
                    <input type="checkbox" name="table-box1" />
                  </td>
                  <td>A1</td>
                  <td>B1</td>
                  <td>C1</td>
                </tr>
                <tr>
                  <td>
                    <input type="checkbox" name="table-box2" />
                  </td>
                  <td>A2</td>
                  <td>B2</td>
                  <td>C2</td>
                </tr>
                <tr>
                  <td>
                    <input type="checkbox" name="table-box3" />
                  </td>
                  <td>A3</td>
                  <td>B3</td>
                  <td>C3</td>
                </tr>
              </tbody>
              <tfoot>
                <tr>
                  <td>
                    <input type="checkbox" name="table-footer" />
                  </td>
                  <td>F1</td>
                  <td>F2</td>
                  <td>F3</td>
                </tr>
              </tfoot>
            </table>

        This function adds a table selector to the Form Element.
        Users must specify a position, type, type_name, header_list, body_list, and footer list.

        position: 'left' or 'right',
        type: 'checkbox' or 'button'

        """
        doc, tag, text, line = Doc().ttl()
        with tag('table'):
            with tag('thead'):
                with tag('tr'):
                    if position == 'left':
                        if type == 'button':
                            line('td', 'Select')
                            for i in table_selector:
                                for j in header_list:
                                    line('td', j)
                        else:
                            with tag('td'):
                                doc.input(name='table-header', type='checkbox')
                                for j in header_list:
                                    line('td', j)
                    else:
                        if type == 'button':
                            for j in header_list:
                                line('td', j)
                            line('td', 'Select')

                        else:
                            for i in table_selector:
                                for j in header_list:
                                    line('td', j)
                            with tag('td'):
                                doc.input(name='table-header', type='checkbox')

            with tag('tbody'):
                for num, j in enumerate(body_list, start=1):
                    with tag('tr'):
                        if position == 'left':
                            with tag('td'):
                                if type == 'button':
                                    with tag('button',
                                             name=type_name + str(num)):
                                        text('Button')
                                else:
                                    doc.input(name=type_name + str(num),
                                              type='checkbox')
                            for k in j:
                                line('td', k)
                        else:
                            for k in j:
                                line('td', k)
                            with tag('td'):
                                if type == 'button':
                                    with tag('button',
                                             name=type_name + str(num)):
                                        text('Button')
                                else:
                                    doc.input(name=type_name + str(num),
                                              type='checkbox')

            with tag('tfoot'):
                with tag('tr'):
                    if position == 'left':
                        with tag('td'):
                            if type == 'button':
                                with tag('button', name="footer"):
                                    text('Button')
                            else:
                                doc.input(name='table-footer', type='checkbox')
                        for j in footer_list:
                            line('td', j)
                    else:
                        for j in footer_list:
                            line('td', j)
                        with tag('td'):
                            if type == 'button':
                                with tag('button', name="footer"):
                                    text('Button')
                            else:
                                doc.input(name='table-footer', type='checkbox')

        self.messageML += doc.getvalue()
Example #29
0
def lambda_handler(event, context):

    global visitorcount
    visitorcount += 1
    print("You're the " + str(visitorcount) + " visitor")

    configuration = yaml.load(open("config.yaml").read())
    questions = configuration['Questions']
    title = configuration['Title']
    author = configuration['Author']
    image = configuration['Image']
    theme = configuration['Theme']

    questionsNames = list()
    for questionIterator in questions:
        questionsNames.append(questionIterator)
    questionsNames.sort()

    doc, tag, text = Doc().tagtext()

    with tag('html'):
        with tag('body'):

            doc.stag('br')
            doc.stag('br')
            doc.stag('br')

            with tag('div', align='center'):
                doc.stag(
                    'font',
                    size="6",
                    style="font-weight: bold; font-family: verdana; color:#" +
                    str(theme) + ";")
                text(title)
                doc.stag('br')
                doc.stag('font',
                         size="2",
                         style="font-weight: bold; font-family: verdana")
                text("by " + author)
                doc.stag('br')
                doc.stag('img', src=image, width="500")
                doc.stag('br')
                doc.stag('br')

            with tag('form', action="submitsurvey"):
                with tag('div',
                         style=
                         "margin-left: auto; margin-right: auto; width: 40%;"):
                    for questionName in questionsNames:
                        questionLabel = questions[questionName]['Label']
                        questionType = questions[questionName]['Type']

                        doc.stag(
                            'font',
                            size="4",
                            style=
                            "font-weight: bold; font-family: verdana; color:#"
                            + str(theme) + ";")
                        text(questionLabel)
                        doc.stag('br')

                        if (questionType == "Text"):
                            with doc.textarea(
                                    name=questionName,
                                    style="width: 100%; border-color: #" +
                                    str(theme) + "; ",
                                    rows="5"):
                                pass

                        if (questionType == "ShortText"):
                            with doc.textarea(
                                    name=questionName,
                                    style="width: 100%; border-color: #" +
                                    str(theme) + "; ",
                                    rows="1"):
                                pass

                        if (questionType == "Radio"):
                            values = questions[questionName]['Values']
                            for valueIterator in values:
                                value = questions[questionName]['Values'][
                                    valueIterator]
                                doc.input(name=questionName,
                                          type='radio',
                                          value=value,
                                          style="border-color: #" +
                                          str(theme) + "; ")
                                doc.stag(
                                    'font',
                                    size="2",
                                    style=
                                    "font-weight: normal; font-family: verdana; color:black"
                                )
                                text(str(value))
                                doc.stag('br')

                        doc.stag('br')
                        doc.stag('br')

                    doc.stag(
                        'input',
                        type="submit",
                        value="Send!",
                        style="background-color: #" + str(theme) +
                        "; border: none; color: white; float: right; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer;"
                    )

    htmlResult = doc.getvalue()

    return {
        'statusCode': "200",
        'body': htmlResult,
        'headers': {
            'Content-Type': 'text/html',
        }
    }
Example #30
0
def lambda_handler(event, context):

    configuration = yaml.load(open("config.yaml").read())
    questions = configuration['Questions']
    title = configuration['Title']
    author = configuration['Author']
    image = configuration['Image']
    theme = configuration['Theme']

    questionsNames = list()
    for questionIterator in questions:
        questionsNames.append(questionIterator)
    questionsNames.sort()

    doc, tag, text = Doc().tagtext()

    with tag('html'):
        with tag('body'):

            doc.stag('br')
            doc.stag('br')
            doc.stag('br')

            with tag('div', align='center'):
                with doc.tag(
                        'div',
                        style=
                        "font-size: medium;font-weight: bold; font-family: verdana; color:#"
                        + str(theme) + ";"):
                    text(title)
                    doc.stag('br')
                with doc.tag(
                        'div',
                        style=
                        "font-size: small; font-weight: bold; font-family: verdana;"
                ):
                    text("by " + author)
                    doc.stag('br')
                    doc.stag('img', src=image, width="500")
                    doc.stag('br')
                    doc.stag('br')

            with tag('form',
                     action="submitsurvey",
                     style="margin-left: auto; margin-right: auto; width: 70%;"
                     ):
                for questionName in questionsNames:
                    with tag('div'):
                        questionLabel = questions[questionName]['Label']
                        questionType = questions[questionName]['Type']

                        #doc.stag('font', size="4", style="font-weight: bold; font-family: verdana; color:#" + str(theme) + ";")
                        with doc.tag(
                                'div',
                                style=
                                "font-size: medium;font-weight: bold; font-family: verdana; color:#"
                                + str(theme) + ";"):
                            doc.asis(questionLabel)
                            doc.stag('br')

                        if (questionType == "Text"):
                            with doc.textarea(
                                    name=questionName,
                                    style="width: 100%; border-color: #" +
                                    str(theme) + "; ",
                                    rows="5"):
                                pass

                        if (questionType == "ShortText"):
                            with doc.textarea(
                                    name=questionName,
                                    style="width: 100%; border-color: #" +
                                    str(theme) + "; ",
                                    rows="1"):
                                pass

                        if (questionType == "Radio"):
                            values = questions[questionName]['Values']
                            for valueIterator in values:
                                value = questions[questionName]['Values'][
                                    valueIterator]
                                with doc.tag(
                                        'div',
                                        style=
                                        "font-size: small; font-weight: normal; font-family: verdana; color:black;"
                                ):
                                    doc.input(name=questionName,
                                              type='radio',
                                              value=value,
                                              style="border-color: #" +
                                              str(theme) + "; ")
                                    text(" " + str(value))
                                    doc.stag('br')

                        if (questionType == "CheckBox"):
                            with tag(
                                    'fieldset',
                                    style=
                                    "border: 0px; padding: 0px; font-size: small; font-weight: normal; font-family: verdana; color:black;"
                            ):
                                values = list(
                                    questions[questionName]['Values'])
                                for valueIterator in values:
                                    value = questions[questionName]['Values'][
                                        valueIterator]
                                    field_name = questionName + "_" + "".join([
                                        c if c.isalnum() else "_"
                                        for c in value.lower()
                                    ])
                                    doc.input(name=field_name,
                                              type='hidden',
                                              value="0",
                                              style="border-color: #" +
                                              str(theme) + "; ")
                                    doc.input(name=field_name,
                                              id=field_name,
                                              type='checkbox',
                                              value="1",
                                              style="border-color: #" +
                                              str(theme) + "; ")
                                    text(" " + str(value))
                                    doc.stag('br')

                        doc.stag('br')
                        doc.stag('br')

                doc.stag(
                    'input',
                    type="submit",
                    value="Send!",
                    style="background-color: #" + str(theme) +
                    "; border: none; color: white; float: right; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer;"
                )

    htmlResult = doc.getvalue()

    return {
        'statusCode': "200",
        'body': htmlResult,
        'headers': {
            'Content-Type': 'text/html',
        }
    }
Example #31
0
def page(S=None):
    doc, tag, text = Doc().tagtext()
    Data = readForm()
    if S:
        S.Set('eidOnWork', '')
        eleRecherche = Data['txt_recherche']
        Records = db.readRecords(S.Get('eID'), parametres.Database, 'Personne',
                                 [('eid', '=', eleRecherche)],
                                 ['eid', 'nom', 'prenom'])
        with tag('div', klass='wrapper'):
            doc, tag, text = mod_menu.sidebar(doc, tag, text)
            with tag('div', id='content'):
                with tag('div', klass='container-fluid'):
                    if len(Records):
                        with tag('div', klass='list-group'):
                            text(str(Records))

                        with tag('div'):
                            with tag('div', klass='container-fluid ajouter'):

                                with tag('form'):
                                    """ajouter sujet"""
                                    with tag('row', id="ajouter_sujet"):

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):

                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag('textarea',
                                                         placeholder='Titre'):
                                                    pass
                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag(
                                                        'textarea',
                                                        placeholder='Descriptif'
                                                ):
                                                    pass

                                        with tag('row', klass=' top-buffer'):

                                            with tag('div',
                                                     klass='row col-sm-10 '):
                                                """Afficher dynamiquement les programmes"""
                                                with tag('div',
                                                         klass='col-sm-2'):
                                                    with tag('div',
                                                             id="programmes"):
                                                        text('Programmes : ')
                                                        with tag('div'):
                                                            for p in programme:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =p,
                                                                            value
                                                                            ='0',
                                                                            onclick
                                                                            ='afficherFilFin()'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round',
                                                                                id
                                                                                =p
                                                                                +
                                                                                '1'
                                                                        ):
                                                                            text(
                                                                                p
                                                                            )
                                                """Afficher dynamiquement les filières"""
                                                with tag('div',
                                                         klass=
                                                         'filiere col-sm-2',
                                                         id='FiliereFin'):
                                                    with tag('div'):
                                                        text('Filiére : ')
                                                        with tag('div'):
                                                            for f in programme[
                                                                    'Finances']:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =f,
                                                                            value
                                                                            ='0'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round'
                                                                        ):
                                                                            text(
                                                                                f
                                                                            )
                                        """Ajotuer fichier annexe"""
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            text('Ajouter un fichier annexe')
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            with tag('input', type='file'):
                                                pass
                                        """Etablir min et max etudiants"""
                                        # with tag('row', klass='row justify-content-center top-buffer'):
                                        # with tag('div', id='nbr_min_etus'):
                                        # with tag('input', type='number', placeholder='Nbr. min d\'étudiants'):pass

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):
                                            with tag('div', id='nbr_max_etus'):
                                                with tag(
                                                        'input',
                                                        type='number',
                                                        placeholder=
                                                        'Nbr. max d\'étudiants',
                                                        min='1'):
                                                    pass
                                        """ligne pour bouton 'enregistrer"""
                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):
                                            with tag('div'):
                                                with tag('a', href=''):
                                                    with tag(
                                                            'img',
                                                            src=
                                                            "./dist/images/check.png"
                                                    ):
                                                        pass
                            """ZONE SUJET EXISTANTS MODIFIABLES"""
                            """AJOUTER UNE UNE BOUCLE POUR LE NBR DE SUJETS"""

                            with tag('div', klass='container-fluid '):
                                with tag('br'):
                                    with tag('h3', klass='text-center'):
                                        text('Sujet 1')

                                    with tag('label', klass='switch '):
                                        doc.input(type='checkbox',
                                                  name=p,
                                                  value='1')
                                        with tag('span',
                                                 klass='slider round',
                                                 id=p + '1'):
                                            text('Actif')
                                with tag('form'):
                                    with tag('row', id="ajouter_sujet"):

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):

                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag('textarea',
                                                         placeholder='Titre'):
                                                    pass
                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag(
                                                        'textarea',
                                                        placeholder='Descriptif'
                                                ):
                                                    pass

                                        with tag('row', klass=' top-buffer'):

                                            with tag('div',
                                                     klass='row col-sm-10 '):
                                                """Afficher dynamiquement les programmes"""
                                                with tag('div',
                                                         klass='col-sm-2'):
                                                    with tag('div',
                                                             id="programmes"):
                                                        text('Programmes : ')
                                                        with tag('div'):
                                                            for p in programme:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =p,
                                                                            value
                                                                            ='0',
                                                                            onclick
                                                                            ='afficherFilFin()'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round',
                                                                                id
                                                                                =p
                                                                                +
                                                                                '1'
                                                                        ):
                                                                            text(
                                                                                p
                                                                            )
                                                """Afficher dynamiquement les filières"""
                                                with tag('div',
                                                         klass=
                                                         'filiere col-sm-2',
                                                         id='FiliereFin'):
                                                    with tag('div'):
                                                        text('Filiére : ')
                                                        with tag('div'):
                                                            for f in programme[
                                                                    'Finances']:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =f,
                                                                            value
                                                                            ='0'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round'
                                                                        ):
                                                                            text(
                                                                                f
                                                                            )
                                        """Ajotuer fichier annexe"""
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            text('Ajouter un fichier annexe')
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            with tag('input', type='file'):
                                                pass
                                        """Etablir min et max etudiants"""
                                        # with tag('row', klass='row justify-content-center top-buffer'):
                                        # with tag('div', id='nbr_min_etus'):
                                        # with tag('input', type='number', placeholder='Nbr. min d\'étudiants'):pass

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):
                                            with tag('div', id='nbr_max_etus'):
                                                with tag(
                                                        'input',
                                                        type='number',
                                                        placeholder=
                                                        'Nbr. max d\'étudiants',
                                                        min='1'):
                                                    pass

                            with tag('div', klass='container-fluid '):
                                with tag('br'):
                                    with tag('h3', klass='text-center'):
                                        text('Sujet 2')

                                    with tag('label', klass='switch '):
                                        doc.input(type='checkbox',
                                                  name=p,
                                                  value='1')
                                        with tag('span',
                                                 klass='slider round',
                                                 id=p + '1'):
                                            text('Actif')
                                with tag('form'):
                                    with tag('row', id="ajouter_sujet"):

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):

                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag('textarea',
                                                         placeholder='Titre'):
                                                    pass
                                            with tag(
                                                    'row',
                                                    klass=
                                                    'col-sm-10 text-center mod_width_textarea'
                                            ):
                                                with tag(
                                                        'textarea',
                                                        placeholder='Descriptif'
                                                ):
                                                    pass

                                        with tag('row', klass=' top-buffer'):

                                            with tag('div',
                                                     klass='row col-sm-10 '):
                                                """Afficher dynamiquement les programmes"""
                                                with tag('div',
                                                         klass='col-sm-2'):
                                                    with tag('div',
                                                             id="programmes"):
                                                        text('Programmes : ')
                                                        with tag('div'):
                                                            for p in programme:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =p,
                                                                            value
                                                                            ='0',
                                                                            onclick
                                                                            ='afficherFilFin()'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round',
                                                                                id
                                                                                =p
                                                                                +
                                                                                '1'
                                                                        ):
                                                                            text(
                                                                                p
                                                                            )
                                                """Afficher dynamiquement les filières"""
                                                with tag('div',
                                                         klass=
                                                         'filiere col-sm-2',
                                                         id='FiliereFin'):
                                                    with tag('div'):
                                                        text('Filiére : ')
                                                        with tag('div'):
                                                            for f in programme[
                                                                    'Finances']:
                                                                with tag(
                                                                        'div'):
                                                                    with tag(
                                                                            'label',
                                                                            klass
                                                                            ='switch'
                                                                    ):
                                                                        doc.input(
                                                                            type
                                                                            ='checkbox',
                                                                            name
                                                                            =f,
                                                                            value
                                                                            ='0'
                                                                        )
                                                                        with tag(
                                                                                'span',
                                                                                klass
                                                                                ='slider round'
                                                                        ):
                                                                            text(
                                                                                f
                                                                            )
                                        """Ajotuer fichier annexe"""
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            text('Ajouter un fichier annexe')
                                        with tag(
                                                'div',
                                                klass=
                                                'top-buffer row justify-content-center'
                                        ):
                                            with tag('input', type='file'):
                                                pass
                                        """Etablir min et max etudiants"""
                                        # with tag('row', klass='row justify-content-center top-buffer'):
                                        # with tag('div', id='nbr_min_etus'):
                                        # with tag('input', type='number', placeholder='Nbr. min d\'étudiants'):pass

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):
                                            with tag('div', id='nbr_max_etus'):
                                                with tag(
                                                        'input',
                                                        type='number',
                                                        placeholder=
                                                        'Nbr. max d\'étudiants',
                                                        min='1'):
                                                    pass

                    else:
                        text(
                            'Personne ne correspond aux critères de recherche')
                    """Il faut faire la page avec une zone :
                        ajouter sujet SI click sur icone
                        sujet avec toutes ses caractérisitques et modifiable SI il y a des sujets
                        il ne faut pas oublier la case à cocher
                        """

        with tag('script', src="dist/js/myjs.js"):
            pass
        with tag('stylesheet', src='./dist/css/mycss.css'):
            pass

        webPage(Page=doc, Session=S)
    else:
        webPage(doc)
def page(S=None):
    doc, tag, text = Doc().tagtext()
    if S:
        with tag('div', klass='wrapper'):
            doc, tag, text = prof_menu.sidebar(doc, tag, text)
            with tag('div', id='content'):
                with tag('div', klass='container-fluid ajouter'):

                    with tag('form'):
                        """ajouter sujet"""
                        with tag('row', id="ajouter_sujet", klass='cacher'):

                            # """Demander si le sujet sera actif pendant des années"""
                            # with tag('div', klass='row justify-content-center top-buffer'):
                            # with tag('div', klass='col-sm-4 text-center'):
                            # with tag('label', klass='switch'):
                            # doc.input( type = 'checkbox', name = 'valable_des_annees', value = '0')
                            # with tag('span',klass='slider round'):
                            # text('Sujet valable plusieures années ?')

                            with tag('row',
                                     klass=
                                     'row justify-content-center top-buffer'):

                                with tag(
                                        'row',
                                        klass=
                                        'col-sm-10 text-center mod_width_textarea'
                                ):
                                    with tag('textarea', placeholder='Titre'):
                                        pass
                                with tag(
                                        'row',
                                        klass=
                                        'col-sm-10 text-center mod_width_textarea'
                                ):
                                    with tag('textarea',
                                             placeholder='Descriptif'):
                                        pass

                            with tag('row', klass=' top-buffer'):

                                with tag('div', klass='row'):
                                    """Afficher dynamiquement les programmes"""
                                    with tag('div', klass='col-6 text-center'):
                                        with tag('div', id="programmes"):
                                            text('Programmes : ')
                                            with tag('div'):
                                                for p in programme:
                                                    with tag('div'):
                                                        # , klass='switch'):
                                                        with tag('label'):
                                                            doc.input(
                                                                type='checkbox',
                                                                name=p,
                                                                value='0',
                                                                onclick=
                                                                'afficherFilFin()'
                                                            )
                                                            with tag('span',
                                                                     id=p +
                                                                     '1'):
                                                                text(p)
                                    """Afficher dynamiquement les filières"""
                                    with tag('div',
                                             klass='filiere col-6 text-center',
                                             id='FiliereFin'):
                                        with tag('div'):
                                            text('Filiére : ')
                                            with tag('div'):
                                                for f in programme['Finances']:
                                                    with tag('div'):
                                                        with tag('label'):
                                                            doc.input(
                                                                type='checkbox',
                                                                name=f,
                                                                value='0')
                                                            with tag('span'):
                                                                text(f)

                            with tag('div', klass='row'):

                                with tag('div', klass='col-4 text-center'):
                                    """Ajouter fichier annexe"""
                                    with tag(
                                            'div',
                                            klass=
                                            'top-buffer row justify-content-center'
                                    ):
                                        text('Ajouter un fichier annexe')
                                    with tag(
                                            'br',
                                            klass=
                                            'top-buffer row justify-content-center'
                                    ):
                                        with tag('input', type='file'):
                                            pass
                                """Etablir min et max etudiants"""
                                # with tag('row', klass='row justify-content-center top-buffer'):
                                # with tag('div', id='nbr_min_etus'):
                                # with tag('input', type='number', placeholder='Nbr. min d\'étudiants'):pass
                                with tag('div', klass='col-4 text-center'):
                                    with tag(
                                            'div',
                                            klass=
                                            'top-buffer row justify-content-center'
                                    ):
                                        text(
                                            'Décider le nombre d\'étudiant qui pourront avoic ce sujet'
                                        )
                                    with tag(
                                            'br',
                                            klass=
                                            'row justify-content-center top-buffer'
                                    ):
                                        with tag('div', id='nbr_max_etus'):
                                            with tag('input',
                                                     type='number',
                                                     placeholder=
                                                     'Nbr. max d\'étudiants',
                                                     min='1'):
                                                pass

                                with tag('div', klass='col-4 text-center'):
                                    with tag(
                                            'div',
                                            klass=
                                            'top-buffer row justify-content-center'
                                    ):
                                        text(
                                            'Année académique pour laquelle le sujet sera disponible'
                                        )
                                    with tag('div'):
                                        doc.input(type='checkbox',
                                                  name=p,
                                                  value='0')
                                        with tag('span', id='2020-2021'):
                                            text('2020-2021')
                                    with tag('div'):
                                        doc.input(type='checkbox',
                                                  name=p,
                                                  value='0')
                                        with tag('span', id='2021-2022'):
                                            text('2021-2022')
                                    with tag('div'):
                                        doc.input(type='checkbox',
                                                  name=p,
                                                  value='0')
                                        with tag('span', id='2022-2023'):
                                            text('2022-2023')
                            """ligne pour bouton 'enregistrer"""
                            with tag('div',
                                     klass=
                                     'row justify-content-center top-buffer'):
                                with tag('div'):
                                    with tag('a', href=''):
                                        with tag(
                                                'img',
                                                src="./dist/images/check.png"):
                                            pass

        with tag('script', src="dist/js/myjs.js"):
            pass
        with tag('stylesheet', src='./dist/css/mycss.css'):
            pass

        webPage(Page=doc, Session=S, CSS='dist/css/mycss.css', JS='myjs.js')
    else:
        webPage(doc)
Example #33
0
 def test_input_no_slash(self):
     doc = Doc(stag_end='>')
     doc.input('passw', type="password")
     self.assertTrue(
         doc.getvalue() in ('<input name="passw" type="password">',
                            '<input type="password" name="passw">'))
Example #34
0
def page(S=None):
    doc, tag, text = Doc().tagtext()
    if S:
        with tag('div', klass='wrapper'):
            doc, tag, text = prof_menu.sidebar(doc, tag, text)
            with tag('div', id='content'):
                with tag('div', klass='container-fluid ajouter'):

                    with tag(
                            'table',
                            id='table_prof_sujet',
                            klass=
                            "table table-striped table-bordered table-sm top-buffer",
                            cellspacing="0",
                            width="100%"):
                        with tag('thead'):
                            with tag('tr', klass='text-center'):
                                with tag('th', cope="col"):
                                    text('Actif')
                                with tag('th', cope="col"):
                                    text('Titre')
                                with tag('th', scope="col"):
                                    text('Programme')
                                with tag('th', scope="col"):
                                    text('Filière')
                                with tag('th',
                                         scope="col",
                                         klass='text-center'):
                                    text('Modifier')
                                with tag('th',
                                         scope="col",
                                         klass='text-center'):
                                    text('Supprimer')

                        with tag('tbody'):
                            """A FAIRE UNE BOUCLE POUR LES sujets"""
                            with tag('tr'):
                                with tag('td',
                                         scope="col",
                                         klass='text-center'):
                                    with tag('input',
                                             type='checkbox',
                                             value='0'):
                                        pass
                                with tag('td', scope="col"):
                                    with tag(
                                            'textarea',
                                            klass='disable_text text',
                                            placeholder='Sujet sur les tomates'
                                    ):
                                        pass
                                with tag('td', scope="col"):
                                    with tag('textarea',
                                             klass='disable_text text',
                                             placeholder='Agriculture'):
                                        pass
                                with tag('td', scope="col"):
                                    with tag('textarea',
                                             klass='disable_text text',
                                             placeholder='Eco'):
                                        pass
                                with tag('td',
                                         scope="col",
                                         klass='mouse_hand text-center'):
                                    with tag('img',
                                             src='./dist/images/pencil.png',
                                             id="myBtn"):
                                        pass
                                with tag('td',
                                         scope="col",
                                         klass='mouse_hand text-center'):
                                    with tag('img',
                                             src='./dist/images/bin.png',
                                             onclick='change()'):
                                        pass
                                """ MODAL """
                                with tag('div', id='myModal', klass='modal'):
                                    with tag('div', klass='modal-content'):
                                        with tag('span', klass='close'):
                                            text("Fermer")

                                        with tag(
                                                'row',
                                                klass=
                                                'row justify-content-center top-buffer'
                                        ):

                                            with tag('form'):
                                                """ajouter sujet"""
                                                with tag('row',
                                                         id="ajouter_sujet",
                                                         klass='cacher'):

                                                    # """Demander si le sujet sera actif pendant des années"""
                                                    # with tag('div', klass='row justify-content-center top-buffer'):
                                                    # with tag('div', klass='col-sm-4 text-center'):
                                                    # with tag('label', klass='switch'):
                                                    # doc.input( type = 'checkbox', name = 'valable_des_annees', value = '0')
                                                    # with tag('span',klass='slider round'):
                                                    # text('Sujet valable plusieures années ?')

                                                    with tag(
                                                            'row',
                                                            klass=
                                                            'row justify-content-center top-buffer'
                                                    ):

                                                        with tag(
                                                                'row',
                                                                klass=
                                                                'col-sm-10 text-center mod_width_textarea'
                                                        ):
                                                            with tag(
                                                                    'textarea',
                                                                    placeholder
                                                                    ='Titre'):
                                                                pass
                                                        with tag(
                                                                'row',
                                                                klass=
                                                                'col-sm-10 text-center mod_width_textarea'
                                                        ):
                                                            with tag(
                                                                    'textarea',
                                                                    placeholder=
                                                                    'Descriptif'
                                                            ):
                                                                pass

                                                    with tag(
                                                            'row',
                                                            klass=' top-buffer'
                                                    ):

                                                        with tag('div',
                                                                 klass='row'):
                                                            """Afficher dynamiquement les programmes"""
                                                            with tag(
                                                                    'div',
                                                                    klass=
                                                                    'col-6 text-center'
                                                            ):
                                                                with tag(
                                                                        'div',
                                                                        id=
                                                                        "programmes"
                                                                ):
                                                                    text(
                                                                        'Programmes : '
                                                                    )
                                                                    with tag(
                                                                            'div'
                                                                    ):
                                                                        for p in programme:
                                                                            with tag(
                                                                                    'div'
                                                                            ):
                                                                                # , klass='switch'):
                                                                                with tag(
                                                                                        'label'
                                                                                ):
                                                                                    doc.input(
                                                                                        type
                                                                                        ='checkbox',
                                                                                        name
                                                                                        =p,
                                                                                        value
                                                                                        ='0',
                                                                                        onclick
                                                                                        ='afficherFilFin()'
                                                                                    )
                                                                                    with tag(
                                                                                            'span',
                                                                                            id
                                                                                            =p
                                                                                            +
                                                                                            '1'
                                                                                    ):
                                                                                        text(
                                                                                            p
                                                                                        )
                                                            """Afficher dynamiquement les filières"""
                                                            with tag(
                                                                    'div',
                                                                    klass=
                                                                    'filiere col-6 text-center',
                                                                    id=
                                                                    'FiliereFin'
                                                            ):
                                                                with tag(
                                                                        'div'):
                                                                    text(
                                                                        'Filiére : '
                                                                    )
                                                                    with tag(
                                                                            'div'
                                                                    ):
                                                                        for f in programme[
                                                                                'Finances']:
                                                                            with tag(
                                                                                    'div'
                                                                            ):
                                                                                with tag(
                                                                                        'label'
                                                                                ):
                                                                                    doc.input(
                                                                                        type
                                                                                        ='checkbox',
                                                                                        name
                                                                                        =f,
                                                                                        value
                                                                                        ='0'
                                                                                    )
                                                                                    with tag(
                                                                                            'span'
                                                                                    ):
                                                                                        text(
                                                                                            f
                                                                                        )

                                                    with tag('div',
                                                             klass='row'):

                                                        with tag(
                                                                'div',
                                                                klass=
                                                                'col-4 text-center'
                                                        ):
                                                            """Ajouter fichier annexe"""
                                                            with tag(
                                                                    'div',
                                                                    klass=
                                                                    'top-buffer row justify-content-center'
                                                            ):
                                                                text(
                                                                    'Ajouter un fichier annexe'
                                                                )
                                                            with tag(
                                                                    'br',
                                                                    klass=
                                                                    'top-buffer row justify-content-center'
                                                            ):
                                                                with tag(
                                                                        'input',
                                                                        type=
                                                                        'file'
                                                                ):
                                                                    pass
                                                        """Etablir min et max etudiants"""
                                                        # with tag('row', klass='row justify-content-center top-buffer'):
                                                        # with tag('div', id='nbr_min_etus'):
                                                        # with tag('input', type='number', placeholder='Nbr. min d\'étudiants'):pass
                                                        with tag(
                                                                'div',
                                                                klass=
                                                                'col-4 text-center'
                                                        ):
                                                            with tag(
                                                                    'div',
                                                                    klass=
                                                                    'top-buffer row justify-content-center'
                                                            ):
                                                                text(
                                                                    'Décider le nombre d\'étudiant qui pourront avoic ce sujet'
                                                                )
                                                            with tag(
                                                                    'br',
                                                                    klass=
                                                                    'row justify-content-center top-buffer'
                                                            ):
                                                                with tag(
                                                                        'div',
                                                                        id=
                                                                        'nbr_max_etus'
                                                                ):
                                                                    with tag(
                                                                            'input',
                                                                            type
                                                                            ='number',
                                                                            placeholder
                                                                            ='Nbr. max d\'étudiants',
                                                                            min=
                                                                            '1'
                                                                    ):
                                                                        pass

                                                        with tag(
                                                                'div',
                                                                klass=
                                                                'col-4 text-center'
                                                        ):
                                                            with tag(
                                                                    'div',
                                                                    klass=
                                                                    'top-buffer row justify-content-center'
                                                            ):
                                                                text(
                                                                    'Année académique pour laquelle le sujet sera disponible'
                                                                )
                                                            with tag('div'):
                                                                doc.input(
                                                                    type=
                                                                    'checkbox',
                                                                    name=p,
                                                                    value='0')
                                                                with tag(
                                                                        'span',
                                                                        id=
                                                                        '2020-2021'
                                                                ):
                                                                    text(
                                                                        '2020-2021'
                                                                    )
                                                            with tag('div'):
                                                                doc.input(
                                                                    type=
                                                                    'checkbox',
                                                                    name=p,
                                                                    value='0')
                                                                with tag(
                                                                        'span',
                                                                        id=
                                                                        '2021-2022'
                                                                ):
                                                                    text(
                                                                        '2021-2022'
                                                                    )
                                                            with tag('div'):
                                                                doc.input(
                                                                    type=
                                                                    'checkbox',
                                                                    name=p,
                                                                    value='0')
                                                                with tag(
                                                                        'span',
                                                                        id=
                                                                        '2022-2023'
                                                                ):
                                                                    text(
                                                                        '2022-2023'
                                                                    )
                                                    """ligne pour bouton 'enregistrer"""
                                                    with tag(
                                                            'div',
                                                            klass=
                                                            'row justify-content-center top-buffer'
                                                    ):
                                                        with tag('div'):
                                                            with tag('a',
                                                                     href=''):
                                                                with tag(
                                                                        'img',
                                                                        src=
                                                                        "./dist/images/check.png"
                                                                ):
                                                                    pass
                                """MODAL FIN"""

                            # """ICI IL FAUT UNE BOUCLE QUI VA GENERER LES SUJETS"""
                            # with tag('tr'):
                            # with tag('td', klass='col-lg-8 top buffer-top'):
                            # with tag('input', type='checkbox', value='0', onchange='sujet_actif()'):pass
                            # with tag('td', klass='col-lg-8 top buffer-top'):
                            # with tag('textarea', name = 'titre', klass='disable_text '):
                            # text('Titre : ' + 'Ceci est un titre')
                            # with tag('td', klass='col-lg-1'):
                            # with tag('img', src='./dist/images/down_arrow_small.png', onclick='afficher_details_sujet()'):pass
                            # with tag('td', klass='col-lg-1'):
                            # with tag('img', src="./dist/images/pencil.png"):pass
                            # with tag('td', klass='col-lg-1 content-center', id='nbr_etus'):

                            # """IL FAUT ALLER CHERCHER LA SOMMES DES ETUS PAR SUJET"""

                            # with tag('div', klass="nbr_etus"):
                            # with tag('input', name = 'nbr_etus', type='number', klass='disable_text hover', value="5"):pass

                            # with tag('td', klass='col-lg-1'):
                            # with tag('img', src="./dist/images/bin.png"):pass

                            # with tag('tr', id = 'details_sujet'):

                            # with tag('row'):
                            # with tag('div'):

                            # with tag('td', klass='col-sm-9'):
                            # with tag('textarea', name = 'descriptif', placeholder = 'Descriptif : ' + 'qsdqsdqsdqsdqsdqsdqsd', klass='disable_text '):
                            # text('Descriptif : ' + 'Ceci est un descriptif')

                            # with tag('td', klass='col-sm-1'):
                            # """Afficher dynamiquement les programmes"""
                            # with tag('div', klass='top-buffer col-sm-1'):
                            # text('Programmes : ')
                            # with tag('div'):
                            # for p in programme:
                            # with tag('div'):
                            # with tag('label', klass='switch'):
                            # doc.input( type = 'checkbox', name = p, value = '0', onclick='afficherFil()')
                            # with tag('span', klass='slider round', id=p+'1'):
                            # text(p)

                            # with tag('td', klass='col-sm-1'):
                            # """Afficher dynamiquement les filières"""
                            # with tag('div', klass='top-buffer filiere col-sm-1', id='FiliereInfo'):
                            # text('Filiére : ')
                            # with tag('div'):
                            # for f in programme['Finances']:
                            # with tag('div'):
                            # with tag('label', klass='switch'):
                            # doc.input( type = 'checkbox', name = f, value = '0')
                            # with tag('span',klass='slider round'):
                            # text(f)

                            # with tag('td', klass='col-sm-1'):pass

                            # with tag('td', klass='col-sm-1'):pass

        with tag('script', src="./dist/js/prof_sujets.js"):
            pass
        with tag('script', src="./dist/js/prof_modal.js"):
            pass
        with tag('script', src="./dist/js/datatables.min.js"):
            pass
        with tag('script', src="./dist/js/datatables.js"):
            pass
        with tag('script', src='./dist/js/responsive.min.js'):
            pass
        with tag('stylesheet', src='./dist/css/modal.css'):
            pass

        webPage(Page=doc, Session=S, CSS='dist/css/mycss.css', JS='myjs.js')
    else:
        webPage(doc)