Skip to content

Instantly share code, notes, and snippets.

class TestSlugs(TestCase):
# This slug must be unique
b = BookPublisher(slug=self.slug)
self.assertRaises(IntegrityError, b.save)
#check if there's only one BookPublisher
self.assertEquals(BookPublisher.objects.count(), 1)
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.name)
if not self.slug_unique:
self.slug_unique = unique_slug(self.slug)
try:
if not self.added_by:
self.added_by_id = 9
except Member.DoesNotExist:
pass
// Search
$("#searchButton").click(function() {
var id = $("#id_word_1").val();
if (id) {
location.replace("/dictionary/redirect/" + id + "/");
return;
}
});
$("#searchTop").submit(function() {
var id = $("#id_word_1").val();
def word_search(request):
match = request.GET.get('q')
result = []
if match is not None and len(match) >= 2:
# We search different variants of spelling
variants = Variant.objects.filter(
Q(name__istartswith=match) | Q(downcoded__istartswith=match)
).values_list("entry__pk").order_by("name")
#include <iostream>
struct test {
int a;
int a_square();
};
int test::a_square()
{