コード例 #1
0
    def update(self, transition_id=None):
        if IWorkspaceContainer.providedBy(self.context.__parent__):
            self._old_url = WorkspaceAbsoluteURLView(self.context,
                                                     self.request)()
        workflow = interfaces.IWorkflow(self.context)
        if transition_id:
            transition = workflow.get_transition(transition_id)
            title = translate(_(transition.title), context=self.request)
            self.status = translate(_(
                u"Confirmation required for workflow transition: '${title}'",
                mapping={"title": title}),
                                    context=self.request)
        self.setupActions(transition_id)

        if (ILegislativeContent.providedBy(self.context)
                and get_mask(self.context) == "manual"
                and not self.context.registry_number):
            self.form_fields = self.form_fields.omit("note", "date_active")
        else:
            self.form_fields = self.form_fields.omit("registry_number")

        if not self.actions:
            self.form_fields = self.form_fields.omit("note", "date_active")
        elif not IFeatureAudit.providedBy(self.context):
            self.form_fields = self.form_fields.omit("note", "date_active")
        # !+SUPERFLUOUS_ObejctModifiedEvent(mr, nov-2011) the following update()
        # is causing a ModifiedEvent to be fired, causing a modify change to be
        # logged (while this workflow change should be just that).
        super(WorkflowActionViewlet, self).update()
コード例 #2
0
ファイル: common.py プロジェクト: bungeni-org/bungeni.main
    def form_name(self):
        if IVersion.providedBy(self.context):
            context = self.context.head
        else:
            context = self.context
        props = IDCDescriptiveProperties(context, None) or context

        if self.is_translation:
            language = get_language_by_name(self.context.language)["name"]
            return _(u"edit_translation_legend",
                     default=u"Editing $language translation of '$title'",
                     mapping={
                         "title": translate(props.title, context=self.request),
                         "language": language
                     })

        elif IVersion.providedBy(self.context):
            return _(u"edit_version_legend",
                     default=u'Editing "$title" (version $version)',
                     mapping={
                         "title": translate(props.title, context=self.request),
                         "version": self.context.seq
                     })
        return _(
            u"edit_item_legend",
            default=u'Editing "$title"',
            mapping={"title": translate(props.title, context=self.request)})
コード例 #3
0
 def update(self, transition_id=None):
     if IWorkspaceContainer.providedBy(self.context.__parent__):
         self._old_url = WorkspaceAbsoluteURLView(
             self.context, self.request)()
     workflow = interfaces.IWorkflow(self.context)
     if transition_id:
         transition = workflow.get_transition(transition_id)
         title = translate(_(transition.title), context=self.request)
         self.status = translate(
             _(u"Confirmation required for workflow transition: '${title}'",
                 mapping={"title": title}
             ), 
             context=self.request)
     self.setupActions(transition_id)
     
     if (ILegislativeContent.providedBy(self.context) and
             get_mask(self.context) == "manual" and 
             not self.context.registry_number
         ):
         self.form_fields = self.form_fields.omit("note", "date_active")
     else:
         self.form_fields = self.form_fields.omit("registry_number")
     
     if not self.actions: 
         self.form_fields = self.form_fields.omit("note", "date_active")
     elif not IFeatureAudit.providedBy(self.context):
         self.form_fields = self.form_fields.omit("note", "date_active")
     # !+SUPERFLUOUS_ObejctModifiedEvent(mr, nov-2011) the following update()
     # is causing a ModifiedEvent to be fired, causing a modify change to be 
     # logged (while this workflow change should be just that).
     super(WorkflowActionViewlet, self).update()
コード例 #4
0
ファイル: audit.py プロジェクト: bungeni-org/bungeni.main
def _df_modify_event(change):
    changed = ", ".join(get_changed_attribute_names(change))
    if changed:
        return """%s: %s on [%s]""" % (
            translate(change.action), changed, _link_event(change))
    else:
        # !+ should never occur?
        return "%s: [%s]" % (translate(change.action), _link_event(change))
コード例 #5
0
ファイル: versions.py プロジェクト: bungeni-org/bungeni.main
 def __init__(self, context, request):
     #!+context = removeSecurityProxy(context)
     browser.BungeniBrowserView.__init__(self, context, request)
     VersionLogMixin.__init__(self)
     self._page_title = translate(self.__class__._page_title)
     if hasattr(self.context, "title"):
         self._page_title = "%s: %s" % (
             self._page_title, translate(self.context.title))
コード例 #6
0
ファイル: audit.py プロジェクト: bungeni-org/bungeni.main
def _df_modify(change):
    # !+ rss -> get_changed_attribute_names(change) always returns empty list!
    changed = ", ".join(get_changed_attribute_names(change))
    if changed:
        return "%s: %s on [%s]" % (
            translate(change.action), changed, _label(change))
    else:
        # !+ should never occur?
        return "%s: [%s]" % (translate(change.action), _label(change))
コード例 #7
0
 def verbose_title(self):
     context = _merged(self.context)
     sitting_title = _(
         "verbose_sitting_title",
         default=u"Sitting of ${group_name} @ ${sitting_venue}",
         mapping={
             "group_name":
             IDCDescriptiveProperties(context.group).title,
             "sitting_venue":
             (IDCDescriptiveProperties(context.venue).title
              if context.venue else translate(_(u"no venue")))
         })
     return translate(sitting_title)
コード例 #8
0
ファイル: dc.py プロジェクト: BenoitTalbot/bungeni-portal
 def verbose_title(self):
     context = _merged(self.context)
     sitting_title = _("verbose_sitting_title", 
         default=u"Sitting of ${group_name} @ ${sitting_venue}",
         mapping = {
             "group_name": IDCDescriptiveProperties(context.group).title,
             "sitting_venue": (
                 IDCDescriptiveProperties(context.venue).title 
                 if context.venue else translate(_(u"no venue"))
             )
         }
     )
     return translate(sitting_title)
コード例 #9
0
ファイル: audit.py プロジェクト: bungeni-org/bungeni.main
def _df_workflow_head(change):
    # !+change.audit.status(mr, apr-2012) use the workflow state's title instead? 
    wf_prev, wf_prev_status = change.seq_previous, None
    if wf_prev:
        wf_prev_status = wf_prev.audit.status
    return (
        '%s: '
        '%s <span class="workflow_info">%s</span> '
        '%s <span class="workflow_info">%s</span>' % (
            translate(change.action),
            translate("from"),
            translate(wf_prev_status),
            translate("to"),
            translate(change.audit.status)))
コード例 #10
0
 def get_js(self):
     pagedate = datetime.date.today()
     if self.maxDate < pagedate:
         pagedate = self.maxDate
     if ((type(self._data) == datetime.date) or
         (type(self._data) == datetime.datetime)
     ):
         pagedate = self._data
     calendar = self.request.locale.dates.calendars["gregorian"]
     month = _(u"Choose Month")
     year = _(u"Enter Year")
     submit = _("OK")
     cancel = _(u"Cancel")
     invalidYear = _(u"Please enter a valid year")
     months_short = self.jstr(calendar.getMonthAbbreviations())
     months_long = self.jstr(calendar.getMonthNames())
     w_day_1char = self.jstr(
         [dn[:1] for dn in calendar.getDayAbbreviations()])
     w_day_short = self.jstr(
         [dn[:2] for dn in calendar.getDayAbbreviations()])
     w_day_medium = self.jstr(calendar.getDayAbbreviations())
     w_day_long = self.jstr(calendar.getDayNames())
     return self.js_template % {
         "name": self.field_name,
         "sel_day": self._day_name,
         "sel_month": self._month_name,
         "sel_year": self._year_name,
         "txt_date": self.date_name,
         "mindate": self.minDate.strftime("%m/%d/%Y"),
         "maxdate": self.maxDate.strftime("%m/%d/%Y"),
         "pagedate": pagedate.strftime("%m/%Y"),
         "months_short": months_short,
         "months_long": months_long,
         "w_day_1char": w_day_1char,
         "w_day_short": w_day_short,
         "w_day_medium": w_day_medium,
         "w_day_long": w_day_long,
         "month": translate(
             str(month), domain="bungeni", context=self.request),
         "year": translate(
             str(year), domain="bungeni", context=self.request),
         "submit": translate(
             str(submit), domain="bungeni", context=self.request),
         "cancel": translate(
             str(cancel), domain="bungeni", context=self.request),
         "invalidYear": translate(
             str(invalidYear), domain="bungeni", context=self.request)
     }
コード例 #11
0
def add_empty_listing_node(listing_node):
    """add an empty node to template output
    """
    no_items_tag = "p"
    no_items_node = etree.Element(no_items_tag)
    no_items_node.text = translate(_(u"No items found"))

    # add to previous element of listing node - then drop it
    prev_element = listing_node.getprevious()
    add_after = None
    if prev_element:
        drop_element(listing_node)
        add_after = prev_element
    else:
        if listing_node.tag in ["tr", "tbody"]:
            parent_table = None
            for prn in listing_node.iterancestors("table"):
                parent_table = prn
                break
            if parent_table is not None:
                # assumption: there's a title element
                add_after = parent_table.getprevious()
                drop_element(parent_table)
    if add_after is not None:
        add_after.addnext(no_items_node)
コード例 #12
0
    def javascript(self):
        kw = {
            "id":
            self.name,
            "dsname":
            self.name.replace(".", "_"),
            "oDS":
            self.oDS,
            "data":
            self.dataSource,
            "options":
            self.options,
            "help_text":
            translate(_(u"start typing to chose $fname...",
                        mapping=dict(fname=self.context.title)),
                      context=self.request)
        }

        return """
            <script type="text/javascript">
                YAHOO.namespace('oa.autocomplete');
                YAHOO.oa.autocomplete.%(dsname)s_func = new function() {

                    %(oDS)s

                    var helpText = "%(help_text)s";
                    var oAC = new YAHOO.widget.AutoComplete("%(id)s",
                        "%(id)s.container", oDS);
                    %(options)s
                    oAC.resultTypeList = false;
                    var myHiddenField = YAHOO.util.Dom.get("%(id)s.hidden");
                    var myHandler = function(sType, aArgs) {
                        var myAC = aArgs[0];
                        var elLI = aArgs[1];
                        var oData = aArgs[2];
                        myHiddenField.value = oData.id;
                    };
                    var helpTextHandler = function(event, args){
                        input = args[0].getInputEl();
                        if(event == "textboxBlur"){
                            if(!input.value){
                                input.value = helpText;
                            }
                        }else if(event == "textboxFocus"){
                            if(input.value==helpText){
                                input.value = "";
                            }
                        }
                    }
                    oAC.itemSelectEvent.subscribe(myHandler);
                    oAC.textboxBlurEvent.subscribe(helpTextHandler);
                    oAC.textboxFocusEvent.subscribe(helpTextHandler);
                    oAC.getInputEl().value = helpText;
                    return {
                        oDS: oDS,
                        oAC: oAC
                    };
                }();
            </script>
            """ % kw
コード例 #13
0
 def group_id(self):
     if IDoc.providedBy(self.context):
         if hasattr(self.context, "group_id") and self.context.group is not None:
             return IDCDescriptiveProperties(self.context.group).short_title
         elif hasattr(self.context, "chamber_id"):
             return IDCDescriptiveProperties(self.context.chamber).short_tile
     return translate("n/a", context=get_request())
コード例 #14
0
def add_empty_listing_node(listing_node):
    """add an empty node to template output
    """
    no_items_tag = "p"
    no_items_node = etree.Element(no_items_tag)
    no_items_node.text = translate(_(u"No items found"))

    # add to previous element of listing node - then drop it
    prev_element = listing_node.getprevious()
    add_after = None
    if prev_element:
        drop_element(listing_node)
        add_after = prev_element
    else:
        if listing_node.tag in ["tr", "tbody"]:
            parent_table = None
            for prn in listing_node.iterancestors("table"):
                parent_table = prn
                break
            if parent_table is not None:
                # assumption: there's a title element
                add_after = parent_table.getprevious()
                drop_element(parent_table)
    if add_after is not None:
        add_after.addnext(no_items_node)
コード例 #15
0
 def group_id(self):
     if IDoc.providedBy(self.context):
         if hasattr(self.context, "group_id") and self.context.group is not None:
             return IDCDescriptiveProperties(self.context.group).short_title
         elif hasattr(self.context, "chamber_id"):
             return IDCDescriptiveProperties(self.context.chamber).short_tile
     return translate("n/a", context=get_request())
コード例 #16
0
ファイル: dc.py プロジェクト: BenoitTalbot/bungeni-portal
 def description(self):
     context = _merged(self.context)
     return "%s %s (%s %s %s)" % (translate(_(u"Sitting scheduled for")),
             self.translate(context.group, "short_name"),
             context.start_date.strftime('%Y-%m-%d %H:%M'), 
             _(u"to"),
             context.end_date.strftime('%H:%M'))
コード例 #17
0
ファイル: dc.py プロジェクト: BenoitTalbot/bungeni-portal
 def title(self):
     context = _merged(self.context)
     return "%s %s, %s %s %s" % (translate(_(u"Debate Record:")), 
             self.translate(context.sitting, "short_name"), 
             context.sitting.start_date.strftime('%Y-%m-%d, %H:%M'), 
             _(u"to"), 
             context.sitting.end_date.strftime('%H:%M'))
コード例 #18
0
ファイル: common.py プロジェクト: bungeni-org/bungeni.main
 def title(self):
     return _(u"add_item_title",
              default=u"Adding $name",
              mapping={
                  "name":
                  translate(self.type_name.lower(), context=self.request)
              })
コード例 #19
0
 def title(self):
     context = _merged(self.context)
     return "%s %s, %s %s %s" % (
         translate(_(u"Debate Record:")),
         self.translate(context.sitting, "short_name"),
         context.sitting.start_date.strftime('%Y-%m-%d, %H:%M'), _(u"to"),
         context.sitting.end_date.strftime('%H:%M'))
コード例 #20
0
 def description(self):
     context = _merged(self.context)
     return "%s %s (%s %s %s)" % (
         translate(_(u"Debate record of ")),
         self.translate(context.sitting, "short_name"),
         context.sitting.start_date.strftime('%Y-%m-%d %H:%M'), _(u"to"),
         context.sitting.end_date.strftime('%H:%M'))
コード例 #21
0
 def description(self):
     context = _merged(self.context)
     return "%s %s (%s %s %s)" % (
         translate(_(u"Sitting scheduled for")),
         self.translate(context.group, "short_name"),
         context.start_date.strftime('%Y-%m-%d %H:%M'), _(u"to"),
         context.end_date.strftime('%H:%M'))
コード例 #22
0
ファイル: dc.py プロジェクト: BenoitTalbot/bungeni-portal
 def description(self):
     context = _merged(self.context)
     return "%s %s (%s %s %s)" % (translate(_(u"Debate record of ")),
             self.translate(context.sitting, "short_name"),
             context.sitting.start_date.strftime('%Y-%m-%d %H:%M'), 
             _(u"to"),
             context.sitting.end_date.strftime('%H:%M'))
コード例 #23
0
ファイル: workspace.py プロジェクト: bungeni-org/bungeni.main
 def get_item_types(self):
     result = dict([("", "-")])
     session = Session()
     group_types = session.query(distinct(domain.Group.type)).all()
     for group_type in group_types:
         result[group_type[0]] = translate(group_type[0],
                                           context=self.request)
     return result
コード例 #24
0
 def get_item_types(self):
     result = dict([("", "-")])
     session = Session()
     group_types = session.query(distinct(domain.Group.type)).all()
     for group_type in group_types:
         result[group_type[0]] = translate(
             group_type[0], context=self.request)
     return result
コード例 #25
0
ファイル: workspace.py プロジェクト: bungeni-org/bungeni.main
 def get_item_types(self):
     result = dict([("", "-")])
     for type_key, ti in capi.iter_type_info():
         workflow = ti.workflow
         if workflow and workflow.has_feature("workspace"):
             name = ti.descriptor_model.display_name if \
                 ti.descriptor_model else ti.workflow_key
             result[ti.workflow_key] = translate(name, context=self.request)
     return result
コード例 #26
0
ファイル: rss.py プロジェクト: kohsah/bungeni-portal
    def generate_channel(self):
        channel_element = self.response.createElement("channel")

        title = translate(self.channel_title, context=self.request)
        title_element = self.response.createElement("title")
        title_element.appendChild(self.response.createTextNode(title))
        channel_element.appendChild(title_element)

        description = translate(self.channel_title, context=self.request)
        description_element = self.response.createElement("description")
        description_element.appendChild(self.response.createTextNode(description))
        channel_element.appendChild(description_element)

        link_element = self.response.createElement("link")
        link_element.appendChild(self.response.createTextNode(self.channel_link))
        channel_element.appendChild(link_element)

        return channel_element
コード例 #27
0
ファイル: audit.py プロジェクト: bungeni-org/bungeni.main
 def __init__(self, context, request):
     browser.BungeniBrowserView.__init__(self, context, request)
     AuditLogMixin.__init__(self)
     if hasattr(self.context, "title"):
         dc = IDCDescriptiveProperties(self.context, None)
         self._page_title = "%s: %s" % (
             translate(self._page_title), 
             dc and dc.title or self.context.title
         )
コード例 #28
0
 def get_item_types(self):
     result = dict([("", "-")])
     for type_key, ti in capi.iter_type_info():
         workflow = ti.workflow
         if workflow and workflow.has_feature("workspace"):
             name = ti.descriptor_model.display_name if \
                 ti.descriptor_model else ti.workflow_key
             result[ti.workflow_key] = translate(name, context=self.request)
     return result
コード例 #29
0
    def javascript(self):
        kw = {"id": self.name,
              "dsname": self.name.replace(".", "_"),
              "oDS": self.oDS,
              "data": self.dataSource,
              "options": self.options,
              "help_text": translate(
                _(u"start typing to chose $fname...",
                    mapping = dict(fname=self.context.title)
                 ),
                 context=self.request
              )
        }

        return """
            <script type="text/javascript">
                YAHOO.namespace('oa.autocomplete');
                YAHOO.oa.autocomplete.%(dsname)s_func = new function() {

                    %(oDS)s

                    var helpText = "%(help_text)s";
                    var oAC = new YAHOO.widget.AutoComplete("%(id)s",
                        "%(id)s.container", oDS);
                    %(options)s
                    oAC.resultTypeList = false;
                    var myHiddenField = YAHOO.util.Dom.get("%(id)s.hidden");
                    var myHandler = function(sType, aArgs) {
                        var myAC = aArgs[0];
                        var elLI = aArgs[1];
                        var oData = aArgs[2];
                        myHiddenField.value = oData.id;
                    };
                    var helpTextHandler = function(event, args){
                        input = args[0].getInputEl();
                        if(event == "textboxBlur"){
                            if(!input.value){
                                input.value = helpText;
                            }
                        }else if(event == "textboxFocus"){
                            if(input.value==helpText){
                                input.value = "";
                            }
                        }
                    }
                    oAC.itemSelectEvent.subscribe(myHandler);
                    oAC.textboxBlurEvent.subscribe(helpTextHandler);
                    oAC.textboxFocusEvent.subscribe(helpTextHandler);
                    oAC.getInputEl().value = helpText;
                    return {
                        oDS: oDS,
                        oAC: oAC
                    };
                }();
            </script>
            """ % kw
コード例 #30
0
 def translation_status(self):
     if ITranslatable.providedBy(self.context) and len(capi.pivot_languages):
         untranslated = list(capi.pivot_languages)
         if self.context.language in untranslated:
             untranslated.remove(self.context.language)
         for pivot_lang in untranslated:
             if translation.get_field_translations(self.context, pivot_lang):
                 untranslated.remove(pivot_lang)
         if len(untranslated):
             i18n_langs = []
             locale = locales.getLocale(get_default_language().split("-")[0], None)
             for lang in untranslated:
                 if locale and locale.displayNames and locale.displayNames.languages:
                     i18n_langs.append(locale.displayNames.languages.get(lang, lang))
                     continue
                 i18n_langs.append(lang)
             return ", ".join(i18n_langs)
         return translate(_("translated"), context=get_request())
     return translate("n/a", context=get_request())
コード例 #31
0
ファイル: browser.py プロジェクト: bungeni-org/bungeni.main
 def add_wf_meta(enum):
     index, item = enum
     node = nodes[index]
     item["item_id"] = node.item_id
     if model_interfaces.IScheduleText.providedBy(node.item):
         return
     if not include_wf:
         return
     wfc = IWorkflowController(node.item, None)
     if wfc is None:
         return
     item["wf_state"] = translate(
         wfc.state_controller.get_state().title)
     item["wf_actions"] = [
         dict(value=transition,
              text=translate(
                  wfc.workflow.get_transition(transition).title))
         for transition in wfc.getFireableTransitionIds()
     ]
コード例 #32
0
ファイル: common.py プロジェクト: bungeni-org/bungeni.main
 def form_description(self):
     language = get_language_by_name(self.language)["name"]
     props = ((IDCDescriptiveProperties.providedBy(self.context)
               and self.context) or IDCDescriptiveProperties(self.context))
     if self.is_translation:
         return _(u"edit_translation_legend",
                  default=u'Editing $language translation of "$title"',
                  mapping={
                      "title": translate(props.title, context=self.request),
                      "language": language
                  })
     else:
         return _(u"translate_item_help",
             default=u'The document "$title" has not yet been translated ' \
                 u"into $language. Use this form to add the translation",
             mapping={
                 "title": translate(props.title, context=self.request),
                 "language": language
             }
         )
コード例 #33
0
ファイル: rss.py プロジェクト: bungeni-org/bungeni.main
    def generate_channel(self):
        channel_element = self.response.createElement("channel")

        title = translate(self.channel_title, context=self.request)
        title_element = self.response.createElement("title")
        title_element.appendChild(self.response.createTextNode(title))
        channel_element.appendChild(title_element)

        description = translate(self.channel_title, context=self.request)
        description_element = self.response.createElement("description")
        description_element.appendChild(
            self.response.createTextNode(description))
        channel_element.appendChild(description_element)

        link_element = self.response.createElement("link")
        link_element.appendChild(
            self.response.createTextNode(self.channel_link))
        channel_element.appendChild(link_element)

        return channel_element
コード例 #34
0
ファイル: common.py プロジェクト: BenoitTalbot/bungeni-portal
 def form_name(self):
     if IVersion.providedBy(self.context):
         context = self.context.head
     else:
         context = self.context
     props = IDCDescriptiveProperties(context, None) or context
     
     if self.is_translation:
         language = get_language_by_name(self.context.language)["name"]
         return _(u"edit_translation_legend",
                  default=u"Editing $language translation of '$title'",
                  mapping={"title": translate(props.title, context=self.request),
                           "language": language})
     
     elif IVersion.providedBy(self.context):
         return _(u"edit_version_legend",
                  default=u'Editing "$title" (version $version)',
                  mapping={"title": translate(props.title, context=self.request),
                           "version": self.context.seq})
     return _(u"edit_item_legend", default=u'Editing "$title"',
              mapping={"title": translate(props.title, context=self.request)})
コード例 #35
0
ファイル: menu.py プロジェクト: BenoitTalbot/bungeni-portal
 def extra(self):
     wf = IWorkflow(self.context, None)
     if wf is None:
         return {"id": self.id}
     status = self.context.status
     state_title = translate(misc.get_wf_state(self.context),
         domain="bungeni", context=self.request)
     return {
         "id": self.id,
         "class": "state-%s" % status,
         "state": status,
         "stateTitle": state_title
     }
コード例 #36
0
ファイル: api.py プロジェクト: bungeni-org/bungeni.main
 def __call__(self):
     wfc = IWorkflowController(self.context)
     wf = wfc.workflow
     tids = wfc.getManualTransitionIds()
     transitions = {}
     context_url = url.absoluteURL(self.context, self.request)
     for tid in tids:
         item_url = "%s/change_workflow_state?transition_id=%s" % (context_url, tid)
         title = translate(wf.get_transition(tid).title,
             domain="bungeni",
             context=self.request)
         transitions[tid] = {"url":item_url, "title":title}
     misc.set_json_headers(self.request)
     return simplejson.dumps(transitions)
コード例 #37
0
 def extra(self):
     wf = IWorkflow(self.context, None)
     if wf is None:
         return {"id": self.id}
     status = self.context.status
     state_title = translate(misc.get_wf_state(self.context),
                             domain="bungeni",
                             context=self.request)
     return {
         "id": self.id,
         "class": "state-%s" % status,
         "state": status,
         "stateTitle": state_title
     }
コード例 #38
0
 def translation_status(self):
     if ITranslatable.providedBy(self.context) and len(capi.pivot_languages):
         untranslated = list(capi.pivot_languages)
         if self.context.language in untranslated:
             untranslated.remove(self.context.language)
         for pivot_lang in untranslated:
             if translation.get_field_translations(self.context, pivot_lang):
                 untranslated.remove(pivot_lang)
         if len(untranslated):
             i18n_langs = []
             locale = locales.getLocale(get_default_language().split("-")[0], None)
             for lang in untranslated:
                 if (locale and 
                         locale.displayNames and 
                         locale.displayNames.languages
                     ):
                     i18n_langs.append(
                         locale.displayNames.languages.get(lang, lang))
                     continue
                 i18n_langs.append(lang)
             return ", ".join(i18n_langs)
         return translate(_("translated"), context=get_request())
     return translate("n/a", context=get_request())
コード例 #39
0
 def update(self):
     self.tabs = []
     directory = getSite()["workspace"][self.folder]
     for key in directory.keys():
         tab_url = url.absoluteURL(directory[key], self.request)
         tab = {}
         if IWorkspaceDocuments.providedBy(directory):
             tab["title"] = translate("section_workspace_%s" % key)
         else:
             tab["title"] = directory[key].title
         tab["tab_type"] = directory[key].__name__
         tab["url"] = tab_url
         tab["active"] = self.request.getURL().startswith(tab_url)
         self.tabs.append(tab)
コード例 #40
0
ファイル: browser.py プロジェクト: bungeni-org/bungeni.main
 def calendar_js_globals(self):
     limit_start = ISchedulingContext(self.context).start_date
     limit_end = ISchedulingContext(self.context).end_date
     cal_globals = dict(
         context_group=self.title,
         limit_start=limit_start.isoformat() if limit_start else None,
         limit_end=limit_end.isoformat() if limit_end else None,
         ical_url=self.ical_url,
         required_fields=[
             field.field.getName()
             for field in self.partial_event_form.form_fields
             if field.field.required
         ],
         view_url=self.url,
         venues_view_title=translate(TITLE_VENUES_VIEW),
         text_group=translate(FIELD_GROUP),
         text_start_date=translate(FIELD_START_DATE),
         text_end_date=translate(FIELD_END_DATE),
         text_venue=translate(FIELD_VENUE),
         text_activity_type=translate(_(u"Activity Type")),
         text_meeting_type=translate(_(u"Meeting Type")),
         text_convocation_type=translate(_(u"Convocation Type")),
         text_sitting=translate(TITLE_SITTING),
         text_view=translate(ACTION_VIEW_SITTING),
         error_messages=dict(
             default=_(u"Please check the highlighted sittings. "
                       "Failed to apply changes"),
             updated=_(u"Please review the highlighted sittings."
                       " Could not apply changes."),
             deleted=_(u"Please review the highlighted events."
                       " Could not be deleted.")))
     return """var cal_globals = %s;
         var timeline_data = { venues: %s, combined: %s };
         var group_urls= %s;""" % (
         json.dumps(cal_globals), json.dumps(self.venues_data),
         json.dumps(self.groups_data), json.dumps(self.calendar_urls()))
コード例 #41
0
ファイル: workspace.py プロジェクト: bungeni-org/bungeni.main
 def get_status(self, item_type):
     result = {}
     for type_key, ti in capi.iter_type_info():
         # !+ why compare workflow_key to item_type ?!
         if (ti.workflow_key == item_type):
             states = ti.workflow.get_state_ids(tagged=["public"],
                                                not_tagged=["terminal"],
                                                conjunction="AND")
             for state in states:
                 state_title = translate(ti.workflow.get_state(state).title,
                                         domain="bungeni",
                                         context=self.request)
                 result[state] = state_title
             break
     return result
コード例 #42
0
ファイル: common.py プロジェクト: BenoitTalbot/bungeni-portal
 def form_description(self):
     language = get_language_by_name(self.language)["name"]
     props = (
         (IDCDescriptiveProperties.providedBy(self.context) and
             self.context) or
         IDCDescriptiveProperties(self.context)
     )
     if self.is_translation:
         return _(u"edit_translation_legend",
             default=u'Editing $language translation of "$title"',
             mapping={
                 "title": translate(props.title, context=self.request),
                 "language": language
             }
         )
     else:
         return _(u"translate_item_help",
             default=u'The document "$title" has not yet been translated ' \
                 u"into $language. Use this form to add the translation",
             mapping={
                 "title": translate(props.title, context=self.request),
                 "language": language
             }
         )
コード例 #43
0
 def expand_containers(self, items, containers, _url, chain=(), context=None):
     #seen_context = False
     _url = _url.rstrip("/")
     current = False
     
     for key, container in containers:
         assert IAlchemistContainer.providedBy(container)
         
         # do not include doc containers for docs who do not specifically 
         # declare the parent group instance as a workspace.group_name
         if IDoc.implementedBy(container.domain_model):
             group = get_group_for_context(container)
             assert IGroup.providedBy(group)
             doc_type_key = naming.polymorphic_identity(container.domain_model)
             if not group.is_type_workspaced(doc_type_key):
                 continue
         
         label = container.domain_model.__name__
         descriptor = utils.get_descriptor(container.domain_model)
         order = 999
         if descriptor:
             order = descriptor.order
             label = getattr(descriptor, "container_name", None) or \
                 getattr(descriptor, "display_name", None)
         
         if context is not None:
             current = container.__name__ == context.__name__
         selected = not len(chain) and current
         if current:
             #seen_context = True
             nodes = self.expand(chain)
         else:
             nodes = ()
         
         key_url = "%s/%s" % (_url, key)
         items.append({
                 "id": self.get_nav_entry_id(key_url),
                 "order": order,
                 "label": translate(label, 
                     target_language=get_default_language(),
                     domain="bungeni"),
                 "url": key_url,
                 "current": current,
                 "selected": selected,
                 "kind": "container",
                 "nodes": nodes,
             })
     items.sort(key=lambda item:(item['order'], item['label']))
コード例 #44
0
 def get_status(self, item_type):
     result = {}
     for type_key, ti in capi.iter_type_info():
         # !+ why compare workflow_key to item_type ?!
         if (ti.workflow_key == item_type):
             states = ti.workflow.get_state_ids(
                 tagged=["public"], not_tagged=["terminal"],
                 conjunction="AND")
             for state in states:
                 state_title = translate(
                     ti.workflow.get_state(state).title,
                     domain="bungeni",
                     context=self.request
                 )
                 result[state] = state_title
             break
     return result
コード例 #45
0
ファイル: fields.py プロジェクト: BenoitTalbot/bungeni-portal
    def setUpWidgets(self, ignore_request=False):
        languages = get_all_languages()
        self.form_fields = filterFields(self.context, self.form_fields)

        # do not display empty form fields
        omit_names = []
        for f in self.form_fields:
            val = getattr(self.context, f.__name__)
            if val is None:
                omit_names.append(f.__name__)
        self.form_fields = self.form_fields.omit(*omit_names)
        context = self.context
        if ITranslatable.providedBy(self.context):
            lang = get_default_language()
            try:
                translation = get_field_translations(self.context, lang)
            except:
                translation = []
            if (
                not translation
                and getattr(self.context, "language", None)
                and getattr(self.context, "language", None) != lang
            ):
                supported_lang = languages.get(lang)
                if supported_lang:
                    langname = supported_lang.get("native", None)
                    if langname == None:
                        langname = supported_lang.get("name")
                    self.status = translate(
                        _(u"This content is not yet translated into" + " $language", mapping={"language": langname}),
                        domain="bungeni",
                        context=self.request,
                    )
            context = copy(removeSecurityProxy(self.context))
            for field_translation in translation:
                setattr(context, field_translation.field_name, field_translation.field_text)
        self.widgets = form.setUpEditWidgets(
            self.form_fields,
            "",
            context,
            self.request,
            adapters=self.adapters,
            for_display=True,
            ignore_request=ignore_request,
        )
コード例 #46
0
 def get_item_types(self):
     workspace_config = component.getUtility(IWorkspaceTabsUtility)
     roles = get_workspace_roles() + ROLES_DIRECTLY_DEFINED_ON_OBJECTS
     domains = []
     for role in roles:
         dom = workspace_config.get_role_domains(role, self.context.__name__)
         if dom:
             for key in dom:
                 if key not in domains:
                     domains.append(key)
     result = dict([("", "-")])
     for d in domains:
         value = workspace_config.get_type(d)
         if value:
             descriptor_model = utils.get_descriptor(d)
             name = descriptor_model.display_name if descriptor_model else value
             result[value] = translate(name, context=self.request)
     return result
コード例 #47
0
ファイル: fields.py プロジェクト: bungeni-org/bungeni.main
    def setUpWidgets(self, ignore_request=False):
        languages = get_all_languages()
        self.form_fields = filterFields(self.context, self.form_fields)

        #do not display empty form fields
        omit_names = []
        for f in self.form_fields:
            val = getattr(self.context, f.__name__)
            if val is None:
                omit_names.append(f.__name__)
        self.form_fields = self.form_fields.omit(*omit_names)
        context = self.context
        if ITranslatable.providedBy(self.context):
            lang = get_default_language()
            try:
                translation = get_field_translations(self.context, lang)
            except:
                translation = []
            if (not translation and getattr(self.context, "language", None)
                    and getattr(self.context, "language", None) != lang):
                supported_lang = languages.get(lang)
                if supported_lang:
                    langname = supported_lang.get("native", None)
                    if langname == None:
                        langname = supported_lang.get("name")
                    self.status = translate(
                        _(u"This content is not yet translated into" +\
                            " $language",
                            mapping={"language": langname}),
                        domain="bungeni",
                        context=self.request
                    )
            context = copy(removeSecurityProxy(self.context))
            for field_translation in translation:
                setattr(context, field_translation.field_name,
                        field_translation.field_text)
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             "",
                                             context,
                                             self.request,
                                             adapters=self.adapters,
                                             for_display=True,
                                             ignore_request=ignore_request)
コード例 #48
0
ファイル: listing.py プロジェクト: bungeni-org/bungeni.main
 def getter(item, formatter):
     state_title = get_wf_state(item)
     request = common.get_request()
     state_title = translate(state_title, domain="bungeni", context=request)
     # !+MY_LISTING_ROWS(mr, aug-2012) the following is a (exploratory)
     # mechanism to add a distinction between what rows are owned by the
     # current user and others. Here it is added only to "status" columns
     # but a generic "row-level" means to mark such rows as different
     # from the others may be a useful feature.
     if IWorkspaceSectionLayer.providedBy(request):
         item_user = None
         if hasattr(item, "owner"):
             item_user = item.owner
         elif hasattr(item, "drafter"):
             item_user = item.drafter
         # !+delegation?
         if item_user and (item_user == get_login_user()):
             state_title = "<b>%s</b> *" % (state_title)
     return state_title
コード例 #49
0
ファイル: audit.py プロジェクト: bungeni-org/bungeni.main
 def columns(self):
     return [
         listing.related_user_name_column("user_id", _("user")),
         column.GetterColumn(name="date_active",
             title=_("audit_column_date_active", "date active"),
             getter=lambda i,f: self.date_formatter.format(i.date_active)),
         column.GetterColumn(name="object",
             title=_("audit_column_object", "object"), 
             getter=lambda i,f: get_auditable_type_key(i)),
         GetterColumn(name="description",
             title=_("audit_column_description", "description"), 
             getter=lambda i,f: format_description(i, self.head)),
         column.GetterColumn(name="note",
             title=_("audit_column_note", "note"),
             getter=lambda i,f: i.note and translate(i.note) or ""),
         column.GetterColumn(name="date_audit",
             title=_("audit_column_date_audit", "date audit"),
             getter=lambda i,f: self.date_formatter.format(i.date_audit)),
     ]
コード例 #50
0
ファイル: listing.py プロジェクト: kohsah/bungeni-portal
 def getter(item, formatter):
     state_title = get_wf_state(item)
     request = common.get_request()
     state_title = translate(state_title, domain="bungeni", context=request)
     # !+MY_LISTING_ROWS(mr, aug-2012) the following is a (exploratory) 
     # mechanism to add a distinction between what rows are owned by the 
     # current user and others. Here it is added only to "status" columns
     # but a generic "row-level" means to mark such rows as different 
     # from the others may be a useful feature.
     if IWorkspaceSectionLayer.providedBy(request):
         item_user = None
         if hasattr(item, "owner"):
             item_user = item.owner
         elif hasattr(item, "drafter"):
             item_user = item.drafter
         # !+delegation?
         if item_user and (item_user == get_login_user()):
             state_title = "<b>%s</b> *" % (state_title)
     return state_title
コード例 #51
0
 def getFieldColumns(self):
     column_model = []
     field_model = []
     default_format = COLUMN_DEFS.get("default")
     default_format_first = COLUMN_DEFS.get("default_first")
     for field in self.workspace_fields:
         coldef = {
             "key": field.name,
             "label": translate(_(field.title), context=self.request),
             "formatter": self.context.__name__,
         }
         coldef_format = COLUMN_DEFS.get(field.name, None)
         if column_model == []:
             if not coldef_format:
                 coldef_format = default_format_first
         else:
             if not coldef_format:
                 coldef_format = default_format
         column_model.append(coldef_format % coldef)
         field_model.append('{key:"%s"}' % (field.name))
     return ",".join(column_model), ",".join(field_model)