This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct test { | |
int a; | |
int a_square(); | |
}; | |
int test::a_square() | |
{ |
NewerOlder