Beispiel #1
0
    def core_del_request_view (self, sid, params):
        dv = self.get_cache(sid, 'core_detail_request', 'dv')
        if not dv:
            dv = datavars.DataVarsCore()
            dv.importCore()
            dv.flIniFile()
            dv.Get('cl_req_id')

        dv.addGroup(_("Signature request deleted"),
            normal=('cl_req_id', 'cl_req_user_name', 'cl_req_ip', 'cl_req_mac',
              'cl_req_date', 'cl_req_location'),
            next_label=_("Done"))

        view = ViewInfo (dv)

        group = GroupField(name=_("Request details"),nextlabel=_("Done"),
                           last=True)
        group.fields = []
        group.fields.append(Field(
            name = "but2",
            label = "Delete",
            value = "core_del_request",
            element = "button"))
        view.groups.append(group)
        self.set_cache(sid, 'core_del_request', "vars", dv, smart=False)
        return view
Beispiel #2
0
    def core_change_group_view (self, sid, params):
        dv = self.get_cache(sid, 'core_change_group', 'dv')
        if not dv:
            dv = datavars.DataVarsCore()
            dv.importCore()
            dv.flIniFile()
            dv.Get('cl_group_name')

        dv.addGroup(_("Toggle groups"),
            normal=('cl_group_name', 'cl_group_rights'),
            next_label=_("Done"))

        view = ViewInfo(dv,viewparams=params)

        group = GroupField(name=_("Toggle groups"), nextlabel=_("Done"), \
                           last=True)
        group.fields = []
        group.fields.append(Field(
            name = "but2",
            label = "Confirm",
            value = "core_change_group",
            element = "button"))
        view.groups.append(group)
        self.set_cache(sid, 'core_change_group', "vars", dv, smart=False)
        return view
Beispiel #3
0
    def core_detail_group_view (self, sid, params):
        dv = self.get_cache(sid, 'core_detail_group', 'dv')
        if not dv:
            dv = datavars.DataVarsCore()
            dv.importCore()
            dv.flIniFile()
            dv.Get('cl_group_name')

        dv.addGroup(None,
            normal=('cl_group_name', 'cl_group_rights'))

        view = ViewInfo(dv,viewparams=params)

        group = GroupField(name='',last=True)
        group.fields = []
        group.fields.append(Field(
            name = "but0",
            label = _("Back"),
            value = "core_show_groups",
            element = "button"))
        group.fields.append(Field(
            name = "but1",
            label = _("Change"),
            value = "core_change_group",
            element = "button"))
        group.fields.append(Field(
            name = "but2",
            label = _("Delete"),
            value = "core_del_group",
            element = "button"))
        view.groups.append(group)
        self.set_cache(sid, 'core_show_groups', "vars", dv, smart=False)
        return view
Beispiel #4
0
 def __call__(self,selfobj,*args,**kwargs):
     try:
         return self.f(selfobj,*args,**kwargs)
     except BaseException as e:
         view = ViewInfo(groups=[])
         group = GroupField(name=_("Error"),last=True)
         group.fields = []
         group.fields.append(Field(
                 name = "error",
                 label = str(e),
                 default = 'color:red;',
                 element = "error"))
         view.groups.append(group)
         print "!!!!EXCEPTION!!!!"
         for i in apply(traceback.format_exception, sys.exc_info()):
             print i
         return view
Beispiel #5
0
        def __call__(self,*args,**kwargs):
            try:
                return self.f(*args,**kwargs)
            except BaseException as e:
                from calculate.core.server.api_types import ViewInfo,GroupField,Field
                view = ViewInfo(groups=[])
                group = GroupField(name=_("Error"),last=True)
                group.fields = []
                group.fields.append(Field(
                        name = "error",
                        label = str(e),
                        default = 'color:red;',
                        element = "error"))
                view.groups.append(group)
                if not any(isinstance(e,x) for x in skipException):
                    for i in apply(traceback.format_exception, sys.exc_info()):
                        print i,

                return view
Beispiel #6
0
    def test_view (self, sid, vp):
        #print '%%%%%% test_view, step', vp.step
        #print "expert = ", vp.expert
        step = vp.step
        expert = vp.expert
        if step == 7:
            step = None
        if step in [0, None]:
            view = ViewInfo(groups=[], has_brief = True)

            group = GroupField(name=_("Test Method"), nextlabel="To step 2",
                               last=False)
            group.fields = []

            group.fields.append(Field(
                    name = "name",
                    label = "YOUR NAME: ",
                    type = "str",
                    value = '',
                    opt = Option(['-n','--name'], 'NAME', 'your name'),
                    help = \
                    "Please enter your name",
                    element = "input"))
            group.fields.append(Field(
                    name = "times",
                    label = _("Time: "),
                    #type = "int",
                    type = "int",
                    value = '55',
                    help = \
                    "Enter the time",
                    #uncompatible = 'Tool tip text',
                    element = "input"))
            group.fields.append(Field(
                    name = "isopath",
                    label = _("select an ISO"),
                    value = '/var/calculate',
                    type = 'files',
                    help = \
                    "Enter the time",
                    element = "openfile"))
            group.fields.append(Field(
                    name = "isopath_file",
                    label = "select an ISO",
                    choice = ['one', 'two'],
                    comments = ['first', 'second'],
                    value = '/home/guest/1',
                    type = 'files',
                    help = \
                    "Enter the time",
                    element = "file"))
            group.fields.append(Field(
                    name = "Partition_table",
                    label = _("Mount Points: "),
                    element = "table",
                    type = 'writable',
                    # Table
                    tablevalue = Table(
                    head = ['Partition','Mount Point','Filesystem', \
                                     'Perform format','Label','Size'],
                    body = [['/dev/sda1','swap','swap','off',None,'4G'],\
                            ['/dev/sda2','/','reiserfs','on','CLD','10G'],\
                            ['/dev/sda3','/var/calculate','ext4','off',
                             None,'30G']],
                    values = [ChoiceValue(
                            typefield = 'combo',
                            values = ['/dev/sda1','/dev/sda2','/dev/sda3'],
                            comments = ['disk1','disk2','disk3']),
                            #onChanged = ['nothing',None,'get_body','get_body',\
                                         #'get_body','get_body']),

                            ChoiceValue(
                            typefield = 'comboEdit',
                            values = ['/','swap','/var/calculate'],
                            comments = ['root','swap','calc']),

                            ChoiceValue(
                            typefield = 'multichoice_add',
                            values = ['swap','reiserfs','ext4'],
                            comments = ['swap1','reiserfs1','ext41']),

                            ChoiceValue(
                            typefield = 'check',
                            values = ['on','off']),

                            ChoiceValue(
                            typefield = 'text',
                            values = ['/dev/sda1','/dev/sda2','/dev/sda3'],
                            comments = ['3Gb','','disk3'])],
                    )))
            group.fields.append(Field(
                    name = "Steps",
                    element = "table",
                    type = 'steps',
                    label = 'Brief preview',
                    help = '<b><i>help</b></i>',
                    value = 'install',
                    # Table
                    listvalue = ['go-previous',' ','system-log-out'],
                    tablevalue = Table(
                    head = ['Табличка','Второй шаг','Завершение'],
                    fields = ['install','','welcome'],
                    body = [['times','name','isopath','Partition_table','',\
                            'boolvariable2','boolvariable', 'combovariable', \
                            'combovariable2'],\
                            ['radiovariable2','radiovariable','comboEdit1', \
                            'comboEdit2', 'multichoice_add', 'multichoice'], \
                            ['comboLang']]
                    )))
            if expert:
                group.fields.append(Field(
                        name = "expert_open",
                        #label = "Advanced settings...",
                        type = "label",
                        help = \
                        "you not human? This is a anti-bot test",
                        value = 'open',
                        element = "expert"))
                group.fields.append(Field(
                        name = "boolvariable",
                        label = "you BOT?",
                        type = "bool",
                        value = 'on',
                        default = True,
                        help = \
                        "you not human? This is a anti-bot test",
                        element = "check"))
                group.fields.append(Field(
                        name = "boolvariable2",
                        label = "you BOT?",
                        type = "bool",
                        value = 'auto',
                        default = True,
                        help = \
                        "you not human? This is a anti-bot test",
                        element = "check_tristate"))
                group.fields.append(Field(
                        name = "combovariable",
                        label = "check city number: ",
                        choice = ['Moscow-1','Piter-2','---','New York-3','London-4'],
                        comments = ['Mos','Pit','---','New Yo','Lond'],
                        type = "str",
                        default = True,
                        value = 'New York-3',
                        help = \
                        "you not human? This is a anti-bot test",
                        element = "combo"))
                group.fields.append(Field(
                        name = "combovariable2",
                        label = "check city number: ",
                        choice = ['Moscow','Piter','New York','---','London'],
                        type = "str",
                        value = 'London',
                        default = True,
                        help = \
                        "you not human? This is a anti-bot test",
                        element = "comboEdit"))
            else:
                group.fields.append(Field(
                        name = "expert_close",
                        #label = "Advanced settings...",
                        type = "label",
                        help = \
                        "you not human? This is a anti-bot test",
                        value = 'close',
                        element = "expert"))
            #group.fields.append(Field(
                    #name = "Partition_table2",
                    #label = _("Mount Points: "),
                    #element = "table",
                    ##type = 'writable',
                    ## Table
                    #tablevalue = Table(
                    #head = ['Partition','Mount Point','Filesystem', \
                                     #'Perform format','Label','Size'],
                    #body = [['/dev/sda1','swap','swap','off',None,'4G'],\
                            #['/dev/sda2','/','reiserfs','on','CLD','10G'],\
                            #['/dev/sda3','/var/calculate','ext4','off',None,'30G']],
                    #values = [ChoiceValue(
                            #typefield = 'combo',
                            #values = ['/dev/sda1','/dev/sda2','/dev/sda3'],
                            #onChanged = ['nothing',None,'get_body','get_body',\
                                         #'get_body','get_body']),

                            #ChoiceValue(
                            #typefield = 'comboEdit',
                            #values = ['/','swap','/var/calculate']),

                            #ChoiceValue(
                            #typefield = 'multichoice_add',
                            #values = ['swap','reiserfs','ext4']),

                            #ChoiceValue(
                            #typefield = 'check',
                            #values = ['on','off'])]
                    #)))
            #group.fields.append(Field(
                    #name = "button_view1",
                    #label = _("Next Step"),
                    #value = 'test_view',
                    #element = "button"))

        if step in [1, None]:
            if not 'view' in locals():
                view = ViewInfo(groups=[])
            else:
                view.groups.append(group)

            group = GroupField(name="Other Settings",nextlabel="Next")
            group.fields = []

            group.fields.append(Field(
                    name = "radiovariable",
                    label = "check city: ",
                    choice = ['Moscow','Piter','New York','London'],
                    type = "str",
                    value = 'London',
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "radio"))
            group.fields.append(Field(
                    name = "radiovariable2",
                    label = "check village: ",
                    choice = ['aaaaaa','bbbb','ccccc','dddddd'],
                    comments = ['a','b','c','d'],
                    type = "str",
                    value = 'bbbb',
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "radio"))
            group.fields.append(Field(
                    name = "comboEdit1",
                    label = "check city number: ",
                    choice = ['M','P','N','L'],
                    comments = ['Moscow','Piter','New York','London'],
                    type = "str",
                    value = 'N',
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "combo"))
            group.fields.append(Field(
                    name = "comboEdit2",
                    label = "check population: ",
                    choice = ['1000','10000','500000','2000000'],
                    type = "str",
                    value = '10000',
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "combo"))
            group.fields.append(Field(
                    name = "multichoice",
                    label = "check population: ",
                    choice = ['1000','10000','500000','2000000','qwe','ert'],
                    type = "str",
                    listvalue = ['1000','ert'],
                    comments = ['Thousand',\
                            'Ten thousand smoothly and is less than a penny'],
                    default = False,
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "multichoice_add"))
            group.fields.append(Field(
                    name = "Partition_table",
                    label = "Mount Points: ",
                    element = "table",
                    type = 'writable',
                    # Table
                    tablevalue = Table(
                    head = ['Partition','Mount Point','Filesystem', \
                                        'Perform format','Label','Size'],
                    body = [['/dev/sda1','swap','swap','off',None,'4G'],\
                            ['/dev/sda2','/','reiserfs','on','CLD','10G'],\
                            ['/dev/sda3','/var/calculate','ext4','off',None,'30G']],
                    values = [ChoiceValue(
                            typefield = 'combo',
                            values = ['/dev/sda1','/dev/sda2','/dev/sda3'],
                            onChanged = ['nothing',None,'get_body','get_body',\
                                         'get_body','get_body']),

                            ChoiceValue(
                            typefield = 'comboEdit',
                            values = ['/','swap','/var/calculate']),

                            ChoiceValue(
                            typefield = 'multichoice_add',
                            values = ['swap','reiserfs','ext4']),

                            ChoiceValue(
                            typefield = 'check',
                            values = ['on','off'])]
                    )))
            if expert:
                group.fields.append(Field(
                        name = "expert_open",
                        #label = "Advanced settings...",
                        type = "label",
                        help = \
                        "you not human? This is a anti-bot test",
                        value = 'open',
                        element = "expert"))
                group.fields.append(Field(
                    name = "multichoice_add",
                    label = "check population: ",
                    choice = ['aa','bb','cc','dd'],
                    comments = ['America','Bosniya','Chine','Denmark'],
                    type = "str",
                    listvalue = ['bb','cc'],
                    default = True,
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "selecttable_add"))
            else:
                group.fields.append(Field(
                        name = "expert_close",
                        #label = "Advanced settings...",
                        type = "label",
                        help = \
                        "you not human? This is a anti-bot test",
                        value = 'close',
                        element = "expert"))
        if step in [2, None]:
            if not 'view' in locals():
                view = ViewInfo(groups=[])
            else:
                view.groups.append(group)

            group = GroupField(name="Gratulations!",last=True)
            group.fields = []

            group.fields.append(Field(
                    name = "final_label",
                    label = "Final step in system install!!! Congratulation!\n"\
                            "Please, select language now!",
                    #value = "border-style: solid; border-width: "
                                                #"2px;border-color: #ff2222;",
                    value = 'border: 0px outset gray;'
                     'border-radius: 6px;'
                     'subcontrol-origin: margin;'
                     'color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,'
                     'stop: 0.1 #bb1111, stop: 0.5 #11bb11, stop: 0.9 #1111bb);'
                     'subcontrol-position: top left; ',
                    element = "label"))
            group.fields.append(Field(
                    name = "comboLang",
                    label = "check language: ",
                    choice = ['Russian','English'],
                    type = "str",
                    value = 'Russian',
                    help = \
                    "you not human? This is a anti-bot test",
                    element = "combo"))
        #if step == None:
            #if not 'view' in locals():
                #view = ViewInfo(groups=[])
            #else:
                #view.groups.append(group)

            #group = GroupField(name="Empty group",last=True)
            #group.fields = []

        view.groups.append(group)

        return view