Ejemplo n.º 1
0
    def _get_one_compound_filter_data(cls, compound_filter):
        filter_data = {}
        for sub_filter in CorbaFilterIterator(compound_filter):
            name = recoder.c2u(sub_filter._get_name())
            debug('NAME=%s %s' % (name, type(name)))
            neg = sub_filter._get_neg()
            if isinstance(sub_filter, ccReg.Filters._objref_Compound):
                value = cls._get_one_compound_filter_data(sub_filter)
            else:
                if sub_filter.isActive():
                    val = sub_filter._get_value()
                    debug('VALUE (from corba)=%s' % val)
                    if isinstance(sub_filter, ccReg.Filters._objref_Date):
                        value = recoder.corba_to_date_time_interval(
                            val, recoder.corba_to_date)
                    elif isinstance(sub_filter, ccReg.Filters._objref_DateTime):
                        value = recoder.corba_to_date_time_interval(
                            val, recoder.corba_to_datetime)
                    else:
                        value = recoder.c2u(val)
                else:
                    value = ''

            filter_data[name] = [neg, value]
        return filter_data
Ejemplo n.º 2
0
    def detail(self, **kwd):
        log_req = self._create_log_req_for_object_view(**kwd)
        context = {}
        try:
            detail = self._get_detail(obj_id=kwd.get('id'))
            if detail is None:
                log_req.result = 'Fail'
            else:
                log_req.result = 'Success'

            result = detail.__dict__
            result['groups'] = (recoder.c2u(
                self._get_groups_for_reg_id(int(kwd.get('id')))))
            result['certifications'] = (recoder.c2u(
                self._get_certifications_for_reg_id(int(kwd.get('id')))))
            ###TODO: This is here temporarily till backandist will create interface for blokcing registrars with history
            admin = cherrypy.session.get('Admin')
            result['is_blocked'] = admin.isRegistrarBlocked(int(kwd.get('id')))
            ### ==

            context['edit'] = kwd.get('edit', False)
            context['result'] = result
        finally:
            log_req.close()
        return self._render('detail', context)
Ejemplo n.º 3
0
Archivo: adif.py Proyecto: LANJr4D/FRED
    def detail(self, **kwd):
        log_req = self._create_log_req_for_object_view(**kwd)
        context = {}
        try:
            detail = self._get_detail(obj_id=kwd.get('id'))
            if detail is None:
                log_req.result = 'Fail'
            else:
                log_req.result = 'Success'

            result = detail.__dict__
            result['groups'] = (
                recoder.c2u(self._get_groups_for_reg_id(int(kwd.get('id')))))
            result['certifications'] = (
                recoder.c2u(
                    self._get_certifications_for_reg_id(int(kwd.get('id')))))
            ###TODO: This is here temporarily till backandist will create interface for blokcing registrars with history
            admin = cherrypy.session.get('Admin')
            result['is_blocked'] = admin.isRegistrarBlocked(int(kwd.get('id')))
            ### ==

            context['edit'] = kwd.get('edit', False)
            context['result'] = result
        finally:
            log_req.close()
        return self._render('detail', context)
Ejemplo n.º 4
0
 def _get_one_compound_filter_data(cls, compound_filter):
     filter_data = {}
     for sub_filter in CorbaFilterIterator(compound_filter):
         name = recoder.c2u(sub_filter._get_name())
         debug('NAME=%s %s' % (name, type(name)))
         neg = sub_filter._get_neg()
         if isinstance(sub_filter, ccReg.Filters._objref_Compound):#Compound):
             value = cls._get_one_compound_filter_data(sub_filter)
         else:
             if sub_filter.isActive():
                 val = sub_filter._get_value()
                 debug('VALUE (from corba)=%s' % val)
                 if isinstance(sub_filter, ccReg.Filters._objref_Date):
                     value = recoder.corba_to_date_time_interval(
                         val, recoder.corba_to_date)
                 elif isinstance(sub_filter, ccReg.Filters._objref_DateTime):
                     value = recoder.corba_to_date_time_interval(
                         val, recoder.corba_to_datetime)
                 else:
                     value = recoder.c2u(val)
             else:
                 value = ''
         
         filter_data[name] = [neg, value]
     return filter_data
Ejemplo n.º 5
0
    def __init__(self, user):
        ''' Wrapper around corba User object '''
        self._user = user  # corba User object
        self.id = user._get_id()
        self.login = recoder.c2u(user._get_username())
        self.firstname = recoder.c2u(user._get_firstname())
        self.surname = recoder.c2u(user._get_surname())
        self.table_page_size = config.tablesize

        self._authorizer = auth_user.Authorizer(self.login)
Ejemplo n.º 6
0
Archivo: user.py Proyecto: LANJr4D/FRED
    def __init__(self, user):
        ''' Wrapper around corba User object '''
        self._user = user # corba User object
        self.id = user._get_id()
        self.login = recoder.c2u(user._get_username())
        self.firstname = recoder.c2u(user._get_firstname())
        self.surname = recoder.c2u(user._get_surname())
        self.table_page_size = config.tablesize

        self._authorizer = auth_user.Authorizer(self.login)
Ejemplo n.º 7
0
    def _update_registrar(self, registrar, log_request_name, action_is_edit,
                          *params, **kwd):
        """ Handles the actual updating/creating of a registrar.
        
            Note that we have to "glue" the registrar initial form data 
            together. This is unfortunate, but it's caused by the design 
            of IDL.

            Args:
                registrar:
                    The ccReg.AdminRegistrar object that is being updated or
                    created.
                log_request_name:
                    The type of log request that keeps log of this event.
                action_is_edit:
                    True iff we are editing an already existing registrar.
                    false iff we are creating a new one.
        """
        context = {'main': div()}
        reg_data_form_class = self._get_editform_class()
        reg_data_initial = registrar.__dict__
        initial = reg_data_initial
        if action_is_edit:
            # Only append groups and certifications when we're editing an
            # already existing registrar (there are none for a new registrar).
            group_mgr = cherrypy.session['Admin'].getGroupManager()
            groups = self._get_groups_for_reg_id(int(kwd.get('id')))
            initial['groups'] = recoder.c2u(groups)
            certs = self._get_certifications_for_reg_id(int(kwd.get('id')))
            initial['certifications'] = recoder.c2u(certs)

        if cherrypy.request.method == 'POST':
            form = reg_data_form_class(kwd, initial=initial, method='post')
            if form.is_valid():
                # Create the log request only after the user has clicked on
                # "save" (we only care about contacting the server, not about
                # user entering the edit page).

                context = self._process_valid_form(form, registrar,
                                                   kwd.get('id'), context,
                                                   log_request_name)
                return context
            else:
                if config.debug:
                    context['main'].add('Form is not valid! Errors: %s' %
                                        repr(form.errors))
        else:
            form = reg_data_form_class(method='post', initial=initial)

        context['form'] = form
        return context
Ejemplo n.º 8
0
Archivo: adif.py Proyecto: LANJr4D/FRED
    def _update_registrar(self, registrar, log_request_name, action_is_edit, *params, **kwd):
        """ Handles the actual updating/creating of a registrar.
        
            Note that we have to "glue" the registrar initial form data 
            together. This is unfortunate, but it's caused by the design 
            of IDL.

            Args:
                registrar:
                    The ccReg.AdminRegistrar object that is being updated or
                    created.
                log_request_name:
                    The type of log request that keeps log of this event.
                action_is_edit:
                    True iff we are editing an already existing registrar.
                    false iff we are creating a new one.
        """
        context = {'main': div()}
        reg_data_form_class = self._get_editform_class()
        reg_data_initial = registrar.__dict__
        initial = reg_data_initial
        if action_is_edit:
            # Only append groups and certifications when we're editing an
            # already existing registrar (there are none for a new registrar).
            group_mgr = cherrypy.session['Admin'].getGroupManager()
            groups = self._get_groups_for_reg_id(int(kwd.get('id')))
            initial['groups'] = recoder.c2u(groups)
            certs = self._get_certifications_for_reg_id(int(kwd.get('id')))
            initial['certifications'] = recoder.c2u(certs)

        if cherrypy.request.method == 'POST':
            form = reg_data_form_class(kwd, initial=initial, method='post')
            if form.is_valid():
                # Create the log request only after the user has clicked on
                # "save" (we only care about contacting the server, not about 
                # user entering the edit page).

                context = self._process_valid_form(
                    form, registrar, kwd.get('id'), context, log_request_name)
                return context
            else:
                if config.debug:
                    context['main'].add(
                        'Form is not valid! Errors: %s' % repr(form.errors))
        else:
            form = reg_data_form_class(method='post', initial=initial)

        context['form'] = form
        return context
Ejemplo n.º 9
0
def resolve_detail_class(detail_class, value):
    if isinstance(
            detail_class, dict
    ):  # if corba field is Union of structures for inner details, switch to particular detail class according to corba union discriminant (_d)
        return detail_class[value._d], recoder.c2u(value._v)
    else:
        return detail_class, value
    def _get_check_messages_list(self, check):
        messages = c2u(
            cherrypy.session['Verification'].getContactCheckMessages(
                u2c(check.contact_id)))

        if len(messages):
            messages_table = SimpleTable(
                header=[
                    _('Id'),
                    _('Created'),
                    _('Channel'),
                    _('Type'),
                    _('Updated'),
                    _('Status')
                ],
                data=[(a(
                    attr(href=f_urls['mail' if msg.type_handle ==
                                     'email' else 'message'] +
                         'detail/?id=%s' % msg.id),
                    img(src='/img/icons/open.png')), msg.created,
                       msg.type_handle, msg.content_handle, msg.updated,
                       msg.status) for msg in messages],
                cssc='itertable')
            messages_table.media_files.append('/css/itertable.css')
            return messages_table
        else:
            return _('No messages have been sent.')
Ejemplo n.º 11
0
 def _get_row(self, index):
     row = []
     try:
         items = self._table.getRow(index)
         row_id = self.get_row_id(index)
     except Registry.Table.INVALID_ROW:
         import traceback 
         raise IndexError(
             "Index %s out of bounds. Original exception: %s" % \
             (index, traceback.format_exc()))
     # Create OID from rowId.
     row_id_oid = Registry.OID(row_id, str(row_id), 
                               f_name_enum[self.request_object])
     items.insert(0, row_id_oid)
     for i, item in enumerate(items):
         cell = {}
         cell['index'] = i
         if i == 0: 
             # items[0] is id (obtained from self._table.getRowId(index)).
             cell['value'] = item
         else: 
             # All other items are corba ANY values.
             cell['value'] = recoder.c2u(from_any(item, True))
         self._rewrite_cell(cell)
         row.append(cell)
     return row
Ejemplo n.º 12
0
 def _get_row(self, index):
     row = []
     try:
         items = self._table.getRow(index)
         row_id = self.get_row_id(index)
     except Registry.Table.INVALID_ROW:
         import traceback
         raise IndexError(
             "Index %s out of bounds. Original exception: %s" % \
             (index, traceback.format_exc()))
     # Create OID from rowId.
     row_id_oid = Registry.OID(row_id, str(row_id),
                               f_name_enum[self.request_object])
     items.insert(0, row_id_oid)
     for i, item in enumerate(items):
         cell = {}
         cell['index'] = i
         if i == 0:
             # items[0] is id (obtained from self._table.getRowId(index)).
             cell['value'] = item
         else:
             # All other items are corba ANY values.
             cell['value'] = recoder.c2u(from_any(item, True))
         self._rewrite_cell(cell)
         row.append(cell)
     return row
Ejemplo n.º 13
0
    def value_from_data(self, data):
        value = data.get(self.name)

        if value:
            if self.owner_detail.history and len(
                    value) > 1 and not self.owner_detail.is_nested:
                self.displaying_history = True
                self.history_field.owner_detail = self.owner_detail
                self._assign_current_field(self.history_field)
                for history_record in value:
                    recoder.c2u(from_any(history_record.value, True))
                return value
            else:
                self.normal_field.owner_detail = self.owner_detail
                self._assign_current_field(self.normal_field)
                return recoder.c2u(from_any(value[0].value, True))
        else:
            self.normal_field.owner_detail = self.owner_detail
            self._assign_current_field(self.normal_field)
            return fredtypes.Null()
Ejemplo n.º 14
0
 def detail(self, **kwd):
     context = {}
     log_req = self._create_log_req_for_object_view(**kwd)
     try:
         mail_id = int(kwd['id'])
         mailer = cherrypy.session.get('Mailer')
         rendered_mail = mailer.renderMail(recoder.u2c(mail_id))
         detail = self._get_detail(obj_id=mail_id)
         result = detail.__dict__
         result['content'] = recoder.c2u(rendered_mail)
         context = {'result': result}
         log_req.result = 'Success'
     except ccReg.Mailer.UnknownMailid, e:
         log_req.result = 'Fail'
         context['main'] = _("Object_not_found")
Ejemplo n.º 15
0
 def _get_data(self):
     """ Get data from CORBA and cache it to self.data, next call is ignored,
         because data are already cached.
     """
     if self.data is None:
         debug("CorbaLazyRequest getting data")
         corba_object = cherrypy.session.get(self.object_name)
         if self.mgr_getter_name:
             corba_object = getattr(corba_object, self.mgr_getter_name)()
         corba_func = getattr(corba_object, self.function_name)
         try:
             data = recoder.c2u(corba_func(*self.c_args, **self.c_kwargs))
         except (omniORB.CORBA.SystemException, ccReg.Admin.ServiceUnavailable), e:
             raise ServerNotAvailableError(("Error in CorbaLazy(function_name=%s) " % self.function_name) + str(e))
         data = self.selector_func(data) if self.selector_func else data
         self.data = self._convert_data(data)
Ejemplo n.º 16
0
    def value_from_data(self, data):
        value = data.get(self.name)

        if value:
            if self.owner_detail.history and len(value) > 1 and not self.owner_detail.is_nested:
                self.displaying_history = True
                self.history_field.owner_detail = self.owner_detail
                self._assign_current_field(self.history_field)
                return value
            else:
                self.normal_field.owner_detail = self.owner_detail
                self._assign_current_field(self.normal_field)
                return recoder.c2u(from_any(value[0].value, True))
        else:
            self.normal_field.owner_detail = self.owner_detail
            self._assign_current_field(self.normal_field)
            return fredtypes.Null()
Ejemplo n.º 17
0
def get_detail(obj_type_name, obj_id, use_cache=True):
    """ If use_cache == False, we always get the object from
        server. """
    if use_cache:
        result_from_cache = details_cache.get((obj_type_name, obj_id))
        if result_from_cache is not None:
            debug('Cache hit (%s, %s)' % (obj_type_name, obj_id))
            return result_from_cache

    debug('Getting detail %s id %s' % (obj_type_name, obj_id))
    corba_session = get_corba_session()
    c_any = corba_session.getDetail(
        f_name_enum[obj_type_name], recoder.u2c(obj_id))
    corba_obj = from_any(c_any, True)
    result = recoder.c2u(corba_obj)

    details_cache[(obj_type_name, obj_id)] = result
    return result
Ejemplo n.º 18
0
Archivo: adif.py Proyecto: LANJr4D/FRED
 def index(self, *args, **kwargs):
     context = {'main': div()}
     reg_mgr = cherrypy.session['Admin'].getGroupManager()
     corba_groups = reg_mgr.getGroups()
     groups = recoder.c2u(corba_groups)
     active_groups = [group for group in groups if not group.cancelled]
     initial = {"groups": active_groups}
     if cherrypy.request.method == 'POST':
         form = GroupManagerEditForm(kwargs, initial=initial, method='post')
         if form.is_valid():
             context = self._process_valid_form(form, context)
         else:
             context['form'] = form
     else:
         form = GroupManagerEditForm(initial=initial, method='post')
         context['form'] = form
     res = self._render(action="edit", ctx=context)
     return res
Ejemplo n.º 19
0
def get_detail(obj_type_name, obj_id, use_cache=True):
    """ If use_cache == False, we always get the object from
        server. """
    if use_cache:
        result_from_cache = details_cache.get((obj_type_name, obj_id))
        if result_from_cache is not None:
            debug('Cache hit (%s, %s)' % (obj_type_name, obj_id))
            return result_from_cache

    debug('Getting detail %s id %s' % (obj_type_name, obj_id))
    corba_session = get_corba_session()
    c_any = corba_session.getDetail(
        f_name_enum[obj_type_name], recoder.u2c(obj_id))
    corba_obj = from_any(c_any, True)
    result = recoder.c2u(corba_obj)
    
    details_cache[(obj_type_name, obj_id)] = result
    return result
Ejemplo n.º 20
0
 def index(self, *args, **kwargs):
     context = {'main': div()}
     reg_mgr = cherrypy.session['Admin'].getGroupManager()
     corba_groups = reg_mgr.getGroups()
     groups = recoder.c2u(corba_groups)
     active_groups = [group for group in groups if not group.cancelled]
     initial = {"groups": active_groups}
     if cherrypy.request.method == 'POST':
         form = GroupManagerEditForm(kwargs, initial=initial, method='post')
         if form.is_valid():
             context = self._process_valid_form(form, context)
         else:
             context['form'] = form
     else:
         form = GroupManagerEditForm(initial=initial, method='post')
         context['form'] = form
     res = self._render(action="edit", ctx=context)
     return res
Ejemplo n.º 21
0
 def _get_data(self):
     """ Get data from CORBA and cache it to self.data, next call is ignored,
         because data are already cached.
     """
     if self.data is None:
         debug('CorbaLazyRequest getting data')
         corba_object = cherrypy.session.get(self.object_name)
         if self.mgr_getter_name:
             corba_object = getattr(corba_object, self.mgr_getter_name)()
         corba_func = getattr(corba_object, self.function_name)
         try:
             data = recoder.c2u(corba_func(*self.c_args, **self.c_kwargs))
         except (omniORB.CORBA.SystemException,
                 ccReg.Admin.ServiceUnavailable), e:
             raise ServerNotAvailableError(
                 ('Error in CorbaLazy(function_name=%s) ' %
                  self.function_name) + str(e))
         data = self.selector_func(data) if self.selector_func else data
         self.data = self._convert_data(data)
    def _table_data_generator(self, test_suit=None, contact_id=None):
        checks = c2u(self._get_contact_checks(test_suit, contact_id))

        for check in checks:
            if not check_nperm_func(
                    'read.contactcheck_%s' % check.test_suite_handle):
                continue
            to_resolve = self._get_to_resolve_date(check)
            if to_resolve:
                to_resolve = to_resolve.isoformat()

            check_link = '<a href="{0}detail/{1}/"><img src="/img/icons/open.png" title="{3}" /></a>'
            if (check.current_status not in self.UNCLOSABLE_CHECK_STATUSES
                    and check_nperm_func(
                        'change.contactcheck_%s' % check.test_suite_handle)):
                cache_key = (RESOLVE_LOCK_CACHE_KEY %
                             check.check_handle).encode('utf-8')
                resolving_user = cache.get(
                    cache_key) if cache is not None else None
                if resolving_user and resolving_user != cherrypy.session[
                        'user'].login:
                    check_link += '&nbsp;%s resolving' % resolving_user
                else:
                    check_link += '''&nbsp;<a href="{0}detail/{1}/resolve/">{2}</a>'''
            check_link = check_link.format(f_urls[self.classname],
                                           check.check_handle, _('Resolve'),
                                           _('Show'))
            row = [
                check_link,
                '<a href="{}detail/?id={}">{}</a>'.format(
                    f_urls['contact'], check.contact_id, check.contact_handle),
                ContactCheckEnums.SUITE_NAMES.get(check.test_suite_handle,
                                                  _('!Unknown error!')),
                to_resolve,
                check.created.isoformat(),
                '<span title="%s">%s</span>' %
                (ContactCheckEnums.CHECK_STATUS_DESCS.get(
                    check.current_status, _('!Unknown error!')),
                 ContactCheckEnums.CHECK_STATUS_NAMES.get(
                     check.current_status, _('!Unknown error!'))),
            ]
            yield row
Ejemplo n.º 23
0
Archivo: adif.py Proyecto: LANJr4D/FRED
 def _get_groups_for_reg_id(self, reg_id):
     """ Returns groups that the registrar with reg_id belongs to under the
         condition that their membership toDate value is not set (i.e., the 
         membership is active).
     """
     group_mgr = cherrypy.session['Admin'].getGroupManager()
     all_groups = group_mgr.getGroups()
     memberships = group_mgr.getMembershipsByRegistar(reg_id)
     my_groups_ids = [
         member.group_id for member in recoder.c2u(memberships)
         if not member.toDate
         #or (member.toDate and not member.toDate <= datetime.date.today()) 
         # Note: toDate should not be in the future (webadmin allow only setting it to today), so 
         # it's safe to say that if there is toDate filled, registrar is already removed from
         # the group. The only problem is that commandline fred_admin allow to set the toDate to the
         # future, so it can couse some problems (then we would have to display such group but
         # without possibility to remove it)
     ]
     groups = [group for group in all_groups if group.id in my_groups_ids]
     return groups
Ejemplo n.º 24
0
 def _get_groups_for_reg_id(self, reg_id):
     """ Returns groups that the registrar with reg_id belongs to under the
         condition that their membership toDate value is not set (i.e., the 
         membership is active).
     """
     group_mgr = cherrypy.session['Admin'].getGroupManager()
     all_groups = group_mgr.getGroups()
     memberships = group_mgr.getMembershipsByRegistar(reg_id)
     my_groups_ids = [
         member.group_id for member in recoder.c2u(memberships)
         if not member.toDate
         #or (member.toDate and not member.toDate <= datetime.date.today())
         # Note: toDate should not be in the future (webadmin allow only setting it to today), so
         # it's safe to say that if there is toDate filled, registrar is already removed from
         # the group. The only problem is that commandline fred_admin allow to set the toDate to the
         # future, so it can couse some problems (then we would have to display such group but
         # without possibility to remove it)
     ]
     groups = [group for group in all_groups if group.id in my_groups_ids]
     return groups
    def detail(self, *args, **kwd):
        # path can be 'detail/ID/' or 'detail/ID/resolve/'
        if (not 1 <= len(args) <= 2) or (len(args) > 1
                                         and args[1] != 'resolve'):
            return self._render('404_not_found')

        check_handle = args[0]
        if len(args) > 1:
            # cache lock is just helping users so they don't work on the same Check, but it's optional:
            if cache:
                cache_key = RESOLVE_LOCK_CACHE_KEY % check_handle
                stored = cache.add(
                    cache_key, cherrypy.session['user'].login,
                    config.verification_check_lock_default_duration)
                current_resolving_user = cache.get(cache_key)
                # resolve only if memcache is not running (return value 0) or lock was acquired (return value True) or
                # the current user is the user who has the lock:
                if (stored == 0 and type(stored) == type(0)) or stored is True \
                    or current_resolving_user == cherrypy.session['user'].login:
                    resolve = True
                else:
                    messages.warning(
                        'This check is currently being resolved by the user "%s"'
                        % current_resolving_user)
                    raise cherrypy.HTTPRedirect(f_urls['contactcheck'] +
                                                'detail/%s/' % check_handle)
            else:
                resolve = True
        else:  # read only mode
            resolve = False

        post_data = kwd if cherrypy.request.method == 'POST' else None

        if resolve and post_data:
            req_type = 'ContactCheckUpdateTestStatuses'
        else:
            req_type = 'ContactCheckDetail'

        log_req = create_log_request(
            req_type, properties=[['check_handle', check_handle]])
        out_props = []

        check = None
        try:
            check = c2u(cherrypy.session['Verification'].getContactCheckDetail(
                check_handle))
            if resolve:
                check_nperm_func('change.contactcheck_%s' %
                                 check.test_suite_handle,
                                 raise_err=True)
            else:
                check_nperm_func('read.contactcheck_%s' %
                                 check.test_suite_handle,
                                 raise_err=True)

            if resolve:
                if self._is_check_post_closed(check):
                    messages.warning(
                        _('This contact check was already resolved.'))
                    raise cherrypy.HTTPRedirect(f_urls['contactcheck'] +
                                                'detail/%s/' %
                                                check.check_handle)
                elif self._is_check_pre_run(check) and check.status_history[
                        -1].status != 'enqueue_req':
                    messages.warning(_('This contact check was not yet run.'))
                    raise cherrypy.HTTPRedirect(f_urls['contactcheck'] +
                                                'detail/%s/' %
                                                check.check_handle)

                initial = {
                    test_data.test_handle: test_data.status_history[-1].status
                    for test_data in check.test_list
                }
                form = self._generate_update_tests_form_class(check)(
                    post_data, initial=initial)
                if form.is_valid():
                    changed_statuses = {}
                    for test_data in check.test_list:
                        status_in_form = form.cleaned_data[
                            test_data.test_handle]
                        if status_in_form != test_data.status_history[
                                -1].status:
                            changed_statuses[
                                test_data.test_handle] = status_in_form
                    if changed_statuses:
                        cherrypy.session[
                            'Verification'].updateContactCheckTests(
                                u2c(check.check_handle),
                                u2c([
                                    Registry.AdminContactVerification.
                                    ContactTestUpdate(test_handle, status)
                                    for test_handle, status in
                                    changed_statuses.items()
                                ]), u2c(log_req.request_id))
                    log_req.result = 'Success'
                    out_props += [['changed_statuses', '']] + [[
                        key, val, True
                    ] for key, val in changed_statuses.items()]
                    self._update_check(check, post_data)
                else:
                    log_req.result = 'Fail'
            else:
                form = None

            log_req.result = 'Success'

            detail = VerificationCheckDetail(check=check,
                                             resolve=resolve,
                                             form=form)

            try:
                contact_detail = get_detail('contact', check.contact_id)
            except ccReg.Admin.ObjectNotFound:
                contact_detail = None

            context = DictLookup({
                'test_suit_name':
                ContactCheckEnums.SUITE_NAMES.get(check.test_suite_handle),
                'check':
                check,
                'contact_url':
                f_urls['contact'] + 'detail/?id=%s' % check.contact_id,
                'detail':
                detail,
                'contact_detail':
                contact_detail,
                'ajax_json_filter_url':
                f_urls['contactcheck'] + 'json_filter/%s/' % check.contact_id,
            })
            if cherrypy.session.get('history', False):
                context.update({
                    'table_tag':
                    self._get_checks_table_tag(),
                    'messages_list':
                    self._get_check_messages_list(check)
                })
            return self._render('detail', ctx=context)
        except Registry.AdminContactVerification.INVALID_CHECK_HANDLE:
            log_req.result = 'Fail'
            return self._render('404_not_found')
        finally:
            log_req.close(properties=out_props,
                          references=[('contact',
                                       check.contact_id)] if check else None)
Ejemplo n.º 26
0
def resolve_detail_class(detail_class, value):
    if isinstance(detail_class, dict): # if corba field is Union of structures for inner details, switch to particular detail class according to corba union discriminant (_d)
        return detail_class[value._d], recoder.c2u(value._v)
    else:
        return detail_class, value