示例#1
0
    def rssItems(self):
        """Elements of <item> 
        A channel may contain any number of <item>s. 
        An item may represent a "story" -- much like a story in a newspaper or magazine; 
        if so its description is a synopsis of the story, and the link points to the full story. 
        An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed; 
        see examples), and the link and title may be omitted. 
        All elements of an item are optional, 
        however at least one of title or description must be present. 
        
        title	The title of the item.
        link	The URL of the item.
        description     	The item synopsis.
        pubDate	Indicates when the item was published. 
        """

        bill_id = self.context.bill_id

        results = queries.execute_sql(statements.sql_bill_timeline,
                                      item_id=bill_id)
        path = url.absoluteURL(self.context, self.request)
        rlist = []
        for result in results:
            rlist.append({
                'title': result.atype,
                'description': result.title,
                'date': result.adate.isoformat()
            })
        return rlist
示例#2
0
    def rssItems(self):
        """Elements of <item> 
        A channel may contain any number of <item>s. 
        An item may represent a "story" -- much like a story in a newspaper or magazine; 
        if so its description is a synopsis of the story, and the link points to the full story. 
        An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed; 
        see examples), and the link and title may be omitted. 
        All elements of an item are optional, 
        however at least one of title or description must be present. 
        
        title	The title of the item.
        link	The URL of the item.
        description     	The item synopsis.
        pubDate	Indicates when the item was published. 
        """

        bill_id = self.context.bill_id

        results = queries.execute_sql(
                            statements.sql_bill_timeline, item_id=bill_id)
        path = url.absoluteURL(self.context, self.request)
        rlist = []
        for result in results:
            rlist.append({
                    'title': result.atype,
                    'description': result.title,
                    'date': result.adate.isoformat()
                })
        return rlist
示例#3
0
 def update(self):
     """
     refresh the query
     """
     item_id = self.context.parliamentary_item_id
     self.results = queries.execute_sql(
                         self.sql_timeline, item_id=item_id)
     path = ui_url.absoluteURL(self.context, self.request)
     self.addurl = '%s/event/add' %( path )
示例#4
0
    def update(self):
        """Refresh the query.
        """

        # evaluate serialization of a dict, failure returns an empty dict
        def _eval_as_dict(s):
            try:
                d = eval(s)
                assert isinstance(d, dict)
                return d
            except (SyntaxError, TypeError, AssertionError):
                #debug.log_exc(sys.exc_info(), log_handler=log.info)
                return {}

        # NOTE: only *Change records have a "notes" dict attribute and the
        # content of this depends on the value of "atype" (see core/audit.py)
        item_id = self.context.parliamentary_item_id
        self.results = [
            dict(atype=action,
                 item_id=piid,
                 description=desc,
                 adate=date,
                 notes=_eval_as_dict(notes)) for action, piid, desc, date,
            notes in queries.execute_sql(self.sql_timeline, item_id=item_id)
        ]

        # Filter out workflow draft items for anonymous users
        if get_principal_id() in ("zope.anybody", ):
            _draft_states = ("draft", "working_draft")

            def show_timeline_item(result):
                if result["atype"] == "workflow":
                    if result["notes"].get("destination") in _draft_states:
                        return False
                return True

            self.results = [
                result for result in self.results if show_timeline_item(result)
            ]

        #change_cls = getattr(domain, "%sChange" % (self.context.__class__.__name__))
        for r in self.results:
            # workflow
            if r["atype"] == "workflow":
                # description
                # the workflow transition change log stores the (unlocalized)
                # human title for the transition's destination workflow state
                # -- here we just localize what is supplied:
                r["description"] = _(r["description"])
                # NOTE: we could elaborate an entirely custom description
                # from scratch e.g via interpolation of a template string:
                '''
                if r["notes"].get("destination", ""):
                    description = "%s %s" % (
                                _("some text"),
                                _(misc.get_wf_state(
                                    self.context, r["notes"]["destination"])))
                '''
            # event
            elif r["atype"] == "event":
                # description
                r["description"] = """<a href="event/obj-%s">%s</a>""" % (
                    r["item_id"], _(r["description"]))
            # version
            elif r["atype"] == "version":
                # description
                try:
                    r["description"] = """<a href="versions/obj-%s">%s</a>""" % (
                        r["notes"]["version_id"], _(r["description"]))
                except (KeyError, ):
                    # no recorded version_id, just localize what is supplied
                    r["description"] = _(r["description"])
        #
        path = url.absoluteURL(self.context, self.request)
        self.addurl = '%s/event/add' % (path)
示例#5
0
    def update(self):
        """Refresh the query.
        """
        # evaluate serialization of a dict, failure returns an empty dict
        def _eval_as_dict(s):
            try:
                d = eval(s)
                assert isinstance(d, dict)
                return d
            except (SyntaxError, TypeError, AssertionError):
                #debug.log_exc(sys.exc_info(), log_handler=log.info)
                return {}

        # !+CHANGE_EXTRAS(mr, dec-2010)
        # only *Change records have an extras dict (as "notes" str attr) and the 
        # content of this depends on the value of "atype" (see core/audit.py)
        item_id = self.context.parliamentary_item_id
        self.items = [ dict(atype=action, item_id=piid, description=desc,
                              adate=date, notes=_eval_as_dict(notes))
                for action, piid, desc, date, notes in
                queries.execute_sql(self.sql_timeline, item_id=item_id) ]

        # Filter out workflow draft items for anonymous users
        if get_principal_id() in ("zope.anybody",):
            _draft_states = ("draft", "working_draft")
            def show_timeline_item(item):
                if item["atype"] == "workflow":
                    if item["notes"].get("destination") in _draft_states:
                        return False
                return True
            self.items = [ item for item in self.items
                             if show_timeline_item(item) ]

        #change_cls = getattr(domain, "%sChange" % (self.context.__class__.__name__))
        for r in self.items:
            # workflow
            if r["atype"] == "workflow":
                # description
                # the workflow transition change log stores the (unlocalized) 
                # human title for the transition's destination workflow state 
                # -- here we just localize what is supplied:
                r["description"] = _(r["description"])
                # NOTE: we could elaborate an entirely custom description 
                # from scratch e.g via interpolation of a template string:
                '''
                if r["notes"].get("destination", ""):
                    description = "%s %s" % (
                                _("some text"),
                                _(misc.get_wf_state(
                                    self.context, r["notes"]["destination"])))
                '''
            # event
            elif r["atype"] == "event":
                # description 
                r["description"] = """<a href="event/obj-%s">%s</a>""" % (
                        r["item_id"], _(r["description"]))
            # version
            elif r["atype"] == "version":
                # description 
                try:
                    r["description"] = """<a href="versions/obj-%s">%s</a>""" % (
                                    r["notes"]["version_id"], _(r["description"]))
                except (KeyError,):
                    # no recorded version_id, just localize what is supplied
                    r["description"] = _(r["description"])
        #
        path = url.absoluteURL(self.context, self.request)
        self.addurl = "%s/event/add" % (path)
示例#6
0
    def update(self):
        if self.request.method == "POST":
            # !+NUMBER_GENERATION (ah, nov-2011) - Reset the number sequence here.
            # Added the 'false' parameter at the end, otherwise setval() automatically
            # increments the sequence when called.
            # NOTE: this is a direct PG call, there is no SQLAlchemy way of resetting
            # a sequence, perhaps they should be dropped and recreated in SQLALchemy
            if self.request.get("form.questions_number") == "on":
                execute_sql(
                    "SELECT setval('question_registry_sequence', 1, false);")
            if self.request.get("form.motions_number") == "on":
                execute_sql(
                    "SELECT setval('motion_registry_sequence', 1, false);")
            if self.request.get("form.agendaitems_number") == "on":
                execute_sql(
                    "SELECT setval('agendaitem_registry_sequence', 1, false);")
            if self.request.get("form.bills_number") == "on":
                execute_sql(
                    "SELECT setval('bill_registry_sequence', 1, false);")
            if self.request.get("form.reports_number") == "on":
                execute_sql(
                    "SELECT setval('report_registry_sequence', 1, false);")
            if self.request.get("form.tableddocuments_number") == "on":
                execute_sql(
                    "SELECT setval('tableddocument_registry_sequence', 1, false);"
                )
            if self.request.get("form.global_number") == "on":
                execute_sql(
                    "SELECT setval('registry_number_sequence', 1, false);")

        settings = \
            component.getUtility(interfaces.IBungeniRegistrySettings)()
        self.adapters = {interfaces.IBungeniRegistrySettings: settings}
示例#7
0
    def update(self):
        if self.request.method == "POST":
            if self.request.get("form.questions_number") == "on":
                execute_sql("SELECT setval('question_registry_sequence', 1);")
            if self.request.get("form.motions_number") == "on":
                execute_sql("SELECT setval('motion_registry_sequence', 1);")
            if self.request.get("form.agendaitems_number") == "on":
                execute_sql(
                    "SELECT setval('agendaitem_registry_sequence', 1);")
            if self.request.get("form.bills_number") == "on":
                execute_sql("SELECT setval('bill_registry_sequence', 1);")
            if self.request.get("form.reports_number") == "on":
                execute_sql("SELECT setval('report_registry_sequence', 1);")
            if self.request.get("form.tableddocuments_number") == "on":
                execute_sql(
                    "SELECT setval('tableddocument_registry_sequence', 1);")
            if self.request.get("form.global_number") == "on":
                execute_sql("SELECT setval('registry_number_sequence', 1);")

        settings = \
            component.getUtility(interfaces.IBungeniRegistrySettings)()
        self.adapters = {interfaces.IBungeniRegistrySettings: settings}
        super(RegistrySettings, self).update()
示例#8
0
    def update(self):
        if self.request.method == "POST":
            if self.request.get("form.questions_number") == "on":
                execute_sql("SELECT setval('question_registry_sequence', 1);")
            if self.request.get("form.motions_number") == "on":
                execute_sql("SELECT setval('motion_registry_sequence', 1);")
            if self.request.get("form.agendaitems_number") == "on":
                execute_sql(
                    "SELECT setval('agendaitem_registry_sequence', 1);")
            if self.request.get("form.bills_number") == "on":
                execute_sql("SELECT setval('bill_registry_sequence', 1);")
            if self.request.get("form.reports_number") == "on":
                execute_sql("SELECT setval('report_registry_sequence', 1);")
            if self.request.get("form.tableddocuments_number") == "on":
                execute_sql(
                    "SELECT setval('tableddocument_registry_sequence', 1);")
            if self.request.get("form.global_number") == "on":
                execute_sql("SELECT setval('registry_number_sequence', 1);")

        settings = \
            component.getUtility(interfaces.IBungeniRegistrySettings)()
        self.adapters = {interfaces.IBungeniRegistrySettings: settings}
        super(RegistrySettings, self).update()
示例#9
0
    def update(self):
        if self.request.method == "POST":
            # !+NUMBER_GENERATION (ah, nov-2011) - Reset the number sequence here.
            # Added the 'false' parameter at the end, otherwise setval() automatically
            # increments the sequence when called.
            # NOTE: this is a direct PG call, there is no SQLAlchemy way of resetting
            # a sequence, perhaps they should be dropped and recreated in SQLALchemy
            if self.request.get("form.questions_number") == "on":
                execute_sql("SELECT setval('question_registry_sequence', 1, false);")
            if self.request.get("form.motions_number") == "on":
                execute_sql("SELECT setval('motion_registry_sequence', 1, false);")
            if self.request.get("form.agendaitems_number") == "on":
                execute_sql("SELECT setval('agendaitem_registry_sequence', 1, false);")
            if self.request.get("form.bills_number") == "on":
                execute_sql("SELECT setval('bill_registry_sequence', 1, false);")
            if self.request.get("form.reports_number") == "on":
                execute_sql("SELECT setval('report_registry_sequence', 1, false);")
            if self.request.get("form.tableddocuments_number") == "on":
                execute_sql("SELECT setval('tableddocument_registry_sequence', 1, false);")
            if self.request.get("form.global_number") == "on":
                execute_sql("SELECT setval('registry_number_sequence', 1, false);")

        settings = \
            component.getUtility(interfaces.IBungeniRegistrySettings)()
        self.adapters = {interfaces.IBungeniRegistrySettings : settings}