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 make_content(self): self.content = [] detail = utils.get_detail(recoder.u2c(self.object_type), int(self.value)) if self.error_msg: self.add(ErrorList([self.error_msg % detail.handle])) self.add( a( attr(href=f_urls[self.object_type] + 'detail/?id=%s' % self.value), (detail.handle)), br())
def _get_detail(self, obj_id): context = {} try: obj_id = int(obj_id) except (TypeError, ValueError): context['main'] = _("Required_integer_as_parameter") raise CustomView(self._render('base', ctx=context)) try: return get_detail(self.classname, obj_id) except (ccReg.Admin.ObjectNotFound,): context['main'] = _("Object_not_found") raise CustomView(self._render('base', ctx=context))
def _render_check_status(self, tests_table, check_status, is_current_status): col_tag = th if is_current_status else td tests_table.footer.add(tr(col_tag(attr(colspan=self.col_count - 3), 'Overall status:'), col_tag(span(attr(title=enums.CHECK_STATUS_DESCS[check_status.status]), enums.CHECK_STATUS_NAMES[check_status.status])), td(get_detail('logger', check_status.logd_request_id).user_name \ if check_status.logd_request_id else _('automat')), td(attr(cssc='no-wrap'), check_status.update))) if is_current_status: if check_status.status == 'ok': tests_table.footer.content[0].add_css_class('status_ok') elif check_status.status == 'fail': tests_table.footer.content[0].add_css_class('status_fail')
def _render_test_status(self, test_row, status, test_handle, is_current_status): test_row.add(td(status.err_msg)) status_td = td(attr(cssc='no-wrap status_col')) if is_current_status and self.resolve: status_td.add(self.form.fields[test_handle]) else: status_td.add( span(attr(title=enums.TEST_STATUS_DESCS[status.status]), enums.TEST_STATUS_NAMES[status.status])) test_row.add(status_td) if status.logd_request_id: log_req_detail = get_detail('logger', status.logd_request_id) test_row.add(td(log_req_detail.user_name)) else: test_row.add(td(_('automat'))) test_row.add(td(attr(cssc='no-wrap'), status.update))
def _blocking_result(self): context = {} if cherrypy.session.get('blocking_result'): blocking_result = cherrypy.session['blocking_result'] if blocking_result.get('blocked_objects'): context['detail_url'] = f_urls[self.classname] + 'detail/?id=%s' context['heading'] = 'Result of: %s' % \ self.blocking_views[blocking_result['blocking_action']].action_name try: # HACK: till backend return list of handle:id of changed/deleted domains, we must use history for deleted domains: if blocking_result['blocking_action'] == 'blacklist_and_delete': # we must turn on history flag to get details of deleted domains utils.get_corba_session().setHistory(True) object_details = [utils.get_detail(self.classname, object_id) for object_id in blocking_result['blocked_objects']] finally: if blocking_result['blocking_action'] == 'blacklist_and_delete': # restore history flag in backend utils.get_corba_session().setHistory(cherrypy.session['history']) if blocking_result['blocking_action'] == 'block' and blocking_result.get('return_value'): holder_changes = {} for domain_holder_change in blocking_result['return_value']: holder_change = { 'old_holder': { 'handle': domain_holder_change.oldOwnerHandle, 'link': f_urls['contact'] + 'detail/?id=%s' % domain_holder_change.oldOwnerId, }, 'new_holder': { 'handle': domain_holder_change.newOwnerHandle, 'link': f_urls['contact'] + 'detail/?id=%s' % domain_holder_change.newOwnerId, } } holder_changes[domain_holder_change.domainId] = holder_change context['holder_changes'] = holder_changes context['blocked_objects'] = object_details del cherrypy.session['blocking_result'] else: context['heading'] = _('The result page has expired.') return self._render('blocking_result', ctx=context)
def detail(self, **kwd): """ Detail for Payment. If the payment is not paired with any Registrar, we display a pairing form too. """ log_req = self._create_log_req_for_object_view(**kwd) try: obj_id = int(kwd.get('id')) context = {} # Indicator whether the pairing action has been carried out # successfully. pairing_success = False user = cherrypy.session['user'] user_has_change_perms = not user.check_nperms("change.bankstatement") # When the user sends the pairing form we arrive at BankStatement # detail again, but this time we receive registrar_handle in kwd # => pair the payment with the registrar. if cherrypy.request.method == 'POST' and user_has_change_perms: registrar_handle = kwd.get('handle', None) payment_type = kwd.get('type', None) try: payment_type = int(payment_type) except (TypeError, ValueError): log_req.result = 'Fail' context['main'] = _('Requires integer as parameter (got %s).' % payment_type) raise CustomView(self._render('base', ctx=context)) pairing_success = self._pair_payment_with_registrar(obj_id, payment_type, registrar_handle) # Do not use cache - we want the updated BankStatementItem. detail = utils.get_detail(self.classname, int(obj_id), use_cache=False) context['detail'] = detail context['form'] = BankStatementPairingEditForm( method="POST", initial={ 'handle': kwd.get('handle', None), 'statementId': kwd.get('statementId', None), 'type': kwd.get('type', 2), 'id': obj_id}, onsubmit='return confirmAction();') if cherrypy.request.method == 'POST' and not pairing_success: # Pairing form was submitted, but pairing did not finish # successfully => Show an error. context['form'].non_field_errors().append( 'Could not pair. Perhaps you have entered an invalid handle?') if detail.type == editforms.PAYMENT_UNASSIGNED and user_has_change_perms: # Payment not paired => show the payment pairing edit form action = 'pair_payment' # invoiceId is a link to detail, but for id == 0 this detail does # not exist => hide invoiceId value so the link is not "clickable". # Note: No information is lost, because id == 0 semantically means # that there is no id. context['detail'].invoiceId = "" else: action = 'detail' if detail.type != editforms.PAYMENT_REGISTRAR: context['detail'].invoiceId = "" res = self._render(action, context) log_req.result = 'Success' finally: log_req.close() return res
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)
context['success'] = admin.setInZoneStatus(int(domain_id)) # TODO(tom): Do not catch generic exception here! except Exception, e: context['error'] = e else: context['error'] = _("Function setInZoneStatus() is not implemented in Admin.") # if it was succefful, redirect into domain detail if context['error'] is None: log_req.result = 'Success' raise cherrypy.HTTPRedirect(f_urls[self.classname] + '/detail/?id=%s' % domain_id) else: log_req.result = 'Fail' # display domain name try: context['handle'] = utils.get_detail(self.classname, int(domain_id), use_cache=False).handle except Exception, e: context['error'] = e # display page with error message return self._render('setinzonestatus', context) finally: log_req.close() class Contact(AdifPage, ListTableMixin): pass class NSSet(AdifPage, ListTableMixin): pass
def detail(self, **kwd): """ Detail for Payment. If the payment is not paired with any Registrar, we display a pairing form too. """ log_req = self._create_log_req_for_object_view(**kwd) try: obj_id = int(kwd.get('id')) context = {} # Indicator whether the pairing action has been carried out # successfully. pairing_success = False user = cherrypy.session['user'] user_has_change_perms = not user.check_nperms( "change.bankstatement") # When the user sends the pairing form we arrive at BankStatement # detail again, but this time we receive registrar_handle in kwd # => pair the payment with the registrar. if cherrypy.request.method == 'POST' and user_has_change_perms: registrar_handle = kwd.get('handle', None) payment_type = kwd.get('type', None) try: payment_type = int(payment_type) except (TypeError, ValueError): log_req.result = 'Fail' context['main'] = _( 'Requires integer as parameter (got %s).' % payment_type) raise CustomView(self._render('base', ctx=context)) pairing_success = self._pair_payment_with_registrar( obj_id, payment_type, registrar_handle) # Do not use cache - we want the updated BankStatementItem. detail = utils.get_detail(self.classname, int(obj_id), use_cache=False) context['detail'] = detail context['form'] = BankStatementPairingEditForm( method="POST", initial={ 'handle': kwd.get('handle', None), 'statementId': kwd.get('statementId', None), 'type': kwd.get('type', 2), 'id': obj_id }, onsubmit='return confirmAction();') if cherrypy.request.method == 'POST' and not pairing_success: # Pairing form was submitted, but pairing did not finish # successfully => Show an error. context['form'].non_field_errors().append( 'Could not pair. Perhaps you have entered an invalid handle?' ) if detail.type == editforms.PAYMENT_UNASSIGNED and user_has_change_perms: # Payment not paired => show the payment pairing edit form action = 'pair_payment' # invoiceId is a link to detail, but for id == 0 this detail does # not exist => hide invoiceId value so the link is not "clickable". # Note: No information is lost, because id == 0 semantically means # that there is no id. context['detail'].invoiceId = "" else: action = 'detail' if detail.type != editforms.PAYMENT_REGISTRAR: context['detail'].invoiceId = "" res = self._render(action, context) log_req.result = 'Success' finally: log_req.close() return res
context['error'] = e else: context['error'] = _( "Function setInZoneStatus() is not implemented in Admin.") # if it was succefful, redirect into domain detail if context['error'] is None: log_req.result = 'Success' raise cherrypy.HTTPRedirect(f_urls[self.classname] + '/detail/?id=%s' % domain_id) else: log_req.result = 'Fail' # display domain name try: context['handle'] = utils.get_detail(self.classname, int(domain_id), use_cache=False).handle except Exception, e: context['error'] = e # display page with error message return self._render('setinzonestatus', context) finally: log_req.close() class Contact(AdifPage, ListTableMixin): pass class NSSet(AdifPage, ListTableMixin):
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)