Пример #1
0
    def newStuffSections(self, lang, section):
        """Access new for the home's new stuff control for Blog, Media, and Events."""
        dv = DataValidator()
        dv.checkLang(lang)
        dv.checkNewsSection(section)

        a = """
        with a as(
        select
        a.id_new::integer as id,
        (b.name || ' ' || b.surname)::varchar as wwwuser,
        publishing_date::date as time,
        title_{} as title,
        a.id_news_section as id_section,
        description_{}::varchar as section,
        a.url_{} as link,
        array_agg(d.id_label_{})::varchar[] as labels
        from
        www.new a inner join www.wwwuser b
        on a.id_wwwuser=b.id_wwwuser
        inner join www.news_section c
        on a.id_news_section=c.id_news_section
        left join www.new_label_{} d 
        on a.id_new=d.id_new
        left join www.label_{} e
        on d.id_label_{}=e.id_label_{}
        where a.published
        group by id, b.name, b.surname, time, title, id_section, section
        ) 
        select
        id as id_item,
        wwwuser,
        time,
        title,
        link,
        section,
        labels
        from a
        where id_section={}
        order by time desc
        limit 5;
        """.format(lang,lang,lang,lang,lang,lang,lang,lang,section)
        return(self.query(a).result())
Пример #2
0
    def newStuffSections(self, lang, section):
        """Access new for the home's new stuff control for Blog, Media, and Events."""
        dv = DataValidator()
        dv.checkLang(lang)
        dv.checkNewsSection(section)

        a = """
        with a as(
        select
        a.id_new::integer as id,
        (b.name || ' ' || b.surname)::varchar as wwwuser,
        publishing_date::date as time,
        title_{} as title,
        a.id_news_section as id_section,
        description_{}::varchar as section,
        a.url_{} as link,
        array_agg(d.id_label_{})::varchar[] as labels
        from
        www.new a inner join www.wwwuser b
        on a.id_wwwuser=b.id_wwwuser
        inner join www.news_section c
        on a.id_news_section=c.id_news_section
        left join www.new_label_{} d 
        on a.id_new=d.id_new
        left join www.label_{} e
        on d.id_label_{}=e.id_label_{}
        where a.published
        group by id, b.name, b.surname, time, title, id_section, section
        ) 
        select
        id as id_item,
        wwwuser,
        time,
        title,
        link,
        section,
        labels
        from a
        where id_section={}
        order by time desc
        limit 5;
        """.format(lang, lang, lang, lang, lang, lang, lang, lang, section)
        return (self.query(a).result())