Пример #1
0
    def unblock(self, id):
        context = DictLookup()
        try:
            reg_id = int(id)
        except (TypeError, ValueError):
            context.message = _("Required_integer_as_parameter")
            raise CustomView(self._render('error', ctx=context))

        return_message = [
            _(u'You can return back to '),
            a(attr(href=f_urls[self.classname] + 'detail/?id=%s' % reg_id),
              _('registrar.'))
        ]

        admin = cherrypy.session.get('Admin')
        if not admin.isRegistrarBlocked(reg_id):
            context.message = [_("This registrar is not blocked.")] + return_message
            return self._render('error', ctx=context)
        else:
            log_req = utils.create_log_request('RegistrarUpdate', [['blocked', 'False']], [[self.classname, reg_id]])
            try:
                admin.unblockRegistrar(reg_id, log_req.request_id)
                log_req.result = 'Success'
            finally:
                log_req.close()

            context.main = [_("Registrar successfully unblocked.")] + return_message
            return self._render('base', ctx=context)
Пример #2
0
    def unblock(self, id):
        context = DictLookup()
        try:
            reg_id = int(id)
        except (TypeError, ValueError):
            context.message = _("Required_integer_as_parameter")
            raise CustomView(self._render('error', ctx=context))

        return_message = [
            _(u'You can return back to '),
            a(attr(href=f_urls[self.classname] + 'detail/?id=%s' % reg_id),
              _('registrar.'))
        ]

        admin = cherrypy.session.get('Admin')
        if not admin.isRegistrarBlocked(reg_id):
            context.message = [_("This registrar is not blocked.")
                               ] + return_message
            return self._render('error', ctx=context)
        else:
            log_req = utils.create_log_request('RegistrarUpdate',
                                               [['blocked', 'False']],
                                               [[self.classname, reg_id]])
            try:
                admin.unblockRegistrar(reg_id, log_req.request_id)
                log_req.result = 'Success'
            finally:
                log_req.close()

            context.main = [_("Registrar successfully unblocked.")
                            ] + return_message
            return self._render('base', ctx=context)
Пример #3
0
 def index(self):
     context = DictLookup()
     context.main = ul(
         li(
             a(
                 attr(
                     href=
                     '''/file/filter/?json_data=[{%22presention|CreateTime%22:%22on%22,%22CreateTime/3%22:%2210%22,%22CreateTime/0/0%22:%22%22,%22CreateTime/0/1/0%22:%220%22,%22CreateTime/0/1/1%22:%220%22,%22CreateTime/1/0%22:%22%22,%22CreateTime/1/1/0%22:%220%22,%22CreateTime/1/1/1%22:%220%22,%22CreateTime/4%22:%22-2%22,%22CreateTime/2%22:%22%22,%22presention|Type%22:%22000%22,%22Type%22:%225%22}]'''
                 ), _('Domain expiration letters'))))
     return self._render('summary', ctx=context)
Пример #4
0
 def index(self):
     #return 'muj index'
     result = utils.get_detail('domain', 41)
     from fred_webadmin.webwidgets.details.adifdetails import DomainDetail as NewDomainDetail
     context = DictLookup(
         {'main': NewDomainDetail(result, cherrypy.session.get('history'))})
     return self._render('base', ctx=context)
 def filter(self, contact_id=None):
     context = DictLookup({
         'heading':
         _('Contact checks'),
         'ajax_json_filter_url':
         f_urls['contactcheck'] + 'json_filter/' +
         ('%s/' % contact_id if contact_id else ''),
         'table_tag':
         self._get_checks_table_tag(),
     })
     if contact_id is None:  # don't set filter when user is wating check of particular contact:
         context['default_js_type_filter'] = 'filter-manual' if check_nperm_func('change.contactcheck_manual') \
                                                             else 'filter-automatic'
     return self._render('filter', ctx=context)
Пример #6
0
    def _render(self, action='', ctx=None):
        context = DictLookup()
        context.approot = '/'
        context.classname = self.classname
        context.classroot = "%s%s/" % (context.approot, context.classname)
        context.corba_server = cherrypy.session.get('corba_server_name')
        context.request = cherrypy.request
        context.history = cherrypy.session.get('history', False)

        user = cherrypy.session.get('user', None)
        if user:
            context.user = user
            # None for Login page that has no menu.
            context.menu = self._get_menu(action) or None
            context.body_id = self._get_selected_menu_body_id(action)

        if ctx:
            context.update(ctx)

        temp_class = self._template(action)(context)
        result = temp_class.render()

        return result
Пример #7
0
 def index(self):
     context = DictLookup()
     context.main = p(
         "Logging has been disabled, Daphne could not connect to CORBA logd.")
     return self._render('base', ctx=context)
Пример #8
0
 def index(self):
     context = DictLookup()
     context.main = ul(li(a(attr(href='''/file/filter/?json_data=[{%22presention|CreateTime%22:%22on%22,%22CreateTime/3%22:%2210%22,%22CreateTime/0/0%22:%22%22,%22CreateTime/0/1/0%22:%220%22,%22CreateTime/0/1/1%22:%220%22,%22CreateTime/1/0%22:%22%22,%22CreateTime/1/1/0%22:%220%22,%22CreateTime/1/1/1%22:%220%22,%22CreateTime/4%22:%22-2%22,%22CreateTime/2%22:%22%22,%22presention|Type%22:%22000%22,%22Type%22:%225%22}]'''), _('Domain expiration letters'))))
     return self._render('summary', ctx=context)
Пример #9
0
    def _render(self, action='', ctx=None):
        context = DictLookup()
        context.approot = '/'
        context.classname = self.classname
        context.classroot = "%s%s/" % (context.approot, context.classname)
        context.corba_server = cherrypy.session.get('corba_server_name')
        context.request = cherrypy.request
        context.history = cherrypy.session.get('history', False)

        user = cherrypy.session.get('user', None)
        if user:
            context.user = user
            # None for Login page that has no menu.
            context.menu = self._get_menu(action) or None
            context.body_id = self._get_selected_menu_body_id(action)

        if ctx:
            context.update(ctx)

        temp_class = self._template(action)(context)
        result = temp_class.render()

        return result
Пример #10
0
 def index(self):
     context = DictLookup()
     context.main = p(
         "Logging has been disabled, Daphne could not connect to CORBA logd."
     )
     return self._render('base', ctx=context)
Пример #11
0
    def index(self):
        context = DictLookup({'main': p("hoj")})

        return BaseSiteMenu(context).render()
 def index(self, *args, **kwargs):
     context = DictLookup()
     context.main = 'Welcome on the contact verification page.'
     return self._render('base', ctx=context)
    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)
Пример #14
0

if sys.version_info >= (2, 7):
    from collections import OrderedDict
else:
    from fred_webadmin.utils import OrderedDict

ContactCheckEnums = DictLookup(
    TEST_STATUS_NAMES=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestStatusDefs',
                                                       ['handle', 'name'], None, None, config.lang[:2]),
    TEST_STATUS_DESCS=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestStatusDefs',
                                                       ['handle', 'description'], None, None, config.lang[:2]),
    CHECK_STATUS_NAMES=CorbaLazyRequestIterStructToDict('Verification', None, 'listCheckStatusDefs',
                                                        ['handle', 'name'], None, None, config.lang[:2]),
    CHECK_STATUS_DESCS=CorbaLazyRequestIterStructToDict('Verification', None, 'listCheckStatusDefs',
                                                        ['handle', 'description'], None, None, config.lang[:2]),
    TEST_NAMES=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestDefs',
                                                ['handle', 'name'], None, None, config.lang[:2], None),
    TEST_DESCS=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestDefs',
                                                ['handle', 'description'], None, None, config.lang[:2], None),
    SUITE_NAMES=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestSuiteDefs',
                                                 ['handle', 'name'], None, None, config.lang[:2]),
    SUITE_DESCS=CorbaLazyRequestIterStructToDict('Verification', None, 'listTestSuiteDefs',
                                                 ['handle', 'description'], None, None, config.lang[:2]),
)


# enum made as function to avoid duplicate data:
def get_status_action(test_suite_handle, current_status):
    status_action = None
    if test_suite_handle == 'automatic':
        if current_status.startswith('auto_'):
Пример #15
0
 def index(self):
     context = DictLookup()
     context.main = ul(li(a(attr(href='''/file/filter/?json_data=[{%22presention|CreateTime%22:%22on%22,%22CreateTime/3%22:%2210%22,%22CreateTime/0/0%22:%22%22,%22CreateTime/0/1/0%22:%220%22,%22CreateTime/0/1/1%22:%220%22,%22CreateTime/1/0%22:%22%22,%22CreateTime/1/1/0%22:%220%22,%22CreateTime/1/1/1%22:%220%22,%22CreateTime/4%22:%22-2%22,%22CreateTime/2%22:%22%22,%22presention|Type%22:%22000%22,%22Type%22:%225%22}]'''), _('Domain expiration letters'))))
     context.main.add(li(a(attr(href='/domain/import_notif_emails/'),
                           _('Import emails for out-of-zone notification'))))
     return self._render('summary', ctx=context)