diff --git a/forms.py b/forms.py index 21c3d5e..bc36b67 100644 --- a/forms.py +++ b/forms.py @@ -27,7 +27,7 @@ class CategoryForm(ModelForm): class UserForm(ModelForm): class Meta: model = User - exclude = ('is_staff', 'is_active', 'last_login', 'last_joined', 'user_permissions', 'groups', 'date_joined') + exclude = ('is_staff', 'is_active', 'last_login', 'last_joined', 'user_permissions', 'groups', 'date_joined', 'password') class CommentForm(ModelForm): class Meta: diff --git a/generators/post.py b/generators/post.py index 05689cd..6104b43 100644 --- a/generators/post.py +++ b/generators/post.py @@ -145,6 +145,8 @@ class Post(Index): 'replace' : self.createReplace, 'tags' : self.createTags} + self.blog = blog + if not os.path.exists(src + '/_post.html'): self.addError('No _post.html found, exiting') return self.report diff --git a/models.py b/models.py index cbbf394..3f5af89 100644 --- a/models.py +++ b/models.py @@ -178,8 +178,6 @@ class Category(models.Model): super(Category, self).save() def remove(self, blog): - blog.create_paths() - output = blog.output_path + '/category/' + self.name_slug if os.path.exists(output): shutil.rmtree(output) @@ -195,8 +193,6 @@ class Tag(models.Model): super(Tag, self).save() def remove(self, blog): - blog.create_paths() - output = blog.output_path + '/tag/' + self.name_slug if os.path.exists(output): shutil.rmtree(output) @@ -228,7 +224,6 @@ class Post(models.Model): def createPost(self, content, tags): b = self.blog - b.create_paths() output = b.src_path if not os.path.exists(output + '/_post'): os.mkdir(output + '/_post') @@ -312,7 +307,6 @@ class Post(models.Model): def remove(self): b = self.blog - b.create_paths() output = b.src_path filename = output + '/_post/' + str(self.pk) diff --git a/search.py b/search.py index 5ebd3e2..b551203 100644 --- a/search.py +++ b/search.py @@ -109,7 +109,7 @@ class Search: if not word in hashtable: hashtable[word] = [] if not index in hashtable[word]: - hashtable[word].append([index, word_weight]) + hashtable[word].insert(0, [index, word_weight]) else: weight = hashtable[word][1] hashtable[word][1] = weight + word_weight @@ -192,16 +192,16 @@ class Search: if len(word) < Search.MINIMUM_LETTERS: continue word = word.lower() - while not word in hashtable and len(word) > Search.MINIMUM_LETTERS: - word = word[:-1] - if word not in hashtable: - continue - for post in hashtable[word]: - if not post[0] in res: - res[post[0]] = post[1] - res[post[0]] += post[1] - sorted_res = sorted(res.iteritems(), key=operator.itemgetter(1)) + reg = re.compile('.*' + word + '.*') + for key in hashtable.keys(): + if reg.match(key): + for post in hashtable[key]: + if not post[0] in res: + res[post[0]] = post[1] + else: + res[post[0]] += post[1] + sorted_res = sorted(res.iteritems(), key=operator.itemgetter(1)) sorted_res.reverse() res = [] diff --git a/sites/blog.soutade.fr/_post.html b/sites/blog.soutade.fr/_post.html index 0444963..57cb4bf 100755 --- a/sites/blog.soutade.fr/_post.html +++ b/sites/blog.soutade.fr/_post.html @@ -14,14 +14,14 @@
{{ category.id }} | {{ category.name }} | Edit | Delete |
{{ category.id }} | {{ category.name }} | Edit | Delete |
User successfuly updated
+User successfuly updated
{% endif %} {% if user.is_superuser or user.id == user_to_edit.id %} {% else %} + {% endif %} {% endblock %} diff --git a/templates/login.html b/templates/login.html index 2e7ce49..9455396 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,24 +1,6 @@