def get_reports_map(self): from ra.admin.admin import get_reports_map from ra.base.registry import get_ra_model_by_name model = get_ra_model_by_name(self.kwargs['base_model']) val = get_reports_map(model.get_class_name().lower(), self.request.user, self.request, self.get_order_list()) return val
def get_meta_data(self): model = registry.get_ra_model_by_name(self.kwargs['base_model']) verbose_name = model._meta.verbose_name verbose_name_plural = model._meta.verbose_name_plural is_bidi = get_language_bidi() if is_bidi: page_title = '%s %s' % (ugettext('reports'), model._meta.verbose_name_plural) else: page_title = '%s %s' % (model._meta.verbose_name_plural, ugettext('reports')) opts = model._meta return verbose_name, verbose_name_plural, page_title, opts
def get_link(self, result): from ra.base.registry import get_ra_model_by_name from django.urls import NoReverseMatch model_name = result.identifier model = get_ra_model_by_name(result.identifier) try: redirect_url = reverse( '%s:%s_%s_view' % (RA_ADMIN_SITE_NAME, model._meta.app_label, model._meta.model_name), args=(result.id,)) except NoReverseMatch: redirect_url = reverse( '%s:%s_%s_change' % (RA_ADMIN_SITE_NAME, model._meta.app_label, model._meta.model_name), args=(result.id,)) return redirect_url
def get_verbose_data(self): """ Used in Charts, (maybe other places) :return: a dict with keys mapping translations """ from ra.base import cache, registry from django.utils.translation import ugettext_lazy as original_ugettext ret_val = {} form_settings = self.form_settings _date, to_date = self._get_verbose_date(form_settings) ret_val['date_verbose'] = _date ret_val['to_date'] = to_date form_filters = self.form._fkeys # ('fkeys', []) for f in form_filters: if '_id' in f: main_filter = self.applied_filters.get(f, '') model_name = f[:-3] model_klass = registry.get_ra_model_by_name(model_name) if not main_filter and model_klass: header = '%s %s' % (original_ugettext('for all'), model_klass._meta.verbose_name_plural) else: ids = main_filter.split(',') length = len(ids) if length == 1: ''' One Selected ''' header = cache.get_cached_name(model_name, ids[0]) else: header = '%s %s' % (original_ugettext( 'several'), model_klass._meta.verbose_name_plural) ret_val[model_name] = header ret_val['time_series_pattern'] = ugettext( form_settings.get('time_series_pattern', 'n/A')) return ret_val