Пример #1
0
def media_search_results(request, blog_id=None, site_id=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)

    from core.models import Media

    # TODO: move to DB.media_search for indexing

    media_searched = (Media.select(Media.id).where(
        Media.friendly_name.contains(search_terms_enc)
        | Media.filename.contains(search_terms_enc)).order_by(
            Media.id.desc()).tuples())

    if site_id is not None:
        media_searched.select().where(Media.site == site_id)
    if blog_id is not None:
        media_searched.select().where(Media.blog == blog_id)

    return media_searched, search_terms
Пример #2
0
def tag_search_results(request, blog_id=None, site_id=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)

    from core.models import Tag

    # TODO: move to DB.media_search for indexing

    tags_searched = (Tag.select(Tag.id).where(
        Tag.tag.contains(search_terms_enc)).order_by(Tag.tag.asc()).tuples())

    # if site_id is not None:
    # tags_searched.select().where(Tag.blog.site == site_id)
    if blog_id is not None:
        tags_searched.select().where(Tag.blog == blog_id)

    return tags_searched, search_terms
Пример #3
0
def tag_search_results(request, blog_id=None, site_id=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)

    from core.models import Tag

    # TODO: move to DB.media_search for indexing

    tags_searched = (Tag.select(Tag.id)
        .where(Tag.tag.contains(search_terms_enc))
        .order_by(Tag.tag.asc()).tuples())

    # if site_id is not None:
        # tags_searched.select().where(Tag.blog.site == site_id)
    if blog_id is not None:
        tags_searched.select().where(Tag.blog == blog_id)

    return tags_searched, search_terms
Пример #4
0
def media_search_results(request, blog_id=None, site_id=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)

    from core.models import Media

    # TODO: move to DB.media_search for indexing

    media_searched = (Media.select(Media.id)
        .where(Media.friendly_name.contains(search_terms_enc) |
            Media.filename.contains(search_terms_enc))
        .order_by(Media.id.desc()).tuples())

    if site_id is not None:
        media_searched.select().where(Media.site == site_id)
    if blog_id is not None:
        media_searched.select().where(Media.blog == blog_id)

    return media_searched, search_terms
Пример #5
0
def site_search_results(request, site=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)
    pages_searched = DB.site_search(search_terms_enc, site)

    return pages_searched, search_terms
Пример #6
0
def site_search_results(request, site=None):

    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')

    if search_terms == "":
        raise ValueError('Search field is empty.')

    search_terms_enc = utf8_escape(search_terms)
    pages_searched = DB.site_search(search_terms_enc, site)

    return pages_searched, search_terms
Пример #7
0
def media_search_results(request, blog_id=None, site_id=None):
    
    try:
        search_terms = request.query['search']
    except KeyError:
        raise KeyError('No search field in query.')
    
    if search_terms == "":
        raise ValueError('Search field is empty.')
    
    search_terms_enc = utf8_escape(search_terms)
    
    # not working yet
    '''media_searched = (Page_Search.select(Page_Search.id)
        .where(Page_Search.title.contains(search_terms_enc) | Page_Search.text.contains(search_terms_enc))
        .order_by(Page_Search.id.desc()).tuples())
    '''
        
    if site_id is not None:
        pass  #        
    if blog_id is not None:
        pass  # pages_searched = get_blog(blog_id).media().select(Page.id).tuples()
    
    return None
Пример #8
0
            {'field': 'friendly_name',
             'colwidth': '*',
             'label': 'Name',
             'format_raw': lambda x: x.for_listing},
            {'field': 'preview',
             'colwidth': '1%',
             'label': 'Preview',
             'format_raw': lambda x: x.preview_for_listing},
            {'field': 'filename',
             'label': 'Filename',
             'colwidth': '1%',
             'format': lambda x: x.filename},
            {'field': 'path',
             'label': 'Path',
             'colwidth': '20%',
             'format_raw': lambda x: breaks(utf8_escape(x.path))},
             {'field': 'url',
             'label': 'URL',
             'colwidth': '20%',
             'format_raw': lambda x: '<a target="_blank" href="{}">{}</a>'.format(x.url, breaks(utf8_escape(x.url)))
             },
             {'field': 'pages',
             'label': 'Used in',
             'colwidth': '1%',
             'format_raw': lambda x: '<a target="_blank" href="{}">{}</a>'.format(
                 "/blog/{}/media/{}/pages".format(x.blog.id, x.id),
                 x.pages.count()
                 )
             },

        )
Пример #9
0
         {'field':'friendly_name',
         'colwidth':'*',
         'label':'Name',
         'format_raw':lambda x:x.for_listing},
         {'field':'preview',
         'colwidth':'1%',
         'label':'Preview',
         'format_raw':lambda x:x.preview_for_listing},
         {'field':'filename',
         'label':'Filename',
         'colwidth':'1%',
         'format':lambda x:x.filename},
         {'field':'path',
         'label':'Path',
         'colwidth':'20%',
         'format_raw':lambda x:breaks(utf8_escape(x.path))},
         )
     },
 'blog':{
     'none':'No pages found',
     'xrowclass':'overflow',
     'actions':(
         {'unpublish':{
             'label':'Unpublish',
             'action':lambda x:cms.unpublish_page(get_page(x), remove_fileinfo=True)}
         },
         {'republish':{
             'label':'Republish',
             'action':lambda x:cms.publish_page(get_page(x))}
         },
         {'delete':{
Пример #10
0
     'field': 'preview',
     'colwidth': '1%',
     'label': 'Preview',
     'format_raw': lambda x: x.preview_for_listing
 },
 {
     'field': 'filename',
     'label': 'Filename',
     'colwidth': '1%',
     'format': lambda x: x.filename
 },
 {
     'field': 'path',
     'label': 'Path',
     'colwidth': '20%',
     'format_raw': lambda x: breaks(utf8_escape(x.path))
 },
 {
     'field':
     'url',
     'label':
     'URL',
     'colwidth':
     '20%',
     'format_raw':
     lambda x: '<a target="_blank" href="{}">{}</a>'.format(
         x.url, breaks(utf8_escape(x.url)))
 },
 {
     'field':
     'pages',