Example #1
0
def _reindex(request):
    "Debug view for reindexing all code snippets with search"
    # TODO: remove
    i = Index(name="snippets")

    docs = []
    for s in CodeSnippet.all():
        docs.append(
            CodeSnippetDocument(
                doc_id=s.key().id(),
                title=s.title,
                code=s.code,
                language_id=s.language,
                language_readable=s.get_language(),
                creator_email=s.creator.email,
                created=s.created.date(),
                modified=datetime.now().date(),
            )
        )
    i.add(docs)

    return HttpResponse("Done")
Example #2
0
    def get_context_data(self, **kwargs):
        ctx = super(Home, self).get_context_data(**kwargs)
        ctx["latest_snippets"] = CodeSnippet.all().order("modified").fetch(5)

        return ctx