Beispiel #1
0
 def run_action_from_console(self,pk=None,an=None):
     """
     Not yet stable. Used by print_tx25.py.
     To be combined with the `show` management command.
     """
     dbutils.set_language(None)
     settings.SITE.startup()
     #~ settings.SITE.ui
     if pk is not None:
         #~ elem = self.get_row_by_pk(pk)
         #~ elem = self.model.objects.get(pk=pk)
         if an is None:
             an = self.default_elem_action_name
     elif an is None:
         an = self.default_list_action_name
     ba = self.get_action_by_name(an)
     #~ print ba
     if pk is None:
         ar = self.request(action=ba)
     else:
         ar = self.request(action=ba,selected_pks=[pk])
     
     ba.action.run_from_ui(ar)
     kw = ar.response
     msg = kw.get('message')
     if msg: 
         print msg
     url = kw.get('open_url') or kw.get('open_davlink_url')
     if url:
         os.startfile(url)
Beispiel #2
0
 def verbose_name(f):
     settings.SITE.set_language(None)
     label_en = force_unicode(_(f.verbose_name))
     babel_labels = []
     for lng in settings.SITE.languages[1:]:
         dbutils.set_language(lng.django_code)
         label = force_unicode(_(f.verbose_name))
         if label != label_en:
             babel_labels.append(label)
     if babel_labels:
         label_en += " (%s)" % ",".join(babel_labels)
     return label_en