Ejemplo n.º 1
0
 def process_request(self, request):
 
     request.SUPPORT_LANGUAGES = settings.SUPPORT_LANGUAGES
     request.SITE_NAME = settings.SITE_NAME
     request.SITE_DOMAIN = settings.SITE_DOMAIN
     request.IS_ADMIN = is_admin()
     
     
     current_user = users.get_current_user()
     if current_user:
         request.current_user = UserPref.get_or_insert_by_user(current_user)
     return None
Ejemplo n.º 2
0
def snippet_list(request):
    snippets = Snippet.all().order("-published_at")

    rev_tags = Tag.all().order("-number").order("-inserted_at").fetch(settings.RELEVENT_TAG_LIMIT)

    return object_list(
        request,
        queryset=snippets,
        allow_empty=True,
        template_name="snippet/snippet_list.html",
        extra_context={"is_admin": is_admin(), "CURRENT_PAGE": "snippet_list", "RELEVENT_TAGS": rev_tags},
        paginate_by=settings.SNIPPET_LIST_PAGE_SIZE,
    )
Ejemplo n.º 3
0
def snippet_search(request):
    if request.GET.has_key("keyword"):
        keyword = request.GET["keyword"]
        logging.getLogger().info(keyword)
        if request.GET.has_key("search_language") and request.GET["search_language"]:
            snippets = (
                Snippet.all().filter("language", request.GET["search_language"]).search(keyword).order("-published_at")
            )
        else:
            snippets = Snippet.all().search(keyword).order("-published_at")
    else:
        if request.GET.has_key("search_language") and request.GET["search_language"]:
            snippets = Snippet.all().filter("language", request.GET["search_language"]).order("-published_at")
        else:
            snippets = Snippet.all().order("-published_at")
    rev_tags = Tag.all().order("-number").order("-inserted_at").fetch(settings.RELEVENT_TAG_LIMIT)
    return object_list(
        request,
        queryset=snippets,
        allow_empty=True,
        template_name="snippet/snippet_list.html",
        extra_context={"is_admin": is_admin(), "CURRENT_PAGE": "snippet_list", "RELEVENT_TAGS": rev_tags},
        paginate_by=settings.SNIPPET_LIST_PAGE_SIZE,
    )