Пример #1
0
def list_status(cat_type):
    results = {}
    for lang in lang_codes:
        # missing categories
        cat_trans = db.session.query(Category.category_id).filter_by(
            lang=lang, cat_type=cat_type
        )
        missing_cat = db.session.query(Category).filter_by(
            lang='en', cat_type=cat_type
        )
        missing_cat = missing_cat.filter(
            db.not_(Category.category_id.in_(cat_trans))
        ).count()
        # missing codes
        trans = db.session.query(Code.code_id).filter_by(lang=lang).filter(
            Code.category_id.in_(cat_trans)
        )
        missing_codes = db.session.query(Code).filter_by(lang='en').filter(
            Code.category_id.in_(cat_trans)
        )

        missing_codes = missing_codes.filter(
            db.not_(Code.code_id.in_(trans))
        ).count()

        results[lang] = {'missing': missing_cat + missing_codes,
                         'unpublished': 0}
    return results
Пример #2
0
def org_list():
    set_menu()
    lang = get_admin_lang()
    permission_content(lang)
    orgs = Organisation.query.filter_by(lang=lang, current=True)
    orgs = orgs.order_by('name')
    for org in orgs:
        p = Organisation.query.filter_by(org_id=org.org_id,
                                         lang=lang,
                                         status='publish').first()
        org.has_published = bool(p)
    if lang == 'en':
        missing = []
        trans = {}
    else:
        # missing orgs
        trans = db.session.query(Organisation.org_id).filter_by(lang=lang,
                                                                current=True)
        missing = db.session.query(Organisation).filter_by(lang='en',
                                                           current=True)
        missing = missing.filter(db.not_(Organisation.org_id.in_(trans)))
        missing = missing.order_by('name')
    status = list_status()
    return render_template('admin/org_list.html',
                           orgs=orgs,
                           lang=lang,
                           missing=missing,
                           trans=trans,
                           status=status)
Пример #3
0
def list_status():
    results = {}
    for lang in lang_codes:
        # missing categories
        trans = db.session.query(MenuItem.menu_id).filter_by(
            lang=lang
        )
        missing = db.session.query(MenuItem).filter_by(
            lang='en'
        )
        missing = missing.filter(
            db.not_(MenuItem.menu_id.in_(trans))
        ).count()
        # missing codes
#        trans = db.session.query(Code.code_id).filter_by(lang=lang).filter(
#            Code.menu_id.in_(cat_trans)
#        )
#        missing_codes = db.session.query(Code).filter_by(lang='en').filter(
#            Code.menu_id.in_(cat_trans)
#        )
#
#        missing_codes = missing_codes.filter(
#            db.not_(Code.code_id.in_(trans))
#        ).count()

        results[lang] = {'missing': missing,
                         'unpublished': 0}
    return results
Пример #4
0
def cms_list():
    set_menu()
    lang = get_admin_lang()
    permission_content(lang)
    pages = Cms.query.filter_by(lang=lang, current=True)
    pages = pages.order_by('title')
    for page in pages:
        p = Cms.query.filter_by(page_id=page.page_id,
                                lang=lang,
                                status='publish').first()
        page.has_published = bool(p)
    if lang == 'en':
        missing = []
        trans = {}
    else:
        # missing pages
        trans = db.session.query(Cms.page_id).filter_by(lang=lang)
        missing = db.session.query(Cms).filter_by(lang='en', current=True)
        missing = missing.filter(db.not_(Cms.page_id.in_(trans)))
        missing = missing.order_by('title')
    status = list_status()
    return render_template('admin/cms_list.html',
                           pages=pages,
                           lang=lang,
                           missing=missing,
                           trans=trans,
                           status=status)
Пример #5
0
def org_list():
    set_menu()
    lang = get_admin_lang()
    permission_content(lang)
    orgs = Organisation.query.filter_by(lang=lang, current=True)
    orgs = orgs.order_by('name')
    for org in orgs:
        p = Organisation.query.filter_by(
            org_id=org.org_id, lang=lang, status='publish'
        ).first()
        org.has_published = bool(p)
    if lang == 'en':
        missing = []
        trans = {}
    else:
        # missing orgs
        trans = db.session.query(Organisation.org_id).filter_by(
            lang=lang, current=True
        )
        missing = db.session.query(Organisation).filter_by(
            lang='en', current=True
        )
        missing = missing.filter(db.not_(Organisation.org_id.in_(trans)))
        missing = missing.order_by('name')
    status = list_status()
    return render_template('admin/org_list.html', orgs=orgs, lang=lang,
                           missing=missing, trans=trans, status=status)
Пример #6
0
def category_list(cat_type):
    set_menu(cat_type)
    check_cat_type(cat_type)
    lang = get_admin_lang()
    categories = Category.query.filter_by(
        lang=lang, current=True, cat_type=cat_type
    )
    categories = categories.order_by('"order"', 'title')
    all_ = all_codes(lang, cat_type)
    if lang == 'en':
        missing_cat = []
        m_codes = []
    else:
        # missing categories
        trans = db.session.query(Category.category_id).filter_by(
            lang=lang, cat_type=cat_type
        )
        missing_cat = db.session.query(Category).filter_by(
            lang='en', cat_type=cat_type
        )
        missing_cat = missing_cat.filter(
            db.not_(Category.category_id.in_(trans))
        )
        # missing codes
        trans = db.session.query(Code.code_id).filter_by(lang=lang)
        missing_codes = db.session.query(Code).filter_by(lang='en')
        missing_codes = missing_codes.filter(db.not_(Code.code_id.in_(trans)))
        m_codes = {}
        for code in missing_codes:
            if code.category_id not in m_codes:
                m_codes[code.category_id] = []
            m_codes[code.category_id].append(code)
    status = list_status(cat_type)
    return render_template('admin/category_list.html',
                           categories=categories,
                           missing_cat=missing_cat,
                           m_codes=m_codes,
                           all=all_,
                           cat_type=cat_type,
                           status=status,
                           lang=lang)
Пример #7
0
def list_status():
    results = {}
    for lang in lang_codes:
        # Unpublished
        unpublished = Cms.query.filter_by(
            lang=lang, current=True).filter(Cms.status != 'publish').count()
        # Missing
        trans = db.session.query(Cms.page_id).filter_by(lang=lang)
        missing = db.session.query(Cms).filter_by(lang='en', current=True)
        missing = missing.filter(db.not_(Cms.page_id.in_(trans))).count()
        results[lang] = {'missing': missing, 'unpublished': unpublished}
    return results
Пример #8
0
def update_translations(page):
    trans = Cms.query.filter_by(page_id=page.page_id)
    trans = trans.filter(db.not_(Cms.id == page.id))
    trans = trans.filter(db.or_(Cms.status == 'publish', Cms.current == True))

    for tran in trans:
        tran.active = page.active
        tran.private = page.private
        tran.url = page.url
        tran.image = page.image
        db.session.add(tran)
    db.session.commit()
Пример #9
0
def list_status():
    results = {}
    for lang in lang_codes:
        # Unpublished
        unpublished = Cms.query.filter_by(lang=lang, current=True).filter(
            Cms.status != 'publish'
        ).count()
        # Missing
        trans = db.session.query(Cms.page_id).filter_by(lang=lang)
        missing = db.session.query(Cms).filter_by(lang='en', current=True)
        missing = missing.filter(db.not_(Cms.page_id.in_(trans))).count()
        results[lang] = {'missing': missing, 'unpublished': unpublished}
    return results
Пример #10
0
def update_translations(page):
    trans = Cms.query.filter_by(page_id=page.page_id)
    trans = trans.filter(db.not_(Cms.id == page.id))
    trans = trans.filter(db.or_(
        Cms.status == 'publish', Cms.current == True
    ))

    for tran in trans:
        tran.active = page.active
        tran.private = page.private
        tran.url = page.url
        tran.image = page.image
        db.session.add(tran)
    db.session.commit()
Пример #11
0
def menu_list():
    set_menu()
    lang = get_admin_lang()
    permission_content(lang)
    menu_items = MenuItem.query.filter_by(lang=lang, parent_menu_id=None)
    menu_items = menu_items.order_by('"order"', 'title')
    if lang == 'en':
        missing = []
        trans = {}
    else:
        # missing menu_items
        trans = db.session.query(MenuItem.menu_id).filter_by(lang=lang)
        missing = db.session.query(MenuItem).filter_by(lang='en')
        missing = missing.filter(db.not_(MenuItem.menu_id.in_(trans)))
    status = list_status()
    return render_template('admin/menu_list.html', menu_items=menu_items, lang=lang,
                           missing=missing, trans=trans, status=status)
Пример #12
0
def update_translations(org):
    trans = Organisation.query.filter_by(org_id=org.org_id)
    trans = trans.filter(db.not_(Organisation.id == org.id))
    trans = trans.filter(
        db.or_(Organisation.status == 'publish', Organisation.current == True))

    for tran in trans:
        tran.address = org.address
        tran.contact = org.contact
        tran.phone = org.phone
        tran.email = org.email
        tran.pgp_key = org.pgp_key
        tran.website = org.website
        tran.active = org.active
        tran.private = org.private
        tran.image = org.image
        db.session.add(tran)
    db.session.commit()
Пример #13
0
def update_translations(org):
    trans = Organisation.query.filter_by(org_id=org.org_id)
    trans = trans.filter(db.not_(Organisation.id == org.id))
    trans = trans.filter(
        db.or_(
            Organisation.status == 'publish', Organisation.current == True
        )
    )

    for tran in trans:
        tran.address = org.address
        tran.contact = org.contact
        tran.phone = org.phone
        tran.email = org.email
        tran.pgp_key = org.pgp_key
        tran.website = org.website
        tran.active = org.active
        tran.private = org.private
        tran.image = org.image
        db.session.add(tran)
    db.session.commit()
Пример #14
0
def cms_list():
    set_menu()
    lang = get_admin_lang()
    permission_content(lang)
    pages = Cms.query.filter_by(lang=lang, current=True)
    pages = pages.order_by('title')
    for page in pages:
        p = Cms.query.filter_by(page_id=page.page_id, lang=lang,
                                status='publish').first()
        page.has_published = bool(p)
    if lang == 'en':
        missing = []
        trans = {}
    else:
        # missing pages
        trans = db.session.query(Cms.page_id).filter_by(lang=lang)
        missing = db.session.query(Cms).filter_by(lang='en', current=True)
        missing = missing.filter(db.not_(Cms.page_id.in_(trans)))
        missing = missing.order_by('title')
    status = list_status()
    return render_template('admin/cms_list.html', pages=pages, lang=lang,
                           missing=missing, trans=trans, status=status)